/* =========================================================================
   Marketplace platform stylesheet — hand-authored.
   No Tailwind / Bootstrap / Sass build. CSS custom properties + logical
   properties so a single sheet serves LTR and RTL.

   Layers:
   1. Tokens          (colors, type, spacing, radii, shadows, motion)
   2. Reset           (base elements)
   3. Layout          (panel shell, grid, container)
   4. Components      (buttons, inputs, cards, tables↔cards, modals, toasts, …)
   5. Utilities       (a small set; no proliferation)
   6. RTL adjustments (only direction-flipping icons; layout uses logical props)
   ========================================================================= */

/* 1. Tokens ============================================================== */
:root {
  /* Brand: a confident teal-leaning blue. Distinct from default Bootstrap blue. */
  --brand-50:  #eef4fb;
  --brand-100: #d8e6f5;
  --brand-500: #2a6fb5;
  --brand-600: #1f5a99;
  --brand-700: #1b4d83;

  /* Accent: amber-orange for primary CTAs (calls out without screaming). */
  --accent-500: #e08a2b;
  --accent-600: #c4751c;

  /* Neutral ramp (warm slate). */
  --n-0:   #ffffff;
  --n-50:  #f7f8fa;
  --n-100: #eef0f3;
  --n-200: #dde1e7;
  --n-300: #c0c6cf;
  --n-400: #8a93a0;
  --n-500: #5e6772;
  --n-700: #353c47;
  --n-900: #161a21;

  /* Semantic */
  --success-500: #1f8a4d;
  --success-50:  #e6f4ec;
  --warning-500: #b97607;
  --warning-50:  #fbf2e0;
  --danger-500:  #b1372c;
  --danger-50:   #fbe9e6;
  --info-500:    #2e6ea3;
  --info-50:     #e7f0f8;

  /* Type */
  --font-display: "InterDisplay", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;

  --t-12: 0.75rem;
  --t-14: 0.875rem;
  --t-16: 1rem;
  --t-20: 1.25rem;
  --t-24: 1.5rem;
  --t-32: 2rem;
  --t-40: 2.5rem;

  --lh-tight: 1.2;
  --lh-body: 1.55;

  /* 8px spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Radii */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-pill: 999px;

  /* Shadow (two restrained elevations) */
  --shadow-1: 0 1px 2px rgba(20, 25, 35, 0.05), 0 1px 3px rgba(20, 25, 35, 0.04);
  --shadow-2: 0 4px 12px rgba(20, 25, 35, 0.08), 0 2px 4px rgba(20, 25, 35, 0.04);

  /* Motion */
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --ease:     cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Surfaces (semantic — switched by dark mode) */
  --bg:        var(--n-50);
  --surface:   var(--n-0);
  --surface-2: var(--n-100);
  --text:      var(--n-900);
  --text-dim:  var(--n-500);
  --line:      var(--n-200);
  --line-strong: var(--n-300);
  --focus-ring: 0 0 0 3px rgba(42, 111, 181, 0.35);

  --maxw-prose: 64ch;
  --maxw-shell: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1218;
    --surface:   #161a22;
    --surface-2: #1d222c;
    --text:      #eef1f5;
    --text-dim:  #98a0ad;
    --line:      #262c38;
    --line-strong: #323a48;
    --shadow-1: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-2: 0 6px 18px rgba(0,0,0,0.45);
  }
}

/* 2. Reset ============================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--t-16);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
input, select, textarea, button { font: inherit; }
a { color: var(--brand-600); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-700); }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  margin: 0 0 var(--s-3);
  font-weight: 600;
  letter-spacing: -0.005em;
}
h1 { font-size: var(--t-32); }
h2 { font-size: var(--t-24); }
h3 { font-size: var(--t-20); }
p { margin: 0 0 var(--s-3); }
hr { border: 0; border-block-start: 1px solid var(--line); margin-block: var(--s-5); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* 3. Layout ============================================================ */
.container {
  width: 100%;
  max-inline-size: var(--maxw-shell);
  margin-inline: auto;
  padding-inline: var(--s-4);
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.header {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(150%) blur(8px);
  border-block-end: 1px solid var(--line);
}
.header__inner {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding-block: var(--s-3);
}
.header__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--t-20);
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header__brand-dot {
  display: inline-block;
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  background: var(--accent-500);
  margin-inline-end: var(--s-2);
  vertical-align: middle;
}
.header__nav {
  display: flex;
  gap: var(--s-4);
  margin-inline-start: auto;
  align-items: center;
}
.header__nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--t-14);
}
.header__nav a:hover { color: var(--text); }

.footer {
  border-block-start: 1px solid var(--line);
  padding-block: var(--s-5);
  color: var(--text-dim);
  font-size: var(--t-14);
  background: var(--surface);
}

.main { padding-block: var(--s-6); }

/* Panel layout (admin / sellers / promoters) */
.panel {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.panel__sidebar {
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  padding: var(--s-4);
}
.panel__body { padding: var(--s-5); background: var(--bg); }
.panel__nav { display: flex; flex-direction: column; gap: 2px; margin-block-start: var(--s-4); }
.panel__nav a {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2);
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--t-14);
}
.panel__nav a:hover { background: var(--surface-2); color: var(--text); }
.panel__nav a.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .panel__nav a.is-active { background: rgba(42, 111, 181, 0.18); color: #aac8eb; }
}
@media (max-width: 900px) {
  .panel { grid-template-columns: 1fr; }
  .panel__sidebar { border-inline-end: 0; border-block-end: 1px solid var(--line); }
}

/* Page header pattern (title row + action) */
.page-header {
  display: flex;
  align-items: end;
  gap: var(--s-4);
  margin-block-end: var(--s-5);
  flex-wrap: wrap;
}
.page-header__titles { flex: 1 1 auto; min-inline-size: 0; }
.page-header h1 { margin-block-end: var(--s-1); }
.page-header__eyebrow {
  font-size: var(--t-12);
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* 4. Components ========================================================= */

/* Buttons */
.btn {
  --bg: var(--surface);
  --fg: var(--text);
  --bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  block-size: 40px;
  border-radius: var(--r-2);
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--bd);
  font-weight: 500;
  font-size: var(--t-14);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  --bg: var(--accent-500);
  --fg: #ffffff;
  --bd: var(--accent-500);
}
.btn--primary:hover { --bg: var(--accent-600); --bd: var(--accent-600); }

.btn--secondary {
  --bg: var(--brand-500);
  --fg: #ffffff;
  --bd: var(--brand-500);
}
.btn--secondary:hover { --bg: var(--brand-600); --bd: var(--brand-600); }

.btn--ghost {
  --bg: transparent;
  --bd: transparent;
  --fg: var(--text);
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  --bg: var(--danger-500);
  --fg: #ffffff;
  --bd: var(--danger-500);
}

.btn--sm { block-size: 32px; padding-inline: var(--s-3); font-size: var(--t-12); }
.btn--lg { block-size: 48px; padding-inline: var(--s-5); font-size: var(--t-16); }
.btn--block { display: flex; inline-size: 100%; }

/* Inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-block-end: var(--s-4);
}
.field__label {
  font-size: var(--t-14);
  font-weight: 500;
  color: var(--text);
}
.field__hint { font-size: var(--t-12); color: var(--text-dim); }
.field__error { font-size: var(--t-12); color: var(--danger-500); }

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  padding: 0 var(--s-3);
  block-size: 40px;
  color: var(--text);
  inline-size: 100%;
  transition: border-color var(--dur-fast) var(--ease);
}
.textarea { block-size: auto; padding: var(--s-3); resize: vertical; min-block-size: 100px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--n-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus-ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }

.field--inline { flex-direction: row; align-items: center; gap: var(--s-3); }
.field--inline .field__label { margin-block-end: 0; }

.checkbox, .radio {
  inline-size: 18px; block-size: 18px;
  accent-color: var(--brand-500);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}
.card--flush { padding: 0; overflow: hidden; }
.card__header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-block-end: 1px solid var(--line);
}
.card__title { font-size: var(--t-16); font-weight: 600; margin: 0; }
.card__body { padding: var(--s-5); }
.card__footer {
  padding: var(--s-4) var(--s-5);
  border-block-start: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
}

/* Grid stack helpers */
.stack > * + * { margin-block-start: var(--s-4); }
.stack-sm > * + * { margin-block-start: var(--s-2); }
.row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }

/* Badges / status pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  font-size: var(--t-12);
  font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.badge--success { background: var(--success-50); color: var(--success-500); border-color: transparent; }
.badge--warning { background: var(--warning-50); color: var(--warning-500); border-color: transparent; }
.badge--danger  { background: var(--danger-50);  color: var(--danger-500);  border-color: transparent; }
.badge--info    { background: var(--info-50);    color: var(--info-500);    border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge--success { background: rgba(31, 138, 77, 0.18); }
  .badge--warning { background: rgba(185, 118, 7, 0.18); }
  .badge--danger  { background: rgba(177, 55, 44, 0.18); }
  .badge--info    { background: rgba(46, 110, 163, 0.18); }
}

/* Tabs */
.tabs { display: flex; gap: var(--s-4); border-block-end: 1px solid var(--line); margin-block-end: var(--s-4); }
.tabs__tab {
  padding: var(--s-2) 0;
  color: var(--text-dim);
  text-decoration: none;
  border-block-end: 2px solid transparent;
  font-weight: 500;
}
.tabs__tab:hover { color: var(--text); }
.tabs__tab.is-active { color: var(--text); border-color: var(--accent-500); }

/* Toasts (Alpine drives the open state) */
.toast-area {
  position: fixed;
  inset-block-end: var(--s-5);
  inset-inline-end: var(--s-5);
  display: grid;
  gap: var(--s-3);
  z-index: 100;
  max-inline-size: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--shadow-2);
  font-size: var(--t-14);
}
.toast--success { border-inline-start: 4px solid var(--success-500); }
.toast--danger  { border-inline-start: 4px solid var(--danger-500); }

/* Modal */
.modal__backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid; place-items: center;
  z-index: 50;
  padding: var(--s-4);
}
.modal__panel {
  background: var(--surface);
  border-radius: var(--r-3);
  inline-size: 100%;
  max-inline-size: 520px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.modal__head { padding: var(--s-4) var(--s-5); border-block-end: 1px solid var(--line); display: flex; align-items: center; }
.modal__title { font-size: var(--t-16); font-weight: 600; }
.modal__body { padding: var(--s-5); }
.modal__foot { padding: var(--s-4) var(--s-5); border-block-start: 1px solid var(--line); background: var(--surface-2); display: flex; gap: var(--s-3); justify-content: flex-end; }

/* Empty state */
.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--text-dim);
}
.empty__title { color: var(--text); margin-block-end: var(--s-2); }

/* Pagination */
.pagination { display: flex; gap: var(--s-1); }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  block-size: 32px; min-inline-size: 32px; padding-inline: var(--s-2);
  border-radius: var(--r-2);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: var(--t-14);
}
.pagination .is-current { background: var(--brand-500); color: white; border-color: var(--brand-500); }

/* Money display */
.money { font-variant-numeric: tabular-nums; }

/* ----- The responsive table → cards component (§13.4) -------------------
   Mandatory: every panel list uses this. Desktop renders a real <table>;
   below 768px each row collapses to a label/value card. The collapse is
   CSS-driven via [data-label] attributes — no JS required.
   --------------------------------------------------------------------- */
.rtable-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; box-shadow: var(--shadow-1); }
.rtable { width: 100%; border-collapse: collapse; font-size: var(--t-14); }
.rtable thead th {
  text-align: start;
  font-weight: 500;
  color: var(--text-dim);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-block-end: 1px solid var(--line);
  white-space: nowrap;
  font-size: var(--t-12);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.rtable tbody td {
  padding: var(--s-3) var(--s-4);
  border-block-end: 1px solid var(--line);
  vertical-align: middle;
}
.rtable tbody tr:last-child td { border-block-end: 0; }
.rtable tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.rtable__row-title { font-weight: 500; color: var(--text); }
.rtable__actions { display: flex; gap: var(--s-2); justify-content: flex-end; }

@media (max-width: 768px) {
  .rtable, .rtable thead, .rtable tbody, .rtable tr, .rtable td, .rtable th { display: block; }
  .rtable thead { position: absolute; inset-inline-start: -9999px; }
  .rtable tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    padding: var(--s-4);
    margin-block-end: var(--s-3);
    box-shadow: var(--shadow-1);
  }
  .rtable tbody td {
    border: 0;
    padding: var(--s-1) 0;
    display: flex;
    align-items: baseline;
    gap: var(--s-3);
  }
  .rtable tbody td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--text-dim);
    font-size: var(--t-12);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .rtable tbody td.rtable__title-cell {
    padding-block: 0 var(--s-2);
    border-block-end: 1px solid var(--line);
    margin-block-end: var(--s-2);
    flex-direction: column;
    gap: 0;
  }
  .rtable tbody td.rtable__title-cell::before { display: none; }
  .rtable__actions { justify-content: flex-start; padding-block-start: var(--s-2); }
  .rtable-wrap { background: transparent; border: 0; box-shadow: none; padding: 0; }
}

/* Auth / centered card pages */
.auth-shell {
  display: grid;
  place-items: center;
  min-block-size: 100vh;
  padding: var(--s-5);
  background: var(--bg);
}
.auth-card { inline-size: 100%; max-inline-size: 420px; }

/* Storefront-specific (calmer surface, generous spacing) */
.store-shell { background: var(--surface); }
.store-hero { padding-block: var(--s-7); }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-5);
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  overflow: hidden;
  transition: box-shadow var(--dur-base) var(--ease);
}
.product-card:hover { box-shadow: var(--shadow-2); }
.product-card__media {
  aspect-ratio: 1 / 1;
  background: var(--n-100);
  display: grid; place-items: center;
  color: var(--text-dim);
}
.product-card__body { padding: var(--s-3) var(--s-4) var(--s-4); }
.product-card__title { font-weight: 500; margin-block-end: var(--s-1); }
.product-card__price { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.product-card__price-old { color: var(--text-dim); text-decoration: line-through; margin-inline-end: var(--s-2); font-weight: 400; }

/* 5. Utilities (small set) ============================================== */
.u-text-dim { color: var(--text-dim); }
.u-text-sm  { font-size: var(--t-14); }
.u-text-xs  { font-size: var(--t-12); }
.u-bold     { font-weight: 600; }
.u-right    { text-align: end; }
.u-center   { text-align: center; }
.u-mt-0     { margin-block-start: 0 !important; }
.u-mb-0     { margin-block-end: 0 !important; }
.u-flex     { display: flex; gap: var(--s-3); align-items: center; }
.u-flex-col { display: flex; flex-direction: column; gap: var(--s-3); }
.u-grow     { flex: 1 1 auto; }
.u-nowrap   { white-space: nowrap; }
.visually-hidden {
  position: absolute !important;
  inline-size: 1px !important; block-size: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}

/* 6. RTL adjustments =====================================================
   Layout uses logical properties so it mirrors automatically.
   Only icons that imply direction flip here. */
[dir="rtl"] .icon--chevron-end { transform: scaleX(-1); }
[dir="rtl"] .icon--arrow-end   { transform: scaleX(-1); }
