/* Admin — a dark operations console, deliberately distinct from the
   marketing site. Loaded globally from layout.tsx, so every rule here is
   scoped under .admin-shell or an admin- prefix to keep it off the
   storefront. Palette borrows the brand gradient (#2AA5C9 → #5E6AC9) and
   nothing else. */

.admin-shell {
  --bg: #070b14;
  --bg-side: #0a0f1c;
  --surface: rgba(255, 255, 255, 0.032);
  --surface-hi: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.075);
  --line-hi: rgba(255, 255, 255, 0.14);
  --text: #e8eefc;
  --dim: #7d89ab;
  --dimmer: #5c6684;
  --accent: #2aa5c9;
  --accent-2: #5e6ac9;
  --good: #3ddc97;
  --warn: #ffb454;
  --bad: #ff6b6b;

  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px 1fr;
  background:
    radial-gradient(1100px 620px at 78% -12%, rgba(94, 106, 201, 0.16), transparent 62%),
    radial-gradient(760px 460px at 4% 104%, rgba(42, 165, 201, 0.11), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.admin-side {
  padding: 26px 16px 20px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-side), #080d18);
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-logo { padding: 0 8px; display: block; }
.admin-logo img { height: 26px; width: auto; }

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-nav a svg { flex: none; opacity: 0.85; }
.admin-nav a:hover { background: var(--surface-hi); color: var(--text); }
.admin-nav a.on {
  background: linear-gradient(90deg, rgba(42, 165, 201, 0.18), rgba(94, 106, 201, 0.08));
  color: #fff;
}
/* The active marker is a bar rather than a fill so the icon stays legible. */
.admin-nav a.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2.5px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.admin-nav a.on svg { opacity: 1; color: #6fd0ea; }

.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 180, 84, 0.18);
  color: var(--warn);
}

.admin-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.admin-side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--dimmer);
  text-decoration: none;
  font-size: 13px;
}
.admin-side-link:hover { background: var(--surface-hi); color: var(--text); }
.admin-me {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--dimmer);
  padding: 12px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}
.admin-me-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.14);
  flex: none;
}
.admin-me-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Page frame ──────────────────────────────────────────────────────── */

.admin-main { padding: 30px 36px 64px; min-width: 0; }

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.admin-title {
  font-family: Orbitron, sans-serif;
  font-size: 21px;
  letter-spacing: 0.055em;
  margin: 0;
}
.admin-sub { margin: 6px 0 0; font-size: 13px; color: var(--dim); }
.admin-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.admin-search {
  position: relative;
  display: flex;
  align-items: center;
}
.admin-search svg {
  position: absolute;
  left: 11px;
  width: 16px; height: 16px;
  color: var(--dimmer);
  pointer-events: none;
}
.admin-search input {
  width: 240px;
  padding: 9px 12px 9px 34px;
  border-radius: 9px;
  border: 1px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.admin-search input::placeholder { color: var(--dimmer); }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}
.admin-btn:hover { background: rgba(255, 255, 255, 0.1); }
.admin-btn:active { transform: translateY(1px); }
.admin-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 5px 18px -8px rgba(94, 106, 201, 0.9);
}
.admin-btn.primary:hover { filter: brightness(1.09); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.admin-btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* ── Stat cards ──────────────────────────────────────────────────────── */

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.admin-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 17px 18px;
  overflow: hidden;
}
/* A hairline of colour at the top edge marks the card that matters, without
   repainting the whole surface. */
.admin-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: transparent;
}
.admin-card.accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.admin-card.warn::before { background: var(--warn); }
.admin-card.danger::before { background: var(--bad); }
.admin-card.warn .ac-value { color: var(--warn); }
.admin-card.danger .ac-value { color: var(--bad); }

.ac-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  font-weight: 600;
}
.ac-value {
  font-family: Orbitron, sans-serif;
  font-size: 27px;
  line-height: 1.15;
  margin: 8px 0 9px;
  letter-spacing: 0.01em;
}
.ac-value.sm { font-size: 19px; }
.ac-of { font-size: 15px; color: var(--dimmer); }
.ac-link { font-size: 12.5px; color: #8fa0ff; text-decoration: none; }
.ac-link:hover { text-decoration: underline; }
.ac-hint { font-size: 12px; color: var(--dimmer); }

/* ── Low-stock alert ─────────────────────────────────────────────────── */

.admin-alert {
  border: 1px solid rgba(255, 180, 84, 0.28);
  background: linear-gradient(180deg, rgba(255, 180, 84, 0.09), rgba(255, 180, 84, 0.02));
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 26px;
}
.alert-head { display: flex; align-items: center; gap: 10px; }
.alert-head svg { color: var(--warn); flex: none; }
.alert-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #ffd9a8;
}
.alert-head .admin-btn { margin-left: auto; }
.alert-list { list-style: none; margin: 13px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.alert-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 180, 84, 0.14);
}
.alert-list a { color: var(--text); text-decoration: none; }
.alert-list a:hover { text-decoration: underline; }
.alert-list strong { margin-left: auto; color: var(--warn); font-family: Orbitron, sans-serif; font-size: 13px; }

/* ── Sections ────────────────────────────────────────────────────────── */

.dash-split { display: grid; grid-template-columns: 1.65fr 1fr; gap: 22px; align-items: start; }
.admin-section { margin-top: 8px; min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.admin-section h2 {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9fb0d8;
  margin: 0 0 12px;
  font-weight: 600;
}
.section-head h2 { margin: 0; }
.admin-link { color: #8fa0ff; text-decoration: none; font-size: 12.5px; }
.admin-link:hover { text-decoration: underline; }

/* Best-seller ranking */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rank-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
}
.rank-n {
  width: 22px; height: 22px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 6px;
  background: rgba(94, 106, 201, 0.2);
  color: #a6b3ff;
  font-size: 11px;
  font-weight: 700;
}
.rank-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rank-name strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name span { font-size: 11.5px; color: var(--dimmer); }
.rank-val { margin-left: auto; font-family: Orbitron, sans-serif; font-size: 13px; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.admin-table-wrap {
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: auto;
  background: var(--surface);
  max-width: 100%;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th,
.admin-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0d1322;
  font-weight: 600;
  color: #9fb0d8;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  white-space: nowrap;
}
.admin-table tbody tr { transition: background 0.12s ease; }
.admin-table tbody tr:hover { background: rgba(255, 255, 255, 0.028); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table td.num,
.admin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table td.strong { font-weight: 600; }
.admin-table td.pos { color: var(--good); }
.admin-table td.neg { color: var(--bad); }
.admin-table code { font-size: 11.5px; color: var(--dimmer); display: block; margin-top: 2px; }
.admin-table a { color: #8fa0ff; text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }
.admin-table tr.row-off td { opacity: 0.55; }

.inv-name { color: var(--text) !important; font-weight: 500; }
.inv-name:hover { color: #8fa0ff !important; }

/* Customer identity cell */
.cust-cell { display: flex; align-items: center; gap: 11px; }
.cust-avatar {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(42, 165, 201, 0.3), rgba(94, 106, 201, 0.3));
  color: #cfe3ff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.cust-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cust-id strong { font-weight: 500; }
.cust-id span { font-size: 11.5px; color: var(--dimmer); }
.cust-note { margin: 10px 0; padding-left: 11px; border-left: 2px solid var(--line-hi); }

/* Inline stock adjustment */
.inv-adjust { display: flex; gap: 6px; align-items: center; }
.inv-adjust input {
  width: 66px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  text-align: right;
}
.inv-adjust select {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--line-hi);
  background: #131a2c;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}

/* ── Pills ───────────────────────────────────────────────────────────── */

.admin-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  white-space: nowrap;
}
.admin-flags { display: inline-flex; gap: 5px; align-items: center; }

.pill-enquiry   { background: rgba(42, 165, 201, 0.18);  color: #7fd6f0; }
.pill-pending   { background: rgba(255, 180, 84, 0.18);  color: #ffcb7a; }
.pill-paid      { background: rgba(94, 106, 201, 0.22);  color: #a6b3ff; }
.pill-shipped   { background: rgba(61, 220, 151, 0.16);  color: #7ee4b0; }
.pill-cancelled { background: rgba(220, 90, 90, 0.18);   color: #ff9a9a; }

.stock-in        { background: rgba(61, 220, 151, 0.15);  color: #7ee4b0; }
.stock-low       { background: rgba(255, 180, 84, 0.18);  color: #ffcb7a; }
.stock-out       { background: rgba(255, 107, 107, 0.18); color: #ff9a9a; }
/* Backorder is a debt, not an error — violet keeps it distinct from red
   "out" and amber "low" so the three read apart at a glance. */
.stock-backorder { background: rgba(168, 120, 255, 0.20); color: #cbb0ff; }
.stock-sold-out  { background: rgba(255, 107, 107, 0.14); color: #ffb3b3; }
.stock-untracked { background: rgba(255, 255, 255, 0.06); color: var(--dim); }

.admin-pill.live   { background: rgba(61, 220, 151, 0.15); color: #7ee4b0; }
.admin-pill.off    { background: rgba(255, 255, 255, 0.06); color: var(--dim); }
.admin-pill.feat   { background: rgba(255, 200, 84, 0.16); color: #ffd97a; }
.admin-pill.reason { background: rgba(255, 255, 255, 0.06); color: var(--dim); }

/* ── Filters ─────────────────────────────────────────────────────────── */

.admin-filters { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-filters a {
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
  color: var(--dim);
  text-decoration: none;
  font-size: 12.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-filters a:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
.admin-filters a.on {
  background: rgba(94, 106, 201, 0.24);
  border-color: rgba(94, 106, 201, 0.45);
  color: #fff;
}

/* ── Empty states & muted text ───────────────────────────────────────── */

.admin-blank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 50px 20px;
  border: 1px dashed var(--line-hi);
  border-radius: 14px;
  color: var(--dim);
  text-align: center;
}
.admin-blank svg { width: 30px; height: 30px; opacity: 0.4; }
.admin-blank p { margin: 0; font-size: 13.5px; }
.admin-empty { color: var(--dimmer); font-style: italic; font-size: 13px; }
.admin-dim { color: var(--dim); }
.admin-hint { color: var(--dimmer); font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────────────── */

.admin-form { display: flex; flex-direction: column; gap: 15px; max-width: 820px; }
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: #9fb0d8;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.admin-form input,
.admin-form select {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-hi);
  background: #121a2b;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.admin-form input:focus,
.admin-form select:focus,
.admin-search input:focus,
.inv-adjust input:focus,
.inv-adjust select:focus {
  outline: none;
  border-color: rgba(42, 165, 201, 0.6);
  box-shadow: 0 0 0 3px rgba(42, 165, 201, 0.14);
}
.af-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; align-items: end; }
.af-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 13px !important;
  color: var(--text) !important;
  font-weight: 400 !important;
}
.af-check input { width: auto; }
.af-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 4px 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.af-group legend {
  padding: 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9fb0d8;
  font-weight: 600;
}
.af-actions { margin-top: 6px; }

/* ── Detail panels ───────────────────────────────────────────────────── */

.order-detail-grid { display: grid; grid-template-columns: 1.75fr 1fr; gap: 20px; align-items: start; }
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  min-width: 0;
}
.admin-panel h2 {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9fb0d8;
  margin: 24px 0 11px;
  font-weight: 600;
}
.admin-panel h2:first-child { margin-top: 0; }
.admin-panel p,
.admin-panel address { margin: 6px 0; line-height: 1.55; font-style: normal; font-size: 13.5px; }
.admin-panel .admin-table-wrap { background: transparent; }

.admin-totals {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-hi);
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13.5px;
}
.admin-totals > div { display: flex; justify-content: space-between; }
.admin-totals span { color: var(--dim); }
.admin-totals .grand {
  font-size: 16px;
  padding-top: 9px;
  border-top: 1px solid var(--line-hi);
  margin-top: 4px;
}
.admin-totals .grand strong { font-family: Orbitron, sans-serif; }

.admin-status-form { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.admin-status-form select {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-hi);
  background: #121a2b;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.admin-notes { white-space: pre-wrap; line-height: 1.7; }

/* ── Scrollbars & focus ──────────────────────────────────────────────── */

.admin-shell *::-webkit-scrollbar { width: 10px; height: 10px; }
.admin-shell *::-webkit-scrollbar-track { background: transparent; }
.admin-shell *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.admin-shell *::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); background-clip: content-box; }

.admin-shell a:focus-visible,
.admin-shell button:focus-visible {
  outline: 2px solid rgba(42, 165, 201, 0.75);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .dash-split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .admin-nav { flex-direction: row; gap: 4px; }
  .admin-nav a { padding: 8px 11px; }
  .admin-nav a span { display: none; }
  .admin-nav a.on::before { display: none; }
  .admin-side-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .admin-side-link span { display: none; }
  .admin-me { border-top: none; margin-top: 0; padding: 8px; }
  .admin-me-email { max-width: 130px; }
  .admin-main { padding: 20px 16px 48px; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .admin-search input { width: 100%; }
  .admin-head { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-shell * { transition: none !important; }
}
