/**
 * SISTEMA DE TEMAS CSS - DÍA/NOCHE
 * Variables CSS centralizadas para toda la plataforma
 * 
 * Incluir en todas las páginas:
 * <link rel="stylesheet" href="../common/css/theme.css">
 */

/* ==========================================
   VARIABLES DE TEMA CLARO (DEFAULT)
   ========================================== */
:root,
.theme-light {
    /* Colores de fondo */
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-modal: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-hover: #F9FAFB;
    
    /* Colores de texto */
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-tertiary: #9CA3AF;
    --text-inverted: #FFFFFF;
    --text-muted: #6B7280;
    
    /* Colores de marca */
    --brand-primary: #FF5500;
    --brand-secondary: #FF8800;
    --brand-gradient: linear-gradient(135deg, #FF5500 0%, #FF8800 100%);
    
    /* Colores de estado */
    --success: #10B981;
    --success-bg: #D1FAE5;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --error: #EF4444;
    --error-bg: #FEE2E2;
    --info: #3B82F6;
    --info-bg: #DBEAFE;
    
    /* Bordes y sombras */
    --border-color: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Navegación */
    --nav-bg: #FFFFFF;
    --nav-border: #F0F0F0;
    --nav-active: #FF5500;
    --nav-inactive: #9CA3AF;
    
    /* Formularios */
    --input-border: #D1D5DB;
    --input-focus: #FF5500;
    --input-placeholder: #9CA3AF;
    
    /* Overlays */
    --overlay-bg: rgba(0, 0, 0, 0.5);
    
    /* Color scheme for browser */
    color-scheme: light;
}

/* ==========================================
   VARIABLES DE TEMA OSCURO
   ========================================== */
.theme-dark,
.dark {
    /* Colores de fondo */
    --bg-primary: #0F0F1A;
    --bg-secondary: #1A1A2E;
    --bg-tertiary: #252542;
    --bg-card: #1E1E32;
    --bg-modal: #1A1A2E;
    --bg-input: #252542;
    --bg-hover: #2A2A45;
    
    /* Colores de texto */
    --text-primary: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-tertiary: #9CA3AF;
    --text-inverted: #1F2937;
    --text-muted: #6B7280;
    
    /* Colores de marca (más vibrantes en modo oscuro) */
    --brand-primary: #FF6B35;
    --brand-secondary: #FFA033;
    --brand-gradient: linear-gradient(135deg, #FF6B35 0%, #FFA033 100%);
    
    /* Colores de estado (ajustados para fondo oscuro) */
    --success: #34D399;
    --success-bg: rgba(52, 211, 153, 0.15);
    --warning: #FBBF24;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --error: #F87171;
    --error-bg: rgba(248, 113, 113, 0.15);
    --info: #60A5FA;
    --info-bg: rgba(96, 165, 250, 0.15);
    
    /* Bordes y sombras */
    --border-color: #374151;
    --border-light: #2A2A45;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    
    /* Navegación */
    --nav-bg: #1A1A2E;
    --nav-border: #252542;
    --nav-active: #FF6B35;
    --nav-inactive: #6B7280;
    
    /* Formularios */
    --input-border: #374151;
    --input-focus: #FF6B35;
    --input-placeholder: #6B7280;
    
    /* Overlays */
    --overlay-bg: rgba(0, 0, 0, 0.7);
    
    /* Color scheme for browser */
    color-scheme: dark;
}

/* ==========================================
   ESTILOS BASE
   ========================================== */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Cards */
.card,
.bg-white {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Inputs */
input, textarea, select {
    background-color: var(--bg-input);
    border-color: var(--input-border);
    color: var(--text-primary);
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--input-focus);
    outline-color: var(--input-focus);
}

/* Modals */
.modal-content {
    background-color: var(--bg-modal);
}

/* Bottom Navigation */
.bottom-nav {
    background-color: var(--nav-bg);
    border-top-color: var(--nav-border);
}

/* Bordes */
.border-gray-100,
.border-gray-200 {
    border-color: var(--border-light) !important;
}

/* Texto gris */
.text-gray-400,
.text-gray-500 {
    color: var(--text-tertiary) !important;
}

.text-gray-600,
.text-gray-700 {
    color: var(--text-secondary) !important;
}

.text-gray-800,
.text-gray-900 {
    color: var(--text-primary) !important;
}

/* ==========================================
   TOGGLE BUTTON DE TEMA
   ========================================== */
.theme-toggle {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-gradient);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Iconos del toggle */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-light .theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg);
}

.theme-light .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0);
}

.theme-dark .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0);
}

.theme-dark .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg);
}

/* ==========================================
   RESPONSIVE UTILITIES
   ========================================== */

/* Mobile First - Base */
.container {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Tablets (640px+) */
@media (min-width: 640px) {
    .container {
        max-width: 640px;
        margin: 0 auto;
    }
}

/* Small laptops (768px+) */
@media (min-width: 768px) {
    .container {
        max-width: 768px;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Laptops (1024px+) */
@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
    
    .bottom-nav {
        display: none;
    }
}

/* Desktops (1280px+) */
@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* ==========================================
   SAFE AREA (NOTCH) SUPPORT
   ========================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .bottom-nav {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    header {
        padding-top: calc(1.5rem + env(safe-area-inset-top));
    }
}

/* ==========================================
   ANIMACIONES SUAVES
   ========================================== */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

/* Desactivar transiciones para evitar flash al cargar */
.theme-transitioning * {
    transition: none !important;
}

/* ==========================================
   SCROLLBAR PERSONALIZADA
   ========================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-tertiary) var(--bg-tertiary);
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
    .bottom-nav,
    .theme-toggle {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* ==========================================
   BADGES DE ESTADO (Modo Oscuro)
   Sobreescribe las clases de Tailwind utilitarias
   ========================================== */
.theme-dark .bg-yellow-50, 
.theme-dark .bg-yellow-100 { 
    background-color: rgba(234, 179, 8, 0.2) !important; 
    color: #fef08a !important; 
    border-color: rgba(234, 179, 8, 0.3) !important; 
}

.theme-dark .bg-blue-50,
.theme-dark .bg-blue-100 { 
    background-color: rgba(59, 130, 246, 0.2) !important; 
    color: #bfdbfe !important; 
    border-color: rgba(59, 130, 246, 0.3) !important;
}

.theme-dark .bg-green-50,
.theme-dark .bg-green-100 { 
    background-color: rgba(34, 197, 94, 0.2) !important; 
    color: #bbf7d0 !important; 
    border-color: rgba(34, 197, 94, 0.3) !important;
}

.theme-dark .bg-red-50,
.theme-dark .bg-red-100 { 
    background-color: rgba(239, 68, 68, 0.2) !important; 
    color: #fecaca !important; 
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.theme-dark .bg-purple-50,
.theme-dark .bg-purple-100 { 
    background-color: rgba(168, 85, 247, 0.2) !important; 
    color: #e9d5ff !important; 
    border-color: rgba(168, 85, 247, 0.3) !important;
}

.theme-dark .bg-indigo-50,
.theme-dark .bg-indigo-100 { 
    background-color: rgba(99, 102, 241, 0.2) !important; 
    color: #c7d2fe !important; 
    border-color: rgba(99, 102, 241, 0.3) !important;
}

.theme-dark .bg-orange-50,
.theme-dark .bg-orange-100 { 
    background-color: rgba(249, 115, 22, 0.2) !important; 
    color: #fed7aa !important; 
    border-color: rgba(249, 115, 22, 0.3) !important;
}

.theme-dark .bg-gray-50,
.theme-dark .bg-gray-100 {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
/* Navigation Component */
nav {
    background-color: var(--nav-bg) !important;
    border-top-color: var(--nav-border) !important;
}

.nav-item {
    color: var(--nav-inactive);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:active { transform: scale(0.95); }

.nav-item.active {
    color: var(--nav-active);
}

.nav-item.active svg {
    stroke: var(--nav-active);
    filter: drop-shadow(0 0 8px rgba(255, 85, 0, 0.3));
}

:root.theme-dark .nav-item.active svg {
    filter: drop-shadow(0 0 10px rgba(255, 107, 53, 0.5));
}
