/*
 * Design tokens — Facturador Techmo, estilo Apple (claro, oscuro o automático).
 * Capa 1: primitivos. Capa 2: semánticos (lo único que usan los componentes). Capa 3: componentes.
 * Ningún color en hexadecimal fuera de este archivo. Contrastes comprobados para WCAG 2.2 AA.
 */
:root {
    color-scheme: light dark;

    /* ---------- Primitivos ---------- */
    --apple-blue: #0071e3;          /* 4.6:1 sobre blanco; texto blanco sobre él 4.6:1 */
    --apple-blue-hover: #0077ed;
    --apple-blue-active: #006edb;
    --apple-blue-dark-text: #2997ff; /* enlaces en modo oscuro: 6:1 sobre #1c1c1e */
    --apple-blue-soft: #e8f2fd;

    --gray-0: #ffffff;
    --gray-50: #f5f5f7;
    --gray-100: #ececf0;
    --gray-150: #e8e8ed;
    --gray-300: #d2d2d7;
    --gray-500: #86868b;
    --gray-600: #6e6e73;   /* 5.0:1 sobre blanco, 4.7:1 sobre #f5f5f7 */
    --gray-900: #1d1d1f;

    --dark-0: #000000;
    --dark-50: #1c1c1e;
    --dark-100: #2c2c2e;
    --dark-150: #3a3a3c;
    --dark-500: #98989d;   /* 6.0:1 sobre #1c1c1e */
    --dark-900: #f5f5f7;

    --green-50: #e3f6e8;
    --green-700: #1b7a3a;
    --amber-50: #fff4d6;
    --amber-300: #f5c518;
    --amber-800: #7a5100;
    --red-50: #fdecec;
    --red-600: #d70015;
    --red-700: #b3000f;

    /* ---------- Semánticos (modo claro) ---------- */
    --color-bg: var(--gray-50);
    --color-surface: var(--gray-0);
    --color-surface-muted: var(--gray-50);
    --color-fill: var(--gray-150);            /* botones secundarios y controles rellenos */
    --color-input-bg: var(--gray-0);
    --color-glass: rgb(255 255 255 / 0.72);   /* menú y barra superior translúcidos */
    --color-text: var(--gray-900);
    --color-text-muted: var(--gray-600);
    --color-border: var(--gray-300);
    --color-border-subtle: rgb(0 0 0 / 0.07);
    --color-border-strong: var(--gray-500);

    --color-primary: var(--apple-blue);       /* enlaces y acentos */
    --color-primary-fill: var(--apple-blue);  /* fondo de botones primarios */
    --color-primary-hover: var(--apple-blue-hover);
    --color-primary-active: var(--apple-blue-active);
    --color-primary-soft: var(--apple-blue-soft);
    --color-on-primary: var(--gray-0);
    --color-focus: var(--apple-blue);
    --color-focus-ring: rgb(0 113 227 / 0.28);

    --color-neutral-bg: var(--gray-150);
    --color-neutral-text: var(--gray-600);
    --color-success-bg: var(--green-50);
    --color-success-text: var(--green-700);
    --color-warning-bg: var(--amber-50);
    --color-warning-border: var(--amber-300);
    --color-warning-text: var(--amber-800);
    --color-danger: var(--red-600);
    --color-danger-hover: var(--red-700);
    --color-danger-bg: var(--red-50);
    --color-danger-text: var(--red-700);
    --color-info-bg: var(--apple-blue-soft);
    --color-info-text: #0058b0;

    /* ---------- Tipografía ---------- */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-md: 1.125rem;
    --text-lg: 1.375rem;
    --text-xl: 2rem;
    --leading-tight: 1.2;
    --leading-normal: 1.47;
    --tracking-tight: -0.022em;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

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

    /* ---------- Forma y profundidad ---------- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 980px;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 18px rgb(0 0 0 / 0.04);
    --shadow-pop: 0 12px 40px rgb(0 0 0 / 0.14);
    --blur-glass: saturate(180%) blur(20px);

    /* ---------- Componentes ---------- */
    --sidebar-width: 15.5rem;
    --topbar-height: 3.75rem;
    --content-max: 76rem;
    --control-height: 2.5rem;
    --control-height-sm: 2rem;
    --env-banner-stripe: var(--amber-300);
    --color-overlay: rgb(0 0 0 / 0.32);
}

/* ---------- Modo oscuro ----------
 * Automático (según el equipo) salvo que la persona elija «Claro» u «Oscuro» en su menú: data-theme en <html>,
 * aplicado antes de pintar por js/theme-init.js. Las dos copias de variables deben mantenerse iguales. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: var(--dark-0);
        --color-surface: var(--dark-50);
        --color-surface-muted: var(--dark-100);
        --color-fill: var(--dark-150);
        --color-input-bg: var(--dark-100);
        --color-glass: rgb(28 28 30 / 0.72);
        --color-text: var(--dark-900);
        --color-text-muted: var(--dark-500);
        --color-border: #48484a;
        --color-border-subtle: rgb(255 255 255 / 0.08);
        --color-border-strong: #6e6e73;

        --color-primary: var(--apple-blue-dark-text);
        --color-primary-hover: #47a5ff;
        --color-primary-active: #6bb6ff;
        --color-primary-soft: rgb(41 151 255 / 0.16);
        --color-focus: var(--apple-blue-dark-text);
        --color-focus-ring: rgb(41 151 255 / 0.35);

        --color-neutral-bg: var(--dark-150);
        --color-neutral-text: #c7c7cc;
        --color-success-bg: rgb(48 209 88 / 0.16);
        --color-success-text: #30d158;
        --color-warning-bg: rgb(255 214 10 / 0.14);
        --color-warning-border: rgb(255 214 10 / 0.45);
        --color-warning-text: #ffd60a;
        --color-danger: #d70015;
        --color-danger-hover: #ff3b30;
        --color-danger-bg: rgb(255 69 58 / 0.16);
        --color-danger-text: #ff6961;
        --color-info-bg: rgb(41 151 255 / 0.16);
        --color-info-text: #64b5ff;

        --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.06);
        --shadow-pop: 0 12px 40px rgb(0 0 0 / 0.6);
        --env-banner-stripe: #ffd60a;
        --color-overlay: rgb(0 0 0 / 0.55);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: var(--dark-0);
    --color-surface: var(--dark-50);
    --color-surface-muted: var(--dark-100);
    --color-fill: var(--dark-150);
    --color-input-bg: var(--dark-100);
    --color-glass: rgb(28 28 30 / 0.72);
    --color-text: var(--dark-900);
    --color-text-muted: var(--dark-500);
    --color-border: #48484a;
    --color-border-subtle: rgb(255 255 255 / 0.08);
    --color-border-strong: #6e6e73;

    --color-primary: var(--apple-blue-dark-text);
    --color-primary-hover: #47a5ff;
    --color-primary-active: #6bb6ff;
    --color-primary-soft: rgb(41 151 255 / 0.16);
    --color-focus: var(--apple-blue-dark-text);
    --color-focus-ring: rgb(41 151 255 / 0.35);

    --color-neutral-bg: var(--dark-150);
    --color-neutral-text: #c7c7cc;
    --color-success-bg: rgb(48 209 88 / 0.16);
    --color-success-text: #30d158;
    --color-warning-bg: rgb(255 214 10 / 0.14);
    --color-warning-border: rgb(255 214 10 / 0.45);
    --color-warning-text: #ffd60a;
    --color-danger: #d70015;
    --color-danger-hover: #ff3b30;
    --color-danger-bg: rgb(255 69 58 / 0.16);
    --color-danger-text: #ff6961;
    --color-info-bg: rgb(41 151 255 / 0.16);
    --color-info-text: #64b5ff;

    --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.06);
    --shadow-pop: 0 12px 40px rgb(0 0 0 / 0.6);
    --env-banner-stripe: #ffd60a;
    --color-overlay: rgb(0 0 0 / 0.55);
}

:root[data-theme="light"] {
    color-scheme: light;
}
