/* ============================================================
   TOKENS · Sistema de Diseño Repuestos Simón Bolívar
   Versión 1.0.0
   ------------------------------------------------------------
   ÚNICA FUENTE DE VERDAD DE COLOR, TIPOGRAFÍA Y ESPACIADO.

   Reglas de uso:
   1. Este archivo NO se edita por proyecto. Se importa tal cual.
   2. Ningún hex literal en el CSS de los proyectos. Solo var().
   3. Si un proyecto necesita un valor que no existe aquí,
      se propone como cambio a este archivo, no como excepción local.
   ============================================================ */

:root {
  /* ---------- MARCA ----------
     Estos tres valores son la identidad. No se alteran nunca. */
  --brand-navy:        #213393;  /* menú, header, texto de botón */
  --brand-yellow:      #FBC200;  /* acción primaria, línea de separación */
  --brand-navy-hover:  #1A2875;  /* hover de superficies navy */
  --brand-yellow-hover:#E3AF00;  /* hover de superficies amarillas */

  /* Azul de apoyo: enlaces, focus, acentos informativos.
     NO es un segundo color de marca. Usar con moderación. */
  --blue-600:          #324FBE;
  --blue-50:           #EEF2FF;

  /* ---------- TEXTO ---------- */
  --ink:           #1B1F2A;  /* texto principal */
  --ink-soft:      #4B5163;  /* texto secundario, descripciones */
  --ink-muted:     #7A8194;  /* placeholders, metadatos, "—" */
  --ink-inverse:   #FFFFFF;  /* texto sobre navy */

  /* ---------- SUPERFICIES ---------- */
  --bg:            #F1F3F9;  /* fondo de página */
  --surface:       #FFFFFF;  /* tarjetas, tablas, modales */
  --surface-alt:   #FAFAFA;  /* filas alternas, encabezado de tabla */
  --surface-hover: #F5F7FC;  /* hover de fila */

  /* ---------- BORDES ---------- */
  --line:      #E2E5EE;  /* borde visible: inputs, tarjetas */
  --line-soft: #EDEFF6;  /* separador interno de tabla */

  /* ---------- ESTADOS SEMÁNTICOS ----------
     Se nombran por SIGNIFICADO, no por el estado de negocio de un
     proyecto. Un "ticket abierto" y una "diligencia creada" son ambos
     `state-new`. Así el mismo componente sirve en los dos sistemas. */
  --state-new:        #006CF0;  /* creado / abierto / sin asignar */
  --state-assigned:   #0D9488;  /* asignado / alistado */
  --state-progress:   #7C3AED;  /* en proceso */
  --state-waiting:    #F59E0B;  /* pendiente info / reprogramado */
  --state-done:       #16A34A;  /* finalizado / resuelto / cerrado */
  --state-error:      #DC2626;  /* cancelado / vencido / error */
  --state-neutral:    #64748B;  /* archivado / no aplica */

  /* Fondos suaves para los chips de estado (texto = color pleno) */
  --state-new-bg:      #E6F1FE;
  --state-assigned-bg: #E3F5F3;
  --state-progress-bg: #F1EAFE;
  --state-waiting-bg:  #FEF3E2;
  --state-done-bg:     #E6F5EA;
  --state-error-bg:    #FDEAEA;
  --state-neutral-bg:  #EEF0F4;

  /* Texto del chip. En claro coincide con el color pleno del estado;
     el tema oscuro lo reemplaza por tonos claros para conservar contraste.
     Los componentes leen SIEMPRE la variante -fg, nunca el color pleno. */
  --state-new-fg:      var(--state-new);
  --state-assigned-fg: var(--state-assigned);
  --state-progress-fg: var(--state-progress);
  --state-waiting-fg:  var(--state-waiting);
  --state-done-fg:     var(--state-done);
  --state-error-fg:    var(--state-error);
  --state-neutral-fg:  var(--state-neutral);

  /* ---------- ACCIONES ----------
     Tokenizados para que el botón no necesite reglas por tema.
     El primario es idéntico en claro y oscuro: es la marca. */
  --btn-2-bg:          var(--surface);
  --btn-2-fg:          var(--brand-navy);
  --btn-2-border:      var(--brand-navy);
  --btn-2-bg-hover:    var(--brand-navy);
  --btn-2-fg-hover:    var(--ink-inverse);
  --btn-ghost-fg:      var(--brand-navy);
  --btn-ghost-bg-hover:var(--blue-50);

  /* ---------- TIPOGRAFÍA ----------
     Manrope: títulos y cifras destacadas.
     Inter: todo el cuerpo, labels, botones, tablas.
     JetBrains Mono: consecutivos, códigos, IDs. */
  --font-display: 'Manrope', 'Segoe UI Semibold', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Cascadia Code', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Escala tipográfica · razón 1.2 desde 16px */
  --text-xs:   0.75rem;   /* 12px · chips, metadatos */
  --text-sm:   0.875rem;  /* 14px · tablas, labels */
  --text-base: 1rem;      /* 16px · cuerpo */
  --text-lg:   1.125rem;  /* 18px · subtítulo de sección */
  --text-xl:   1.375rem;  /* 22px · título de tarjeta */
  --text-2xl:  1.75rem;   /* 28px · título de página */
  --text-3xl:  2.25rem;   /* 36px · cifra de KPI */
  --text-4xl:  3rem;      /* 48px · título de login */

  --leading-tight:  1.2;   /* títulos */
  --leading-normal: 1.5;   /* cuerpo */
  --leading-loose:  1.65;  /* párrafos largos */

  /* ---------- ESPACIADO · base 4px ---------- */
  --space-1:  0.25rem;  /*  4px */
  --space-2:  0.5rem;   /*  8px */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.25rem;  /* 20px */
  --space-6:  1.5rem;   /* 24px */
  --space-8:  2rem;     /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* ---------- RADIOS ---------- */
  --radius-sm:   8px;    /* chips, inputs pequeños */
  --radius:      12px;   /* input, botón, tarjeta — valor por defecto */
  --radius-lg:   16px;   /* modal, tarjeta contenedora */
  --radius-pill: 999px;  /* chip de estado, avatar */

  /* ---------- ELEVACIÓN ----------
     Solo dos niveles. La jerarquía se construye con borde y fondo,
     no acumulando sombras. */
  --shadow-card:  0 1px 2px rgba(27, 31, 42, 0.05);
  --shadow-float: 0 8px 24px rgba(27, 31, 42, 0.12);

  /* ---------- LAYOUT ---------- */
  --sidebar-w:          264px;
  --sidebar-w-collapsed: 72px;
  --header-h:            64px;
  --brand-rule:          3px;   /* grosor de la línea amarilla de separación */
  --content-max:         1440px;

  /* ---------- MOVIMIENTO ---------- */
  --ease:          cubic-bezier(0.2, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration:      200ms;

  /* ---------- FOCUS ----------
     Obligatorio y visible en todo elemento interactivo. */
  --focus-ring: 0 0 0 3px rgba(50, 79, 190, 0.35);

  /* ---------- Z-INDEX ----------
     Escala fija. Prohibido inventar valores como 9999. */
  --z-base:     0;
  --z-sticky:   10;   /* encabezado de tabla fijo */
  --z-sidebar:  20;
  --z-header:   30;
  --z-dropdown: 40;
  --z-modal:    50;
  --z-toast:    60;
}

/* ============================================================
   TEMA OSCURO
   ------------------------------------------------------------
   Se activa con <html data-theme="dark">. Redefine SOLO
   superficies y texto: la marca (navy y amarillo) no cambia.
   Ningún componente necesita CSS adicional para funcionar en
   oscuro; si lo necesita, el componente está mal hecho.
   ============================================================ */

[data-theme="dark"] {
  --ink:           #E8EAF2;
  --ink-soft:      #A3AAC0;
  --ink-muted:     #6B7389;
  --ink-inverse:   #FFFFFF;

  --bg:            #12172B;
  --surface:       #1A2038;
  --surface-alt:   #1F2642;
  --surface-hover: #252C4A;

  --line:          #2C3454;
  --line-soft:     #232A46;

  /* Los chips de estado necesitan fondos translúcidos en oscuro
     para no perder contraste contra --surface. */
  --state-new-bg:      rgba(0, 108, 240, 0.18);
  --state-assigned-bg: rgba(13, 148, 136, 0.18);
  --state-progress-bg: rgba(124, 58, 237, 0.20);
  --state-waiting-bg:  rgba(245, 158, 11, 0.18);
  --state-done-bg:     rgba(22, 163, 74, 0.20);
  --state-error-bg:    rgba(220, 38, 38, 0.18);
  --state-neutral-bg:  rgba(100, 116, 139, 0.20);

  --state-new-fg:      #60A5FA;
  --state-assigned-fg: #2DD4BF;
  --state-progress-fg: #A78BFA;
  --state-waiting-fg:  #FBBF24;
  --state-done-fg:     #4ADE80;
  --state-error-fg:    #F87171;
  --state-neutral-fg:  #94A3B8;

  /* Sobre fondo oscuro el navy es invisible: el secundario pasa a amarillo. */
  --btn-2-bg:          transparent;
  --btn-2-fg:          var(--brand-yellow);
  --btn-2-border:      var(--brand-yellow);
  --btn-2-bg-hover:    var(--brand-yellow);
  --btn-2-fg-hover:    var(--brand-navy);
  --btn-ghost-fg:      var(--ink);
  --btn-ghost-bg-hover:var(--surface-hover);

  --shadow-card:  0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.45);

  --focus-ring: 0 0 0 3px rgba(251, 194, 0, 0.45);
}

/* ============================================================
   RESET Y BASE
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  margin: 0;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

/* Todo identificador, consecutivo o código va en mono.
   Patrón ya presente en Diligencias (DL-2026-000455) y Agenda (Z007). */
code, .codigo, .consecutivo {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Las columnas numéricas se alinean a la derecha con cifras de
   ancho fijo para que los dígitos formen columna. */
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Focus visible obligatorio. Nunca `outline: none` sin reemplazo. */
:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Respetar la preferencia de movimiento reducido del sistema. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
