/* =========================================================
   ADAPTER DESIGN SYSTEM — Design Tokens & Base Components
   Inspired by Intercom & Claude. Clean, rounded, artisanal.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Colors — Neutral */
  --bg: #FFFFFF;
  --bg-muted: #FAFAFA;
  --bg-subtle: #F4F4F5;
  --bg-strong: #E4E4E7;
  --border: #EAEAEA;
  --border-strong: #D4D4D8;
  --text: #0A0A0A;
  --text-muted: #52525B;
  --text-subtle: #A1A1AA;

  /* Colors — Semantic (default = Midnight) */
  --primary: #0A0A0A;
  --primary-hover: #262626;
  --primary-contrast: #FFFFFF;
  --accent: #2563EB;
  --accent-soft: #EFF4FF;
  --success: #10B981;
  --success-soft: #ECFDF5;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --danger: #EF4444;
  --danger-soft: #FEF2F2;

  /* Radii */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(10,10,10,0.04);
  --shadow-sm: 0 1px 3px rgba(10,10,10,0.06), 0 1px 2px rgba(10,10,10,0.04);
  --shadow-md: 0 4px 12px rgba(10,10,10,0.06), 0 2px 4px rgba(10,10,10,0.04);
  --shadow-lg: 0 12px 32px rgba(10,10,10,0.08), 0 4px 8px rgba(10,10,10,0.04);

  /* Tinta del primario: color para texto/íconos teñidos de marca sobre fondo claro.
     Por defecto es el mismo --primary; los temas con primario claro (retailbase)
     lo oscurecen para cumplir contraste 4.5:1. */
  --primary-ink: var(--primary);

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 180ms;
}

/* =========================================================
   THEME VARIANTS — opcional por producto
   Se activan con data-theme="<nombre>" en <html>.
   Midnight es el default y no necesita atributo.
   ========================================================= */
:root[data-theme="midnight"] {
  --primary: #0A0A0A;
  --primary-hover: #262626;
  --primary-contrast: #FFFFFF;
  --accent: #2563EB;
  --accent-soft: #EFF4FF;
}
:root[data-theme="graphite"] {
  --primary: #1F2937;
  --primary-hover: #111827;
  --primary-contrast: #FFFFFF;
  --accent: #334155;
  --accent-soft: #F1F5F9;
}
:root[data-theme="indigo"] {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-contrast: #FFFFFF;
  --accent: #4F46E5;
  --accent-soft: #EEF2FF;
}
:root[data-theme="ocean"] {
  --primary: #0F766E;
  --primary-hover: #115E59;
  --primary-contrast: #FFFFFF;
  --accent: #0F766E;
  --accent-soft: #F0FDFA;
}
:root[data-theme="forest"] {
  --primary: #15803D;
  --primary-hover: #166534;
  --primary-contrast: #FFFFFF;
  --accent: #15803D;
  --accent-soft: #F0FDF4;
}
:root[data-theme="plum"] {
  --primary: #6D28D9;
  --primary-hover: #5B21B6;
  --primary-contrast: #FFFFFF;
  --accent: #6D28D9;
  --accent-soft: #F5F3FF;
}
:root[data-theme="sunset"] {
  --primary: #C2410C;
  --primary-hover: #9A3412;
  --primary-contrast: #FFFFFF;
  --accent: #C2410C;
  --accent-soft: #FFF7ED;
}
/* Retailbase: verde de marca heredado (#24D764). Como es un primario claro,
   el texto sobre él es verde-negro (no blanco) y la tinta de texto/links usa
   un verde oscuro que cumple 4.5:1 sobre blanco. */
:root[data-theme="retailbase"] {
  --primary: #24D764;
  --primary-hover: #1EBE56;
  --primary-contrast: #08351A;
  --primary-ink: #15803D;
  --accent: #15803D;
  --accent-soft: #F0FDF4;
}

/* ------ Reset ------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-muted);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ------ Typography utilities ------ */
.t-display { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.t-h1      { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; }
.t-h2      { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.t-h3      { font-size: 16px; font-weight: 600; }
.t-body    { font-size: 14px; font-weight: 400; }
.t-small   { font-size: 13px; font-weight: 400; }
.t-micro   { font-size: 12px; font-weight: 500; letter-spacing: 0.01em; }
.t-mono    { font-family: ui-monospace, 'SF Mono', 'Menlo', monospace; }
.muted     { color: var(--text-muted); }
.subtle    { color: var(--text-subtle); }

/* ------ Buttons ------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
  cursor: pointer;
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; stroke-width: 1.75; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-subtle); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ------ Input ------ */
.input, .textarea, .select {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }

/* ------ Card ------ */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }

/* ------ Badges ------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.badge-success { background: var(--success-soft); color: #065F46; border-color: #A7F3D0; }
.badge-success .dot { background: var(--success); }
.badge-warning { background: var(--warning-soft); color: #92400E; border-color: #FCD34D; }
.badge-warning .dot { background: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: #991B1B; border-color: #FECACA; }
.badge-danger  .dot { background: var(--danger); }
.badge-accent  { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, var(--bg)); }
.badge-accent  .dot { background: var(--accent); }

/* ------ Table ------ */
.table {
  width: 100%;
  font-size: 14px;
}
.table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--bg-muted); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ------ Avatar ------ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* ------ Sidebar ------ */
.sidebar {
  width: 248px;
  height: 100vh;
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 16px 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px 10px;
  font-weight: 600;
  font-size: 15px;
}
.sidebar-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.sidebar-section {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-strong);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* ------ Topbar ------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ------ App layout ------ */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 28px; flex: 1; overflow: auto; }

/* ------ Focus ring for a11y ------ */
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

/* ------ Scrollbar polish ------ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-strong); border-radius: 10px; border: 2px solid var(--bg-muted); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ------ KPI card ------ */
.kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.kpi-trend { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.trend-up { color: #047857; }
.trend-down { color: #B91C1C; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
