/* ============================================================
   Ruta — design tokens (ruta.xterraengine.com)
   Producto: pedidos, ruta de venta y fiado (Guatemala)
   Identidad: "herramienta de trabajo al sol": blanco puro, tinta
   casi negra, un solo azul de acción, estados por color + texto +
   forma. Vendedor con una mano en Android de gama baja: targets
   ≥ 48 px, texto base 18 px, sin sombras ni decoración.
   SOLO tema claro (legibilidad bajo sol directo); el panel del
   distribuidor usa los mismos tokens con la escala de escritorio.
   Sin fuentes ni recursos externos (CSP). Propietario: ARCHITECT.
   Documentación: docs/DISENO-RUTA.md
   ============================================================ */

:root {
  color-scheme: light only;

  /* ---------- Color: fondo y superficies ---------- */
  --bg:            #ffffff;
  --bg-elev:       #f2f4f7;   /* barras, cabeceras */
  --surface:       #ffffff;
  --surface-2:     #f2f4f7;   /* filas alternas, inputs */
  --surface-3:     #e3e7ee;   /* pulsado, chips */
  --overlay:       rgba(17, 24, 39, 0.55);

  /* ---------- Color: bordes (más gruesos que en otros productos) ---------- */
  --border:        #c9d0da;
  --border-strong: #5f6b7a;
  --border-w:      2px;

  /* ---------- Color: texto ---------- */
  --text:          #111827;   /* 16:1 sobre blanco */
  --text-muted:    #3f4b5b;   /* 9:1 */
  --text-faint:    #6b7686;   /* 4.9:1 — solo una palabra */
  --text-inverse:  #ffffff;

  /* ---------- Color: acción (azul ruta) ---------- */
  --accent:        #0b4fd6;   /* 7:1 sobre blanco */
  --accent-strong: #0b4fd6;
  --accent-hover:  #0740b0;
  --accent-soft:   rgba(11, 79, 214, 0.10);
  --accent-ink:    #ffffff;

  /* ---------- Color: estado de visita / pedido / conexión ---------- */
  --success:       #0f7a3d;   /* visitada con pedido, sincronizado, en línea */
  --success-soft:  rgba(15, 122, 61, 0.12);
  --warning:       #9a4d00;   /* sin venta, pendiente de enviar */
  --warning-soft:  rgba(154, 77, 0, 0.12);
  --danger:        #b3261e;   /* error de envío, fiado vencido */
  --danger-soft:   rgba(179, 38, 30, 0.12);
  --neutral:       #5f6b7a;   /* pendiente de visitar */
  --neutral-soft:  rgba(95, 107, 122, 0.12);

  /* Barra de conexión (fondo pleno, no suave: tiene que verse al sol) */
  --online-bg:     #0f7a3d;   --online-ink: #ffffff;
  --offline-bg:    #9a4d00;   --offline-ink: #ffffff;
  --syncing-bg:    #0b4fd6;   --syncing-ink: #ffffff;
  --error-bg:      #b3261e;   --error-ink: #ffffff;

  /* ---------- Escala categórica para gráficas del panel (6) ---------- */
  --chart-1: #0b4fd6; --chart-2: #0f7a3d; --chart-3: #c2410c; --chart-4: #6d28d9; --chart-5: #a16207; --chart-6: #5f6b7a;
  --chart-grid: rgba(17, 24, 39, 0.12); --chart-axis: var(--text-muted); --chart-empty: var(--surface-2);

  /* ---------- Tipografía (base 18 en el vendedor, 16 en el panel) ---------- */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-2xs: 0.75rem;   /* 12  mínimo absoluto en el vendedor */
  --fs-xs:  0.875rem;  /* 14 */
  --fs-sm:  1rem;      /* 16 */
  --fs-md:  1.125rem;  /* 18  cuerpo del vendedor */
  --fs-lg:  1.25rem;   /* 20 */
  --fs-xl:  1.5rem;    /* 24  nombre de tienda, título */
  --fs-2xl: 2rem;      /* 32  total del pedido */
  --fs-3xl: 2.75rem;   /* 44  cantidad en el stepper */

  --lh-tight: 1.15; --lh-snug: 1.3; --lh-normal: 1.45;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --ls-tight: -0.01em; --ls-wide: 0.04em;

  /* ---------- Espaciado (4px) ---------- */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem; --sp-5: 1.25rem;
  --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem; --sp-12: 3rem; --sp-16: 4rem;

  /* ---------- Layout y targets ---------- */
  --container:        72rem;
  --container-narrow: 30rem;
  --sidebar-w:        15rem;
  --tap:              3rem;     /* 48 px: mínimo tocable */
  --control-h:        3.5rem;   /* 56 px: botones y campos del vendedor */
  --control-h-sm:     3rem;     /* 48 */
  --stepper-h:        4rem;     /* 64: + / − de cantidades */
  --bottom-bar-h:     4.5rem;   /* barra fija de acción */
  --status-bar-h:     2.25rem;  /* barra de conexión */

  /* ---------- Radios (pequeños: forma clara) ---------- */
  --radius-xs: 2px; --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 999px;

  /* ---------- Sombras: ninguna en el vendedor; una para menús del panel ---------- */
  --shadow-sm: none;
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.16);
  --shadow-lg: 0 16px 40px rgba(17, 24, 39, 0.24);
  --ring: 0 0 0 3px rgba(11, 79, 214, 0.35);

  /* ---------- Movimiento: mínimo ---------- */
  --dur-fast: 80ms; --dur-base: 140ms; --dur-slow: 240ms;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --transition: background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease);

  --z-sticky: 10; --z-dropdown: 20; --z-bar: 30; --z-modal: 40; --z-toast: 50;
}

/* ============================================================ Base mínima */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 100%; line-height: var(--lh-normal); -webkit-text-size-adjust: 100%; font-synthesis: none; }
body { margin: 0; min-height: 100dvh; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.95em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }

/* ============================================================ Utilidades */
.label { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--control-h); min-width: var(--tap); padding: 0 var(--sp-5); border: var(--border-w) solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap; transition: var(--transition); -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; }
.btn:active { background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:active { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:active { background: var(--accent-soft); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--sp-4); font-size: var(--fs-sm); }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: var(--stepper-h); font-size: var(--fs-xl); }

.card { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); }

.input { display: block; width: 100%; min-height: var(--control-h); padding: 0 var(--sp-4); border: var(--border-w) solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text); font-size: var(--fs-md); }
textarea.input { min-height: 6rem; padding: var(--sp-3) var(--sp-4); resize: vertical; }
select.input { padding-right: var(--sp-8); }
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input:disabled, .input[readonly] { background: var(--surface-2); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-mono { font-family: var(--font-mono); }
.input-num { font-variant-numeric: tabular-nums; text-align: right; font-size: var(--fs-xl); }

.badge { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-3); min-height: 1.75rem; border: var(--border-w) solid currentColor; border-radius: var(--radius-full); background: var(--surface); color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; white-space: nowrap; }
.badge-accent  { color: var(--accent);  background: var(--accent-soft); }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger  { color: var(--danger);  background: var(--danger-soft); }
.badge-neutral { color: var(--neutral); background: var(--neutral-soft); }

/* Barra de estado de conexión y sincronización (siempre visible en el vendedor) */
.status-bar { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--status-bar-h); padding: 0 var(--sp-4); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--online-ink); background: var(--online-bg); }
.status-bar[data-state="offline"] { background: var(--offline-bg); color: var(--offline-ink); }
.status-bar[data-state="syncing"] { background: var(--syncing-bg); color: var(--syncing-ink); }
.status-bar[data-state="error"]   { background: var(--error-bg);   color: var(--error-ink); }

.table-wrap { overflow-x: auto; border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-muted); background: var(--bg-elev); position: sticky; top: 0; z-index: 1; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table tfoot td { font-weight: var(--fw-bold); background: var(--surface-2); border-top: var(--border-w) solid var(--border-strong); }
