/* ── Vaulted — Customer UI ── */
:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --border: #2e2e2e;
  --gold: #c9a84c;
  --gold-light: #e8c76a;
  --text: #e8e8e8;
  --text-muted: #888;
  --danger: #e05555;
  --success: #4caf6e;
  --radius: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

input, textarea, select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 80px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
button:hover, .btn:hover { background: var(--gold-light); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c44; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Auth pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .logo-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
}
.auth-logo .logo-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.auth-card button[type="submit"] {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 12px;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.error-msg {
  background: rgba(224,85,85,.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-msg.visible { display: block; }

/* ── App shell ── */
.app-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cart-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius);
  position: relative;
}
.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--gold);
  color: #000;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-badge:empty { display: none; }

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  border-radius: 0;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); background: transparent; }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.app-main { padding: 24px 20px; max-width: 1100px; margin: 0 auto; }

/* ── Products grid ── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s;
}
.product-card:hover { border-color: var(--gold); }
.product-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 40px;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-info { padding: 14px; }
.product-name { font-weight: 600; margin-bottom: 4px; }
.product-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; line-height: 1.4; }
.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.product-price { font-size: 18px; font-weight: 700; color: var(--gold); }
.product-stock { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.out-of-stock { opacity: .5; }

/* ── Cart drawer ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  display: none;
}
.overlay.open { display: block; }
.drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 201;
  transition: right .25s ease;
  display: flex;
  flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-header h2 { font-size: 18px; font-weight: 600; }
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}
.close-btn:hover { color: var(--text); background: transparent; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  background: var(--bg3);
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 500; margin-bottom: 4px; }
.cart-item-price { color: var(--gold); font-size: 13px; }
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.qty-btn {
  width: 26px;
  height: 26px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}
.qty-btn:hover { background: var(--border); }
.qty-val { min-width: 24px; text-align: center; font-weight: 600; }
.cart-total { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.cart-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* ── Checkout modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-box h2 { margin-bottom: 20px; font-size: 20px; }
.modal-box .form-group { margin-bottom: 14px; }
.order-summary-list { margin: 12px 0; }
.order-summary-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.order-total-line {
  display: flex;
  justify-content: space-between;
  padding: 12px 0 0;
  font-weight: 700;
  font-size: 16px;
}

/* ── Orders tab ── */
.orders-list { display: flex; flex-direction: column; gap: 12px; }
.order-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}
.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.order-id { font-weight: 600; }
.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}
.status-pending { background: rgba(201,168,76,.15); color: var(--gold); }
.status-confirmed { background: rgba(76,175,110,.15); color: var(--success); }
.status-out_for_delivery { background: rgba(100,150,255,.15); color: #6496ff; }
.status-delivered { background: rgba(76,175,110,.2); color: var(--success); }
.status-cancelled { background: rgba(224,85,85,.15); color: var(--danger); }

/* ── Chat tab ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  max-height: 600px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.chat-status-dot.online { background: var(--success); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-row.mine .msg-bubble {
  background: var(--gold);
  color: #0f0f0f;
  border-bottom-right-radius: 3px;
}
.msg-row.theirs .msg-bubble {
  background: var(--bg3);
  border-bottom-left-radius: 3px;
}
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  text-align: right;
}
.chat-input-area {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.chat-input-area input { flex: 1; }
.chat-input-area button { flex-shrink: 0; padding: 10px 16px; }
.typing-indicator {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 18px;
  height: 22px;
}

/* ── Referrals tab ── */
.referral-code-box {
  background: var(--bg2);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}
.referral-code-box .code {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 4px;
  margin: 12px 0;
}
.ref-stats { display: flex; gap: 12px; margin-bottom: 20px; }
.ref-stat-card {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.ref-stat-card .num { font-size: 28px; font-weight: 700; color: var(--gold); }
.ref-stat-card .label { font-size: 13px; color: var(--text-muted); }
.referred-list { display: flex; flex-direction: column; gap: 8px; }
.referred-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
}

/* ── Utilities ── */
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  max-width: 300px;
  animation: slideIn .2s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 600px) {
  .app-main { padding: 16px 14px; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .drawer { width: 100vw; }
  .tab-btn { padding: 12px 12px; font-size: 13px; }
  .ref-stats { flex-direction: column; }
}
