/* =========================================================================
   Infinity Ramper Shops — Merchant Dashboard
   Shared design system. Loaded by every dashboard page.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Fonts (Google Fonts)
   ------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Funnel+Display:wght@300;400;500;600;700&family=Inter:wght@300;400;500&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* -------------------------------------------------------------------------
   2. Token palette
   Dark default; `[data-theme="light"]` on <html> flips to light.
   ------------------------------------------------------------------------- */
:root,
[data-theme='dark'] {
  --bg:         #0e0e0e;
  --bg-warm:    #141414;
  --bg-dark:    #0a0a0a;
  --ink:        #f0ede6;
  --ink-mid:    #888888;
  --ink-light:  #666666;
  --ink-faint:  #444444;
  --border:     #1e1e1e;
  --accent:     #FFAC1C;
  --green:      #3a7a52;
  --danger:     #e24b4a;
}

[data-theme='light'] {
  --bg:         #f8f7f4;
  --bg-warm:    #f0ede6;
  --bg-dark:    #0a0a0a;
  --ink:        #0a0a0a;
  --ink-mid:    #555555;
  --ink-light:  #888888;
  --ink-faint:  #bbbbbb;
  --border:     #e8e5e0;
  --accent:     #FFAC1C;
  --green:      #3a7a52;
  --danger:     #c93a3a;
}

/* -------------------------------------------------------------------------
   3. Base reset & typography
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

button { font: inherit; color: inherit; }

code, .mono, .tab-mono {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

::selection { background: var(--accent); color: #0a0a0a; }

/* -------------------------------------------------------------------------
   4. Typographic patterns
   ------------------------------------------------------------------------- */
.display, h1, h2, h3 {
  font-family: 'Funnel Display', serif;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
}

h1.display {
  font-size: clamp(32px, 4vw, 40px);
  letter-spacing: -0.028em;
  line-height: 1.05;
}

h2.display {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h3.display {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-family: 'Funnel Display', serif;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.eyebrow::before {
  content: '';
  width: 16px;
  height: 1px;
  background: currentColor;
  display: inline-block;
}

/* A version without the leading rule — for in-card contexts */
.eyebrow.plain::before { display: none; }

.brand {
  font-family: 'Funnel Display', serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}

.brand em {
  font-style: italic;
  font-weight: 300;
  color: var(--ink-mid);
  letter-spacing: -0.03em;
}

/* Hero wordmark — larger variant for the landing page */
.brand-hero {
  font-family: 'Funnel Display', serif;
  font-weight: 600;
  font-size: 42px;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 16px;
  line-height: 1;
}
.brand-hero em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
  letter-spacing: -0.03em;
}

/* -------------------------------------------------------------------------
   5. Layout shell: sidebar + topbar + main
   ------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  grid-template-areas:
    'sidebar topbar'
    'sidebar main';
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--bg-warm);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.sidebar .brand-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink-mid);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Funnel Display', serif;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}

.nav-item:hover {
  color: var(--accent);
  background: transparent;
}

.nav-item.active {
  color: var(--ink);
  background: var(--bg);
}

.nav-item .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  margin-right: -4px;
}

.nav-item.active .dot {
  background: var(--accent);
}

.sidebar .footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--ink-light);
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}

.topbar {
  grid-area: topbar;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar .crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-mid);
  font-family: 'Funnel Display', serif;
}

.topbar .crumbs .sep { color: var(--ink-faint); }
.topbar .crumbs .current { color: var(--ink); }

.topbar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main {
  grid-area: main;
  padding: 48px 40px 80px;
  max-width: 1400px;
  overflow-x: auto;
}

/* -------------------------------------------------------------------------
   6. Buttons
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 100px;
  font-family: 'Funnel Display', serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Primary (black/ink pill → amber on hover) */
.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  color: #0a0a0a;
}

/* Accent (solid amber — used sparingly, e.g. CTA at bottom of page) */
.btn-accent {
  background: var(--accent);
  color: #0a0a0a;
}
.btn-accent:hover:not(:disabled) { background: #ffbc44; }

/* Secondary (bordered pill) */
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

/* Ghost (subtle text-only) */
.btn-ghost {
  background: transparent;
  color: var(--ink-light);
  padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) { color: var(--accent); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* -------------------------------------------------------------------------
   7. Cards & the 1px-gap hairline grid trick
   ------------------------------------------------------------------------- */
.card {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-body { position: relative; }

/* The hairline grid: `grid-hairline` is given `background: var(--border)` and
 * `gap: 1px`, then each child paints its own background, creating the
 * 1px-line separators without any border declarations.                     */
.grid-hairline {
  display: grid;
  background: var(--border);
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.grid-hairline > * { background: var(--bg-warm); padding: 20px 24px; }

/* -------------------------------------------------------------------------
   8. Forms
   ------------------------------------------------------------------------- */
label {
  display: block;
  font-family: 'Funnel Display', serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='url'],
input[type='search'],
input[type='date'],
select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { min-height: 80px; resize: vertical; font-family: 'Inter', sans-serif; }

input::placeholder, textarea::placeholder { color: var(--ink-faint); }

/* Field row */
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* -------------------------------------------------------------------------
   9. Tables (dashboard data)
   ------------------------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead th {
  text-align: left;
  padding: 10px 14px;
  font-family: 'Funnel Display', serif;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--border);
  background: var(--bg-warm);
}

.table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr { transition: background 80ms ease; cursor: pointer; }
.table tbody tr:hover { background: var(--bg-warm); }
.table tbody tr:hover .mono { color: var(--accent); }

.table tbody tr:last-child td { border-bottom: none; }

/* Wrapper with the hairline technique for rounded corners */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.table-wrap .table thead th:first-child { padding-left: 24px; }
.table-wrap .table thead th:last-child { padding-right: 24px; }
.table-wrap .table tbody td:first-child { padding-left: 24px; }
.table-wrap .table tbody td:last-child { padding-right: 24px; }

.num {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* -------------------------------------------------------------------------
   10. Badges (status pills)
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: 'Funnel Display', serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--ink-mid);
  background: transparent;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-awaiting  { color: var(--ink-faint); }
.badge-paid      { color: var(--accent); }
.badge-processing{ color: var(--accent); }
.badge-shipped   { color: var(--green); }
.badge-delivered { color: var(--green); }
.badge-cancelled { color: var(--danger); }
.badge-refunded  { color: var(--danger); }

/* Pulsing live dot (e.g. "LIVE" indicator) */
.badge-live::before { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* -------------------------------------------------------------------------
   11. Banners & toasts
   ------------------------------------------------------------------------- */
.banner {
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner-error { border-color: var(--danger); color: var(--danger); }
.banner-ok    { border-color: var(--green); color: var(--green); }

/* Inline field validation — sits under the input, cleared on next keystroke */
.field-error {
  border-color: var(--danger) !important;
}
.field-error:focus {
  border-color: var(--danger) !important;
}
.field-error-msg {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  font-family: 'Inter', sans-serif;
}

#toast-root {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 16px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  min-width: 240px;
  animation: slide-in 200ms ease;
}

.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--danger); color: var(--danger); }

@keyframes slide-in {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* -------------------------------------------------------------------------
   12. Page header patterns
   ------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-head .meta { color: var(--ink-mid); font-size: 13px; margin-top: 6px; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }

/* -------------------------------------------------------------------------
   13. Metric tiles (Dashboard overview)
   ------------------------------------------------------------------------- */
.metric {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.metric .label { font-family: 'Funnel Display', serif; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.metric .value {
  font-family: 'Funnel Display', serif;
  font-weight: 400;
  font-size: 36px;
  letter-spacing: -0.028em;
  color: var(--ink);
  line-height: 1;
}
.metric .value .ccy { font-size: 18px; color: var(--ink-light); margin-right: 4px; letter-spacing: 0.02em; }
.metric .delta { font-size: 12px; color: var(--ink-mid); }
.metric .delta.up { color: var(--green); }
.metric .delta.down { color: var(--danger); }

/* -------------------------------------------------------------------------
   14. Drawer (slide-in side panel for order detail)
   ------------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 90;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(640px, 100vw);
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 240ms ease;
  z-index: 100;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.drawer-body { padding: 28px 32px; display: flex; flex-direction: column; gap: 28px; }

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 24px;
  font-size: 13px;
}
.kv dt { color: var(--ink-faint); font-family: 'Funnel Display', serif; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 1px; }
.kv dd { margin: 0; color: var(--ink); }

/* -------------------------------------------------------------------------
   15. Utility
   ------------------------------------------------------------------------- */
.hidden { display: none !important; }
.muted { color: var(--ink-mid); }
.faint { color: var(--ink-faint); }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.grow { flex-grow: 1; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { word-break: break-all; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Loading spinner (minimal) */
.spinner {
  width: 14px; height: 14px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty {
  padding: 48px 32px;
  text-align: center;
  color: var(--ink-light);
  font-size: 13px;
}
.empty .display {
  font-family: 'Funnel Display', serif;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  font-weight: 400;
}
.empty em { font-style: italic; font-weight: 300; color: var(--ink-mid); }

/* Horizontal toolbar (filters, search) */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input,
.toolbar select {
  padding: 7px 10px;
  font-size: 12px;
  width: auto;
  min-width: 160px;
}

/* Chart container (simple SVG line chart) */
.chart { width: 100%; height: 180px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .area { fill: var(--accent); fill-opacity: 0.12; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.chart .dot  { fill: var(--bg); stroke: var(--accent); stroke-width: 1.5; }
.chart .axis-label { fill: var(--ink-faint); font-family: 'IBM Plex Mono', monospace; font-size: 10px; }

/* Responsive: collapse sidebar on narrow screens */
@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60px 1fr;
    grid-template-areas: 'sidebar' 'topbar' 'main';
  }
  .sidebar { flex-direction: row; padding: 16px 20px; gap: 24px; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .sidebar .footer, .sidebar .brand-wrap { display: none; }
  .nav-item { font-size: 12px; padding: 8px 10px; }
  .main { padding: 24px 20px 60px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 16px; }
}

/* --- Admin dashboard header brand — amber IR circle + Funnel Display wordmark --- */
.dash-head .admin-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a0a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Funnel Display', sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.dash-head .admin-wordmark {
  font-family: 'Funnel Display', sans-serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
