/* ============================================================================
   Customer dashboard (/dashboard) — form / table / tile / chrome layer.
   Built entirely on tokens.css variables. Adds only semantic status colours,
   which tokens.css deliberately does not define. Dark theme, RTL, 360px-safe.
   ============================================================================ */

:root {
  --ok:   #10b981;
  --warn: #f59e0b;
  --err:  #ef4444;
  --ok-soft:   rgba(16, 185, 129, 0.14);
  --warn-soft: rgba(245, 158, 11, 0.14);
  --err-soft:  rgba(239, 68, 68, 0.14);
}

body.dash {
  background: var(--bg-page);
  color: var(--text-secondary);
  font-family: var(--font-fa);
  min-height: 100vh;
  margin: 0;
}

/* ---- header + tabs ---- */
.dash-head {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 10;
}
.dash-head-row {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-2); padding: var(--space-2) var(--gutter);
}
.dash-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text-primary); text-decoration: none;
  font-weight: 800; font-size: 1.15rem;
}
.dash-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.dash-shoplink { color: var(--accent-bright); text-decoration: none; font-size: .9rem; }
.dash-shoplink:hover { color: var(--accent); }
.dash-user { color: var(--text-secondary); font-size: .9rem; }
.dash-logout { color: var(--err); text-decoration: none; font-size: .9rem; }

.dash-tabs {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; gap: 4px; padding: 0 var(--gutter) var(--space-1);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.dash-tab {
  white-space: nowrap; padding: 10px 14px; border-radius: var(--radius-btn);
  color: var(--text-secondary); text-decoration: none; font-size: .92rem;
  border: 1px solid transparent;
}
.dash-tab:hover { color: var(--text-primary); background: var(--accent-soft); }
.dash-tab.is-active {
  color: var(--text-primary); background: var(--accent-soft);
  border-color: var(--border-strong);
}

/* ---- main ---- */
.dash-main { max-width: var(--max-width); margin: 0 auto; padding: var(--space-4) var(--gutter); }
.dash-foot { text-align: center; color: var(--text-muted); font-size: .85rem; padding: var(--space-4) var(--gutter); }
.dash-h1 { color: var(--text-primary); font-size: 1.4rem; margin: 0 0 var(--space-3); }
.dash-hello { color: var(--text-primary); font-size: 1.5rem; margin: 0 0 4px; }
.dash-sub { color: var(--text-muted); margin: 0 0 var(--space-4); }

/* ---- stat tiles ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.stat-tile {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-card); padding: var(--space-3);
}
.stat-tile .stat-val { color: var(--text-primary); font-size: 1.6rem; font-weight: 800; }
.stat-tile .stat-lbl { color: var(--text-muted); font-size: .88rem; margin-top: 4px; }
.stat-tile.accent .stat-val { color: var(--accent-bright); }

/* ---- cards / sections ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-card); padding: var(--space-3); margin-bottom: var(--space-3);
}
.card h2 { color: var(--text-primary); font-size: 1.1rem; margin: 0 0 var(--space-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; text-align: right; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--border-soft); font-size: .92rem; }
.table th { color: var(--text-muted); font-weight: 600; }
.table td { color: var(--text-secondary); }

/* ---- status badges ---- */
.badge-status { display: inline-block; padding: 4px 10px; border-radius: var(--radius-pill); font-size: .8rem; }
.badge-status--ok   { background: var(--ok-soft);   color: var(--ok); }
.badge-status--warn { background: var(--warn-soft); color: var(--warn); }
.badge-status--wait { background: var(--accent-soft); color: var(--accent-bright); }

/* ---- alerts ---- */
.alert { border-radius: var(--radius-btn); padding: 12px 14px; font-size: .92rem; margin-bottom: var(--space-3); }
.alert-ok   { background: var(--ok-soft);   color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-err  { background: var(--err-soft);  color: var(--err); }

/* ---- forms ---- */
.field { display: block; margin-bottom: var(--space-3); }
.field > span { display: block; color: var(--text-secondary); font-size: .9rem; margin-bottom: 8px; }
.input {
  width: 100%; box-sizing: border-box; min-height: 44px;
  background: var(--bg-page-deep); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-btn);
  padding: 10px 12px; font-family: var(--font-fa); font-size: 1rem;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-hint { color: var(--text-muted); font-size: .82rem; margin-top: 6px; }

/* ---- empty state ---- */
.empty-state {
  text-align: center; padding: var(--space-5) var(--space-3);
  background: var(--bg-card); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card); color: var(--text-muted);
}
.empty-state p { margin: 0 0 var(--space-3); }

/* ---- dev login picker (TEMPORARY) ---- */
.dev-banner {
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid var(--warn); border-radius: var(--radius-btn);
  padding: 12px 14px; margin-bottom: var(--space-3); font-size: .9rem; text-align: center;
}
.dev-list { display: grid; gap: var(--space-2); }
.dev-user {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-card); padding: var(--space-2) var(--space-3);
}
.dev-user .u-name { color: var(--text-primary); }
.dev-user .u-phone { color: var(--text-muted); font-size: .85rem; }

/* keep the shared components.css .btn set; just size a couple */
.btn-block { width: 100%; }
.dl-list { list-style: none; padding: 0; margin: 0; }
.dl-list li { display: flex; justify-content: space-between; gap: var(--space-2); padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.dl-list li span:first-child { color: var(--text-muted); }
.dl-list li span:last-child { color: var(--text-primary); }
.ref-code {
  font-family: monospace; font-size: 1.3rem; letter-spacing: 2px;
  color: var(--accent-bright); background: var(--accent-soft);
  padding: 8px 16px; border-radius: var(--radius-btn); display: inline-block;
}

/* ---- responsive ---- */
@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
  .dash-main { padding: var(--space-3) var(--space-2); }
  .dash-head-row { padding: var(--space-2); }
}

/* ---- ticket thread ---- */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: var(--space-3); }
.msg { max-width: 80%; padding: 12px 14px; border-radius: var(--radius-card); }
.msg .msg-meta { font-size: .74rem; color: var(--text-muted); margin-bottom: 6px; }
.msg .msg-body { color: var(--text-primary); white-space: pre-wrap; word-break: break-word; }
.msg-user  { align-self: flex-start; background: var(--bg-card-alt); border: 1px solid var(--border-soft); }
.msg-admin { align-self: flex-end;   background: var(--accent-soft); border: 1px solid var(--border-strong); }

/* ── login / OTP auth screen ─────────────────────────────────────────────── */
.auth-wrap { max-width: 420px; margin: 0 auto; }
.auth-lead { color: var(--muted, #9aa4c0); margin: 4px 0 18px; line-height: 1.9; }
.auth-card { display: flex; flex-direction: column; gap: 14px; }
.field-label { font-size: .9rem; color: var(--muted, #9aa4c0); }
.otp-input { font-size: 1.5rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
