/* ========================================
   CONTAX Portal - Theme Configuration & Design Tokens
   ========================================
   
   Define variables globales del sistema de diseño (Light & Dark Mode).
   Soporta personalización dinámica de branding sin romper la armonía visual.
   ======================================== */

/* Alpine.js cloak - hide elements until Alpine initializes */
[x-cloak] {
    display: none !important;
}

:root {
    /* ===== TIPOGRAFÍA & FUENTES ===== */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    
    --font-size-2xs: 0.6875rem; /* 11px */
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.8125rem;  /* 13px */
    --font-size-base: 0.875rem; /* 14px */
    --font-size-md: 0.9375rem;  /* 15px */
    --font-size-lg: 1rem;       /* 16px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */

    /* ===== COLORES DEL TEMA (LIGHT MODE) ===== */
    /* Primarios por defecto (sobrescribibles por branding dinámico) */
    --color-primary: #18181b;
    --color-primary-hover: #27272a;
    --color-primary-light: #f4f4f5;
    --color-primary-dark: #09090b;

    /* Superficies y Fondos */
    --bg-body: #f8fafc;
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-subtle: #f8fafc;
    --bg-card-dark: #18181b;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;

    /* Texto & Jerarquía */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-subtle: #cbd5e1;
    --text-inverse: #ffffff;

    /* Bordes & Divisores */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-strong: #cbd5e1;

    /* ===== DIMENSIONES & ELEVACIONES ===== */
    /* Radios armónicos */
    --radius-xs: 0.25rem;   /* 4px */
    --radius-sm: 0.375rem;  /* 6px */
    --radius-md: 0.5rem;    /* 8px */
    --radius-lg: 0.75rem;   /* 12px - Inputs, Botones */
    --radius-xl: 1rem;      /* 16px - Cards */
    --radius-2xl: 1.25rem;  /* 20px */
    --radius-3xl: 1.5rem;   /* 24px - Modales, Paneles */
    --radius-full: 9999px;

    /* Sombras sutiles */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transiciones fluidas */
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 150ms var(--ease-standard);
    --transition-normal: 200ms var(--ease-standard);
    --transition-slow: 300ms var(--ease-standard);

    /* Espaciado */
    --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;

    /* ===== COLORES DE ESTADO - PALETA SOFT PREMIUM ===== */
    /* Pendiente (Slate / Neutral suave) */
    --status-pending: #64748b;
    --status-pending-text: #334155;
    --status-pending-bg: #f1f5f9;
    --status-pending-border: #e2e8f0;

    /* En Progreso (Ámbar cálido) */
    --status-progress: #d97706;
    --status-progress-text: #b45309;
    --status-progress-bg: #fef3c7;
    --status-progress-border: #fde68a;

    /* En Revisión (Azul cielo) */
    --status-review: #2563eb;
    --status-review-text: #1d4ed8;
    --status-review-bg: #dbeafe;
    --status-review-border: #bfdbfe;

    /* Completado / Pagado (Esmeralda suave) */
    --status-completed: #059669;
    --status-completed-text: #047857;
    --status-completed-bg: #d1fae5;
    --status-completed-border: #a7f3d0;

    /* Vencido / Peligro (Coral / Rosa suave) */
    --status-overdue: #e11d48;
    --status-overdue-text: #be123c;
    --status-overdue-bg: #ffe4e6;
    --status-overdue-border: #fecdd3;

    /* Cancelado / Anulado (Gris atenuado) */
    --status-cancelled: #94a3b8;
    --status-cancelled-text: #64748b;
    --status-cancelled-bg: #f1f5f9;
    --status-cancelled-border: #e2e8f0;

    /* Info / Proyectos / Inteligencia (Lavanda / Violeta) */
    --status-project: #7c3aed;
    --status-project-text: #6d28d9;
    --status-project-bg: #ede9fe;
    --status-project-border: #ddd6fe;
}

/* ===== DARK MODE (SLEEK ZINC & CARBON SYSTEM) ===== */
.dark {
    /* Fondos refinados sin tonos azulados sucios */
    --bg-body: #09090b;
    --bg-main: #09090b;
    --bg-sidebar: #0f0f12;
    --bg-card: #141417;
    --bg-card-subtle: #18181c;
    --bg-card-dark: #1e1e24;
    --bg-hover: #202025;
    --bg-active: #282830;

    /* Texto & Jerarquía */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-subtle: #3f3f46;
    --text-inverse: #09090b;

    /* Bordes & Divisores */
    --border-color: #27272a;
    --border-light: #1f1f23;
    --border-strong: #3f3f46;

    /* Sombras oscuras */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.5);

    /* ===== COLORES DE ESTADO PARA DARK MODE (ALTO CONTRASTE SUAVE) ===== */
    /* Pendiente */
    --status-pending: #94a3b8;
    --status-pending-text: #e2e8f0;
    --status-pending-bg: rgba(148, 163, 184, 0.15);
    --status-pending-border: rgba(148, 163, 184, 0.25);

    /* En Progreso */
    --status-progress: #fbbf24;
    --status-progress-text: #fef08a;
    --status-progress-bg: rgba(245, 158, 11, 0.18);
    --status-progress-border: rgba(245, 158, 11, 0.3);

    /* En Revisión */
    --status-review: #60a5fa;
    --status-review-text: #bfdbfe;
    --status-review-bg: rgba(59, 130, 246, 0.18);
    --status-review-border: rgba(59, 130, 246, 0.3);

    /* Completado / Pagado */
    --status-completed: #34d399;
    --status-completed-text: #a7f3d0;
    --status-completed-bg: rgba(16, 185, 129, 0.18);
    --status-completed-border: rgba(16, 185, 129, 0.3);

    /* Vencido / Peligro */
    --status-overdue: #fb7185;
    --status-overdue-text: #fecdd3;
    --status-overdue-bg: rgba(244, 63, 94, 0.18);
    --status-overdue-border: rgba(244, 63, 94, 0.3);

    /* Cancelado */
    --status-cancelled: #71717a;
    --status-cancelled-text: #a1a1aa;
    --status-cancelled-bg: rgba(113, 113, 122, 0.18);
    --status-cancelled-border: rgba(113, 113, 122, 0.3);

    /* Info / Proyectos / Inteligencia */
    --status-project: #a78bfa;
    --status-project-text: #ddd6fe;
    --status-project-bg: rgba(139, 92, 246, 0.18);
    --status-project-border: rgba(139, 92, 246, 0.3);
}

/* ========================================
   ARMONIZACIÓN TIPOGRÁFICA & TABULAR
   ======================================== */

body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Cifras numéricas tabulares para alineación perfecta en reportes y tablas */
.tabular-nums,
.font-mono-amount,
.stat-value,
.amount-text,
table td.num,
table th.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "cv05" 1;
}

.font-mono-amount {
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

/* ========================================
   MAPEO DE CLASES TAILWIND EN MODO OSCURO
   Alinea los grises de Tailwind con los tokens Zinc
   ======================================== */

.dark .bg-gray-800,
.dark [class*="dark:bg-gray-800"] {
    background-color: var(--bg-card) !important;
}

.dark .bg-gray-700,
.dark [class*="dark:bg-gray-700"] {
    background-color: var(--bg-card-subtle) !important;
}

.dark .bg-gray-900,
.dark [class*="dark:bg-gray-900"] {
    background-color: var(--bg-body) !important;
}

.dark .bg-gray-600,
.dark [class*="dark:bg-gray-600"] {
    background-color: var(--bg-hover) !important;
}

/* Bordes consistentes */
.dark .border-gray-700,
.dark [class*="dark:border-gray-700"] {
    border-color: var(--border-color) !important;
}

.dark .border-gray-600,
.dark [class*="dark:border-gray-600"] {
    border-color: var(--border-color) !important;
}

.dark .border-gray-800,
.dark [class*="dark:border-gray-800"] {
    border-color: var(--border-light) !important;
}

/* Fondos de hover consistentes */
.dark [class*="dark:hover:bg-gray-700"]:hover,
.dark [class*="hover:bg-gray-700"]:hover,
.dark [class*="dark:hover:bg-gray-600"]:hover,
.dark [class*="hover:bg-gray-600"]:hover {
    background-color: var(--bg-hover) !important;
}

/* Textos con contraste refinado */
.dark .text-gray-400,
.dark [class*="dark:text-gray-400"] {
    color: var(--text-secondary) !important;
}

.dark .text-gray-300,
.dark [class*="dark:text-gray-300"] {
    color: var(--text-secondary) !important;
}

.dark .text-gray-200,
.dark [class*="dark:text-gray-200"] {
    color: var(--text-primary) !important;
}

/* ========================================
   GLOBAL SLEEK SCROLLBARS
   ======================================== */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 150, 150, 0.25) transparent;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.25);
    border-radius: 9999px;
    transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(150, 150, 150, 0.45);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 150, 150, 0.25) transparent;
}

/* ========================================
   SKELETON SHIMMER UTILITIES
   ======================================== */

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-shimmer {
    background: linear-gradient(90deg, 
        rgba(228, 228, 231, 0.6) 25%, 
        rgba(244, 244, 245, 0.9) 37%, 
        rgba(228, 228, 231, 0.6) 63%
    );
    background-size: 200% 100%;
    animation: shimmer 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.dark .skeleton-shimmer {
    background: linear-gradient(90deg, 
        rgba(39, 39, 42, 0.6) 25%, 
        rgba(63, 63, 70, 0.9) 37%, 
        rgba(39, 39, 42, 0.6) 63%
    );
    background-size: 200% 100%;
}

/* ========================================
   HUB 2-COLUMN UNIFIED LAYOUT
   ======================================== */

.hub-container {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    overflow: hidden;
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

@media (max-width: 768px) {
    .hub-container {
        flex-direction: column;
        max-height: none;
        height: auto;
    }
}

.hub-inner-sidebar {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .hub-inner-sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    margin: 0.125rem 0.625rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    text-decoration: none;
}

.sidebar-nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
    transition: transform var(--transition-fast);
}

.sidebar-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar-nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

.hub-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden;
    min-width: 0;
}

.hub-content-header {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.hub-content-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ========================================
   CANONICAL DESIGN SYSTEM UTILITY CLASSES
   ======================================== */

/* Bento Card Base */
.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.bento-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Canonical Page Header */
.heading-module {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
@media (min-width: 640px) {
    .heading-module {
        font-size: 1.25rem;
    }
}

.subheading-module {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.125rem;
}

/* Canonical Buttons */
.btn-brand-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-inverse);
    background: var(--color-primary);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}
.btn-brand-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-brand-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: all var(--transition-fast);
}
.btn-brand-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-brand-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    background: #25D366;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}
.btn-brand-whatsapp:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}
