/* dashboard.css — Best Auto Zone admin */

:root {
  --ink: #0B0B0F;
  --ink-soft: #1A1A22;
  --paper: #F6F7FA;
  --bg: #FFFFFF;
  --red: #DC1F2D;
  --red-d: #B0151F;
  --red-soft: #FBE7E9;
  --line: #E4E5EA;
  --line-soft: #F0F1F4;
  --mute: #6E6E78;
  --ok: #14794A;
  --ok-soft: #DEFBED;
  --warn: #B0750D;
  --warn-soft: #FFF4D9;

  --shadow-sm: 0 1px 3px rgba(11,11,15,.06);
  --shadow-md: 0 8px 24px rgba(11,11,15,.08);

  --display: 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body.dash {
  margin: 0;
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3 { font-family: var(--display); font-style: italic; color: var(--ink); margin: 0; letter-spacing: -0.01em; text-transform: uppercase; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }

a { color: var(--red-d); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ---------- Sidebar ---------- */
.side {
  width: 250px;
  flex-shrink: 0;
  background: var(--ink);
  color: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
}
.side__brand:hover { text-decoration: none; }
.side__mark {
  width: 38px; height: 38px;
  background: var(--red);
  color: #fff;
  font-family: var(--display);
  font-style: italic;
  font-weight: 900;
  display: grid;
  place-items: center;
  font-size: 12px;
  transform: skewX(-12deg);
  letter-spacing: -0.02em;
}
.side__mark span { transform: skewX(12deg); display: inline-block; }
.side__brand strong { display: block; color: #fff; font-family: var(--display); font-style: italic; font-size: 1rem; }
.side__brand small { color: rgba(255,255,255,.55); font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; }

.side__nav { padding: 14px 10px; flex: 1; }
.side__nav a {
  display: block;
  padding: 11px 14px;
  margin-bottom: 2px;
  color: rgba(255,255,255,.75);
  font-weight: 500;
  font-size: .95rem;
}
.side__nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side__nav a.is-active {
  background: rgba(220,31,45,.15);
  color: #fff;
  border-left: 3px solid var(--red);
  padding-left: 11px;
}

.side__foot {
  padding: 14px 10px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side__foot a {
  padding: 9px 14px;
  color: rgba(255,255,255,.65);
  font-size: .88rem;
}
.side__foot a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__user { color: var(--mute); font-size: .9rem; }
.content { padding: 24px 32px 48px; }

/* ---------- Range bar ---------- */
.range-bar {
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.range-bar__chips { display: flex; gap: 4px; flex-wrap: wrap; }
.range-bar__chips a {
  padding: 7px 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--mute);
  background: var(--paper);
  border: 1px solid transparent;
}
.range-bar__chips a:hover { color: var(--ink); text-decoration: none; }
.range-bar__chips a.is-active { background: var(--ink); color: #fff; }
.range-bar__custom { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.range-bar__custom label { font-size: .82rem; font-weight: 600; color: var(--mute); display: flex; flex-direction: column; gap: 4px; }
.range-bar__custom input { padding: 6px 8px; border: 1px solid var(--line); }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 20px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat__label { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); font-weight: 600; }
.stat__value { font-family: var(--display); font-style: italic; font-size: 2.2rem; color: var(--ink); line-height: 1; }
.stat__note { color: var(--mute); font-size: .76rem; }
.stat--good { border-left: 4px solid var(--ok); }
.stat--good .stat__value { color: var(--ok); }

/* ---------- Panels ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel__head h2 small { color: var(--mute); font-family: var(--body); font-weight: 500; font-size: .82rem; font-style: normal; text-transform: none; }
.panel--narrow { max-width: 540px; }
.panel--wide { grid-column: 1 / -1; }

.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.d-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.d-table th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mute);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.d-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.d-table tbody tr:hover td { background: var(--paper); }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill--st-new       { background: #DCE7F5; color: #143E70; }
.pill--st-contacted { background: #FFF4D9; color: #6A4A05; }
.pill--st-quoted    { background: #FAE3CC; color: #7A3F05; }
.pill--st-sold      { background: #D4F0DC; color: #14542A; }
.pill--st-shipped   { background: #C4ECF8; color: #0C547A; }
.pill--st-completed { background: #BFE5C8; color: #0E4523; }
.pill--st-cancelled { background: #FBDADD; color: #7A1822; }
.pill--st-lost      { background: #E1E1E5; color: #4A4A52; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .85rem; color: var(--ink); }
.field input,
.field select,
.field textarea {
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,31,45,.12);
}
.field textarea { resize: vertical; min-height: 100px; font-family: inherit; }
.field small { color: var(--mute); font-size: .82rem; }
.field input[readonly], .field select:disabled { background: #f4f5f7; color: var(--mute); }

.inline-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.inline-row .field { flex: 1 1 200px; margin-bottom: 0; }
.field--actions { flex: 0 0 auto !important; }

.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------- Buttons ---------- */
.d-btn {
  display: inline-block;
  padding: 10px 16px;
  font-family: var(--display);
  font-style: italic;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transform: skewX(-12deg);
  transition: background .15s, color .15s, border-color .15s;
}
.d-btn span { display: inline-block; transform: skewX(12deg); }
.d-btn:hover { text-decoration: none; }
.d-btn--primary { background: var(--red); color: #fff; }
.d-btn--primary:hover { background: var(--red-d); }
.d-btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.d-btn--ghost:hover { background: var(--paper); border-color: var(--ink); }
.d-btn--sm { padding: 7px 12px; font-size: 11px; }
.d-btn--block { display: block; width: 100%; text-align: center; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  align-items: end;
}
.filter-bar__group { display: flex; flex-direction: column; gap: 4px; }
.filter-bar__group label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); font-weight: 600; }
.filter-bar__group input, .filter-bar__group select {
  padding: 7px 10px; border: 1px solid var(--line); background: #fff;
}
.filter-bar__group--actions { display: flex; flex-direction: row; gap: 6px; align-items: end; }

/* ---------- Alerts ---------- */
.alert {
  padding: 11px 16px;
  margin-bottom: 16px;
  border-left: 4px solid;
  font-size: .92rem;
}
.alert--good { background: var(--ok-soft); color: #14542A; border-color: var(--ok); }
.alert--bad  { background: var(--red-soft); color: #7A1822; border-color: var(--red); }
.alert--warn { background: var(--warn-soft); color: #6A4A05; border-color: var(--warn); }

/* ---------- KV (definition lists) ---------- */
.kv { display: grid; grid-template-columns: 1fr 2fr; gap: 8px 16px; margin: 0; }
.kv--2 { grid-template-columns: repeat(2, auto 1fr); }
.kv dt { font-weight: 600; color: var(--mute); font-size: .85rem; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.kv dd { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.addr { background: var(--paper); padding: 14px; font-style: normal; line-height: 1.6; margin: 0; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--mute); font-weight: 500; }

/* ---------- Charts ---------- */
.chart { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--mute); text-align: center; padding: 40px 20px; font-style: italic; }

/* horizontal bar chart */
.hbar { display: flex; flex-direction: column; gap: 8px; }
.hbar__row { display: grid; grid-template-columns: 160px 1fr 50px; gap: 12px; align-items: center; }
.hbar__label { font-size: .88rem; font-weight: 500; }
.hbar__track { background: var(--line-soft); height: 16px; overflow: hidden; }
.hbar__fill { background: var(--ink); height: 100%; transition: width .3s ease; }
.hbar__fill--st-new       { background: #143E70; }
.hbar__fill--st-contacted { background: #B0750D; }
.hbar__fill--st-quoted    { background: #7A3F05; }
.hbar__fill--st-sold      { background: #14542A; }
.hbar__fill--st-shipped   { background: #0C547A; }
.hbar__fill--st-completed { background: #0E4523; }
.hbar__fill--st-cancelled { background: var(--red); }
.hbar__fill--st-lost      { background: #4A4A52; }
.hbar__count { text-align: right; font-family: var(--display); font-style: italic; color: var(--ink); font-size: 1rem; }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel__row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 14px; align-items: center; }
.funnel__label { font-weight: 600; font-size: .92rem; }
.funnel__bar { background: var(--line-soft); height: 28px; overflow: hidden; }
.funnel__fill {
  background: linear-gradient(90deg, var(--red) 0%, var(--red-d) 100%);
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  transition: width .4s ease;
}
.funnel__pct { font-family: var(--display); font-style: italic; color: var(--ink); }

/* ---------- Login ---------- */
.dash--login {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ink) 0%, #1A1A22 100%);
  padding: 24px;
}
.dash--login::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0, transparent 80px, rgba(220,31,45,0.03) 80px, rgba(220,31,45,0.03) 82px);
  pointer-events: none;
}
.login-wrap { width: 100%; max-width: 440px; position: relative; }
.login-card {
  background: #fff;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
  border-top: 4px solid var(--red);
}
.login-card__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card__mark {
  width: 44px; height: 44px;
  background: var(--ink);
  color: var(--red);
  font-family: var(--display);
  font-style: italic;
  font-weight: 900;
  display: grid; place-items: center;
  font-size: 14px;
  transform: skewX(-12deg);
  letter-spacing: -0.02em;
}
.login-card__mark span { transform: skewX(12deg); display: inline-block; }
.login-card__brand strong { display: block; color: var(--ink); font-family: var(--display); font-style: italic; font-size: 1.05rem; }
.login-card__brand small { font-size: .68rem; color: var(--mute); text-transform: uppercase; letter-spacing: .14em; }
.login-card h1 { margin-bottom: 4px; }
.login-card__sub { color: var(--mute); margin: 0 0 20px; font-size: .92rem; }

/* ---------- Misc ---------- */
.muted { color: var(--mute); }
.small { font-size: .85rem; }
.empty { color: var(--mute); padding: 20px 0; text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  body.dash { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; }
  .side__brand { border-bottom: 0; border-right: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }
  .side__nav { display: flex; padding: 12px; flex: 1; overflow-x: auto; }
  .side__nav a { margin: 0 4px 0 0; padding: 9px 12px; white-space: nowrap; }
  .side__nav a.is-active { border-left: 0; border-bottom: 3px solid var(--red); padding-left: 12px; }
  .side__foot { display: none; }
  .topbar { padding: 14px 18px; }
  .content { padding: 18px; }
  .dash-grid-2 { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .hbar__row { grid-template-columns: 110px 1fr 40px; }
  .funnel__row { grid-template-columns: 120px 1fr 50px; }
}
@media (max-width: 560px) {
  .filter-bar { grid-template-columns: 1fr; }
  .stat__value { font-size: 1.6rem; }
  .range-bar { flex-direction: column; align-items: stretch; }
  .range-bar__custom { justify-content: space-between; }
}
/* ---------- Mobile improvements ---------- */
@media (max-width: 768px) {
  /* Hide table on mobile, show card-style stacks */
  .d-table thead { display: none; }
  .d-table tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
  }
  .d-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line);
    gap: 12px;
  }
  .d-table tbody td:last-child { border-bottom: 0; padding-top: 10px; }
  .d-table tbody td::before {
    content: attr(data-label);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--mute);
    flex-shrink: 0;
  }
  /* For when data-label is not set, hide the prefix */
  .d-table tbody td:empty::before { content: ''; }

  /* Bigger touch targets */
  .d-btn, .d-btn--sm { min-height: 40px; }

  /* Stat values smaller */
  .stat__value { font-size: 1.6rem; }

  /* Charts scale */
  .chart { max-width: 100%; height: auto; }
  .hbar__row { grid-template-columns: 90px 1fr 36px; }
  .funnel__row { grid-template-columns: 100px 1fr 40px; }
  .funnel__fill { font-size: .8rem; padding: 0 8px; }

  /* Range bar stacks */
  .range-bar__chips { width: 100%; }
  .range-bar__chips a { flex: 1 1 auto; text-align: center; }
  .range-bar__custom { width: 100%; justify-content: space-between; }

  /* Filter bar stacks */
  .filter-bar { grid-template-columns: 1fr; gap: 10px; padding: 14px; }

  /* KV stacks */
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .kv dt { padding: 6px 0 0; border-bottom: 0; }
  .kv dd { padding: 0 0 8px; border-bottom: 1px solid var(--line-soft); }
  .kv--2 { grid-template-columns: 1fr; }

  /* Login card padding */
  .login-card { padding: 28px 22px; }
}


/* ============ Status pill colors ============ */
.st-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.st-received   { background: #dbeafe; color: #1e40af; }
.st-reviewing  { background: #fef3c7; color: #92400e; }
.st-confirmed  { background: #d1fae5; color: #065f46; }
.st-shipped    { background: #e0e7ff; color: #3730a3; }
.st-in-transit { background: #cffafe; color: #155e75; }
.st-delivered  { background: #d1fae5; color: #064e3b; }
.st-cancelled  { background: #fee2e2; color: #991b1b; }

/* ============ Tracking URL box (on order detail page) ============ */
.tracking-url-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.tracking-url-box__label {
    font-size: 0.85rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 4px;
}
.tracking-url-box__url {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #111827;
    word-break: break-all;
}
.tracking-url-box__copy-btn {
    background: #C8102E;
    color: white;
    border: 0;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}
.tracking-url-box__copy-btn:hover { opacity: 0.9; }
.tracking-url-box__copied {
    color: #059669;
    font-weight: 600;
    font-size: 0.85rem;
    display: none;
}

/* ============ Status history timeline ============ */
.status-history {
    margin: 24px 0;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}
.status-history__entry {
    padding: 10px 0;
    border-left: 2px solid #e5e7eb;
    padding-left: 16px;
    margin-bottom: 12px;
    position: relative;
}
.status-history__entry::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 14px;
    width: 12px;
    height: 12px;
    background: #6b7280;
    border-radius: 50%;
}
.status-history__entry--cancelled::before { background: #ef4444; }
.status-history__when { font-size: 0.85rem; color: #6b7280; }
.status-history__change { font-weight: 600; margin: 4px 0; }
.status-history__reason { color: #6b7280; font-size: 0.9rem; margin-top: 4px; }

/* ============ Cancel reason field (shown on status change to Cancelled) ============ */
.cancel-reason-wrap { display: none; margin-top: 12px; }
.cancel-reason-wrap.is-visible { display: block; }
.cancel-reason-wrap textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}
.cancel-reason-wrap__quick-fills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.cancel-reason-wrap__quick-fill {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
}
.cancel-reason-wrap__quick-fill:hover { background: #e5e7eb; }
