/* ============================================================
   Obitus — Design Tokens
   Sistema de diseño moderno construido sobre la paleta corporativa.
   Acento principal: teal #176b87 (mantenido del look existente).
   ============================================================ */

:root {
    /* === Color: brand (teal corporativo) === */
    --brand-50:  #ecf6f9;
    --brand-100: #cfe7ed;
    --brand-200: #a4d3de;
    --brand-300: #6fb8c9;
    --brand-400: #3e98ae;
    --brand-500: #176b87;   /* color principal histórico */
    --brand-600: #135a72;
    --brand-700: #0f475a;
    --brand-800: #0c3848;
    --brand-900: #0a2c38;

    /* === Color: neutrals === */
    --gray-0:   #ffffff;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* === Color: semantic === */
    --color-bg:          var(--gray-50);
    --color-surface:     var(--gray-0);
    --color-surface-alt: var(--gray-100);
    --color-text:        var(--gray-900);
    --color-text-muted:  var(--gray-500);
    --color-border:      var(--gray-200);
    --color-border-strong: var(--gray-300);
    --color-accent:      var(--brand-500);
    --color-accent-hover:var(--brand-600);
    --color-accent-soft: var(--brand-50);

    --color-success: #16a34a;
    --color-success-soft: #dcfce7;
    --color-warning: #d97706;
    --color-warning-soft: #fef3c7;
    --color-danger:  #dc2626;
    --color-danger-soft: #fee2e2;
    --color-info:    #0891b2;

    /* === Spacing — 8px grid === */
    --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;
    --space-16: 4rem;

    /* === Radius === */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* === Elevation === */
    --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
    --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08), 0 1px 2px -1px rgb(15 23 42 / 0.04);
    --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.10), 0 4px 6px -4px rgb(15 23 42 / 0.08);
    --shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.10), 0 8px 10px -6px rgb(15 23 42 / 0.08);
    --shadow-glow: 0 0 0 4px rgb(23 107 135 / 0.18);

    /* === Typography === */
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;

    --text-xs:   clamp(0.75rem, 0.7rem + 0.1vw, 0.8125rem);
    --text-sm:   clamp(0.875rem, 0.83rem + 0.15vw, 0.9375rem);
    --text-base: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
    --text-lg:   clamp(1.125rem, 1.05rem + 0.3vw, 1.25rem);
    --text-xl:   clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
    --text-2xl:  clamp(1.5rem, 1.3rem + 0.8vw, 2rem);
    --text-3xl:  clamp(1.875rem, 1.6rem + 1.1vw, 2.5rem);

    --leading-tight: 1.2;
    --leading-snug:  1.4;
    --leading-normal:1.55;
    --leading-loose: 1.75;

    --weight-regular: 400;
    --weight-medium:  500;
    --weight-semi:    600;
    --weight-bold:    700;

    /* === Motion === */
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in:       cubic-bezier(0.4, 0, 1, 1);
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 300ms;

    /* === Layout === */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --header-height: 4rem;
    --content-max:   1600px;

    /* === Z-index === */
    --z-sticky:  100;
    --z-drawer:  200;
    --z-overlay: 300;
    --z-modal:   400;
    --z-toast:   500;
}

/* === Dark theme === */
[data-theme="dark"] {
    --color-bg:          #0b1220;
    --color-surface:     #111a2e;
    --color-surface-alt: #18223a;
    --color-text:        #e2e8f0;
    --color-text-muted:  #94a3b8;
    --color-border:      #1f2a44;
    --color-border-strong: #2a3656;
    --color-accent:      var(--brand-300);
    --color-accent-hover:var(--brand-200);
    --color-accent-soft: rgb(23 107 135 / 0.18);

    --color-success-soft: rgb(22 163 74 / 0.18);
    --color-warning-soft: rgb(217 119 6 / 0.18);
    --color-danger-soft:  rgb(220 38 38 / 0.18);

    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.30);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.40), 0 1px 2px -1px rgb(0 0 0 / 0.30);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.45), 0 2px 4px -2px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.50), 0 4px 6px -4px rgb(0 0 0 / 0.40);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.55), 0 8px 10px -6px rgb(0 0 0 / 0.40);
    --shadow-glow: 0 0 0 4px rgb(111 184 201 / 0.25);

    color-scheme: dark;
}

[data-theme="dark"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Bootstrap table dark mode overrides */
[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--color-text);
    --bs-table-hover-bg: var(--color-surface-alt);
    --bs-table-hover-color: var(--color-text);
    --bs-table-striped-bg: transparent;
    --bs-table-border-color: var(--color-border);
    color: var(--color-text);
}

[data-theme="dark"] .table tbody td,
[data-theme="dark"] .table thead th {
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    color: var(--color-text);
    background-color: var(--color-surface-alt);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Smooth focus ring for keyboard users only */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Body baseline */
html {
    color-scheme: light;
}

body {
    font-family: var(--font-sans);
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
