/*
 * JC Ltda - Premium UI Stylesheet
 * Estilo Apple-inspired con Glassmorphism, Depth & Micro-interactions
 * Compatible con modo claro/oscuro
 */

/* ========================================
   1. TIPOGRAFÍA & SISTEMA DE FUENTES
   ======================================== */

:root {
    /* Fuentes del sistema (100% local - San Francisco en macOS, Segoe UI en Windows) */
    --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    /* Escala tipográfica premium */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Letter spacing (tracking) - Apple style */
    --tracking-tighter: -0.05em;
    --tracking-tight: -0.025em;
    --tracking-normal: 0em;
    --tracking-wide: 0.025em;
    
    /* Border radius global */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    
    /* Paleta de Colores Apple-Inspired (Modo Claro) */
    --color-bg-primary: #f5f7fa;
    --color-bg-secondary: #ffffff;
    --color-text-primary: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-tertiary: #86868b;
    
    /* Colores Accent - Azul vibrante estilo iOS */
    --color-accent-primary: #007aff;
    --color-accent-hover: #0051d5;
    --color-accent-light: #e3f2fd;
    
    /* Colores Secundarios */
    --color-purple: #5e5ce6;
    --color-purple-hover: #4c4acf;
    --color-pink: #ff2d55;
    --color-pink-hover: #e5003c;
    --color-orange: #ff9500;
    --color-orange-hover: #e68600;
    --color-green: #34c759;
    --color-green-hover: #2db04a;
    --color-red: #ff3b30;
    --color-red-hover: #e62e24;
    
    /* Glassmorphism */
    --glass-bg-light: rgba(255, 255, 255, 0.72);
    --glass-bg-dark: rgba(29, 29, 31, 0.72);
    --glass-border-light: rgba(0, 0, 0, 0.04);
    --glass-border-dark: rgba(255, 255, 255, 0.12);
    --glass-blur: 20px;
    
    /* Sombras Apple-style - Modo claro */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12);
    --shadow-2xl: 0 32px 64px rgba(0, 0, 0, 0.14);
    
    /* Transiciones fluidas */
    --transition-base: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo oscuro - Override de variables */
body.dark-mode {
    /* Colores de fondo oscuros */
    --color-bg-primary: #000000;
    --color-bg-secondary: #1c1c1e;
    --color-text-primary: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-text-tertiary: #6e6e73;
    
    /* Accent colors ajustados para modo oscuro */
    --color-accent-primary: #0a84ff;
    --color-accent-hover: #409cff;
    --color-accent-light: rgba(10, 132, 255, 0.15);
    
    /* Glassmorphism oscuro */
    --glass-bg-light: rgba(28, 28, 30, 0.8);
    --glass-border-light: rgba(255, 255, 255, 0.1);
    
    /* Sombras intensas para modo oscuro */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.7);
    --shadow-2xl: 0 32px 64px rgba(0, 0, 0, 0.8);
}

/* ========================================
   2. TIPOGRAFÍA GLOBAL
   ======================================== */

body {
    font-family: var(--font-system);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-system);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    line-height: 1.2;
}

h1, .h1 { font-size: var(--font-size-4xl); font-weight: 800; }
h2, .h2 { font-size: var(--font-size-3xl); font-weight: 700; }
h3, .h3 { font-size: var(--font-size-2xl); font-weight: 700; }
h4, .h4 { font-size: var(--font-size-xl); font-weight: 600; }
h5, .h5 { font-size: var(--font-size-lg); font-weight: 600; }
h6, .h6 { font-size: var(--font-size-base); font-weight: 600; }

.text-premium {
    letter-spacing: var(--tracking-tight);
}

/* ========================================
   3. GLASSMORPHISM - TARJETAS
   ======================================== */

.card {
    background: var(--glass-bg-light);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transition: var(--transition-base);
    overflow: hidden;
}

body.dark-mode .card {
    background: var(--glass-bg-dark);
    border-color: var(--glass-border-dark);
    box-shadow: var(--shadow-xl);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

body.dark-mode .card:hover {
    box-shadow: var(--shadow-2xl);
    border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--glass-border-light);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 1.25rem 1.5rem;
}

body.dark-mode .card-header {
    background: rgba(15, 23, 42, 0.3);
    border-bottom-color: var(--glass-border-dark);
}

.card-body {
    padding: 1.75rem;
}

.card-footer {
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--glass-border-light);
    padding: 1.25rem 1.5rem;
}

body.dark-mode .card-footer {
    background: rgba(15, 23, 42, 0.2);
    border-top-color: var(--glass-border-dark);
}

/* ========================================
   4. NAVBAR & TOPBAR - GLASSMORPHISM
   ======================================== */

.app-topbar {
    background: var(--glass-bg-light) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border-light) !important;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

body.dark-mode .app-topbar {
    background: var(--glass-bg-dark) !important;
    border-bottom-color: var(--glass-border-dark) !important;
    box-shadow: var(--shadow-md);
}

.navbar {
    background: var(--glass-bg-light) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-light);
    box-shadow: var(--shadow-md);
}

body.dark-mode .navbar {
    background: var(--glass-bg-dark) !important;
    border-color: var(--glass-border-dark);
}

/* ========================================
   5. BOTONES - ESTILO LIQUID GLASS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.08),
        inset 0 1px 1px rgba(255, 255, 255, 0.6),
        inset 0 -1px 1px rgba(0, 0, 0, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 
        0 2px 6px rgba(0, 0, 0, 0.1),
        inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 3px;
}

/* Primary & Dark (Azul Liquid Glass) */
.btn-primary,
.btn-dark {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(0, 122, 255, 0.85) 0%, rgba(0, 81, 213, 0.95) 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 6px 16px rgba(0, 122, 255, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.5),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover,
.btn-dark:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(26, 138, 255, 0.9) 0%, rgba(0, 98, 204, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(0, 122, 255, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

body.dark-mode .btn-primary,
body.dark-mode .btn-dark {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(10, 132, 255, 0.75) 0%, rgba(0, 98, 204, 0.85) 100%);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 6px 16px rgba(10, 132, 255, 0.25),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

body.dark-mode .btn-primary:hover,
body.dark-mode .btn-dark:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(64, 156, 255, 0.85) 0%, rgba(10, 132, 255, 0.95) 100%);
    box-shadow: 0 8px 20px rgba(10, 132, 255, 0.35);
}

/* Secondary / Light (Gris Liquid Glass) */
.btn-secondary,
.btn-light {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(245, 245, 247, 0.8) 0%, rgba(226, 226, 231, 0.9) 100%);
    color: #1d1d1f;
    border-color: rgba(255, 255, 255, 0.6);
    text-shadow: none;
}

.btn-secondary:hover,
.btn-light:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.9) 0%, rgba(232, 232, 237, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

body.dark-mode .btn-secondary,
body.dark-mode .btn-light {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(44, 44, 46, 0.7) 0%, rgba(28, 28, 30, 0.8) 100%);
    color: #f5f5f7;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .btn-secondary:hover,
body.dark-mode .btn-light:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(58, 58, 60, 0.8) 0%, rgba(44, 44, 46, 0.9) 100%);
}

/* Success (Verde Liquid Glass) */
.btn-success {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(52, 199, 89, 0.85) 0%, rgba(45, 176, 74, 0.95) 100%);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(52, 199, 89, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.btn-success:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(68, 214, 105, 0.9) 0%, rgba(52, 199, 89, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 199, 89, 0.4);
}

body.dark-mode .btn-success {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(48, 209, 88, 0.75) 0%, rgba(45, 176, 74, 0.85) 100%);
}

/* Danger (Rojo Liquid Glass) */
.btn-danger {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(255, 59, 48, 0.85) 0%, rgba(230, 46, 36, 0.95) 100%);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(255, 59, 48, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.btn-danger:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(255, 87, 77, 0.9) 0%, rgba(255, 59, 48, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 59, 48, 0.4);
}

body.dark-mode .btn-danger {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(255, 69, 58, 0.75) 0%, rgba(230, 46, 36, 0.85) 100%);
}

/* Warning (Naranja Liquid Glass) */
.btn-warning {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(255, 149, 0, 0.85) 0%, rgba(230, 134, 0, 0.95) 100%);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(255, 149, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.btn-warning:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(255, 167, 38, 0.9) 0%, rgba(255, 149, 0, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 149, 0, 0.4);
}

body.dark-mode .btn-warning {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(255, 159, 10, 0.75) 0%, rgba(230, 134, 0, 0.85) 100%);
}

/* Info Button */
.btn-info {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(90, 200, 250, 0.85) 0%, rgba(40, 160, 220, 0.95) 100%);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(90, 200, 250, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.btn-info:hover {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 50%),
        linear-gradient(145deg, rgba(100, 210, 255, 0.9) 0%, rgba(90, 200, 250, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(90, 200, 250, 0.4);
}

body.dark-mode .btn-info {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(100, 210, 255, 0.75) 0%, rgba(40, 160, 220, 0.85) 100%);
}

/* Outline Primary (Glassy Outline) */
.btn-outline-primary {
    background: rgba(0, 122, 255, 0.05);
    color: #007aff;
    border-color: rgba(0, 122, 255, 0.4);
    text-shadow: none;
}

.btn-outline-primary:hover {
    background: rgba(0, 122, 255, 0.15);
    border-color: rgba(0, 122, 255, 0.6);
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-primary {
    color: #0a84ff;
    border-color: rgba(10, 132, 255, 0.4);
}

body.dark-mode .btn-outline-primary:hover {
    background: rgba(10, 132, 255, 0.15);
}

/* Outline Secondary */
.btn-outline-secondary {
    background: rgba(110, 110, 115, 0.05);
    color: #6e6e73;
    border-color: rgba(110, 110, 115, 0.3);
    text-shadow: none;
}

.btn-outline-secondary:hover {
    background: rgba(110, 110, 115, 0.15);
    color: #1d1d1f;
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-secondary {
    color: #a1a1a6;
    border-color: rgba(161, 161, 166, 0.3);
}

body.dark-mode .btn-outline-secondary:hover {
    background: rgba(161, 161, 166, 0.15);
    color: #f5f5f7;
}

/* Outline Danger */
.btn-outline-danger {
    background: rgba(255, 59, 48, 0.05);
    color: #ff3b30;
    border-color: rgba(255, 59, 48, 0.4);
    text-shadow: none;
}

.btn-outline-danger:hover {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.6);
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-danger {
    color: #ff453a;
    border-color: rgba(255, 69, 58, 0.4);
}

body.dark-mode .btn-outline-danger:hover {
    background: rgba(255, 69, 58, 0.15);
}

/* Outline Success */
.btn-outline-success {
    background: rgba(52, 199, 89, 0.05);
    color: #34c759;
    border-color: rgba(52, 199, 89, 0.4);
    text-shadow: none;
}

.btn-outline-success:hover {
    background: rgba(52, 199, 89, 0.15);
    border-color: rgba(52, 199, 89, 0.6);
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-success {
    color: #30d158;
    border-color: rgba(48, 209, 88, 0.4);
}

body.dark-mode .btn-outline-success:hover {
    background: rgba(48, 209, 88, 0.15);
}

/* Outline Warning */
.btn-outline-warning {
    background: rgba(255, 149, 0, 0.05);
    color: #ff9500;
    border-color: rgba(255, 149, 0, 0.4);
    text-shadow: none;
}

.btn-outline-warning:hover {
    background: rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.6);
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-warning {
    color: #ff9f0a;
    border-color: rgba(255, 159, 10, 0.4);
}

body.dark-mode .btn-outline-warning:hover {
    background: rgba(255, 159, 10, 0.15);
}

/* Outline Info */
.btn-outline-info {
    background: rgba(90, 200, 250, 0.05);
    color: #5ac8fa;
    border-color: rgba(90, 200, 250, 0.4);
    text-shadow: none;
}

.btn-outline-info:hover {
    background: rgba(90, 200, 250, 0.15);
    border-color: rgba(90, 200, 250, 0.6);
    transform: translateY(-1px);
}

body.dark-mode .btn-outline-info {
    color: #64d2ff;
    border-color: rgba(100, 210, 255, 0.4);
}

body.dark-mode .btn-outline-info:hover {
    background: rgba(100, 210, 255, 0.15);
}

/* Icon Button */
.btn-icon {
    padding: 0.55rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: scale(1.08) translateY(-1px);
}


/* ========================================
   6. FORMULARIOS - PREMIUM INPUT
   ======================================== */

.form-control,
.form-select {
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    transition: var(--transition-base);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-xs);
    color: var(--color-text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 4px var(--color-accent-light);
    transform: translateY(-1px);
    background: #ffffff;
}

/* appearance enhancement for native selects when Select2 is not applied */
.form-select:not(.select2) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    padding-right: 2.25rem !important;
    cursor: pointer !important;
    
    /* Agregamos la flecha como imagen de fondo (SVG) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background: rgba(28, 28, 30, 0.8);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary);
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.2);
    background: rgba(28, 28, 30, 0.95);
}

.form-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

body.dark-mode .form-label {
    color: var(--color-text-secondary);
}

/* ========================================
   7. MODALES - GLASSMORPHISM
   ======================================== */

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-2xl);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

body.dark-mode .modal-content {
    background: rgba(44, 44, 46, 0.92);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.75rem 2rem;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.1) 100%);
}

body.dark-mode .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.modal-body {
    padding: 2rem;
    color: var(--color-text-primary);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.25rem 1.5rem;
    background: rgba(245, 245, 247, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

body.dark-mode .modal-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
    background: rgba(30, 30, 32, 0.6);
}

/* Estilos específicos para botones en el footer del modal */
.modal-footer .btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 12px;
    min-width: 120px;
    margin: 0; /* Override bootstrap default margin */
}

/* Botón secundario (Cancelar) estilo Apple */
.modal-footer .btn-outline-secondary,
.modal-footer .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid transparent;
    color: var(--color-text-primary);
    box-shadow: none;
    backdrop-filter: none;
}

.modal-footer .btn-outline-secondary:hover,
.modal-footer .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

body.dark-mode .modal-footer .btn-outline-secondary,
body.dark-mode .modal-footer .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f7;
}

body.dark-mode .modal-footer .btn-outline-secondary:hover,
body.dark-mode .modal-footer .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.modal-title {
    font-weight: 700;
    font-size: var(--font-size-2xl);
    letter-spacing: var(--tracking-tight);
    color: var(--color-text-primary);
}

body.dark-mode .modal-title {
    color: #f5f5f7;
}

/* Botón cerrar del modal */
.modal-header .btn-close {
    opacity: 0.5;
    transition: var(--transition-fast);
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.modal-header .btn-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
    transform: rotate(90deg);
}

body.dark-mode .modal-header .btn-close {
    filter: invert(1);
}

body.dark-mode .modal-header .btn-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Backdrop mejorado del modal */
.modal-backdrop {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop.show {
    opacity: 0.5;
}

body.dark-mode .modal-backdrop.show {
    opacity: 0.7;
}

/* Animación de modal mejorada */
.modal.fade .modal-dialog {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.9) translateY(-30px);
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ========================================
   8. TABLAS - PREMIUM DESIGN
   ======================================== */

.table-responsive {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table {
    font-size: var(--font-size-sm);
}

.table thead th {
    background: linear-gradient(180deg, rgba(0, 122, 255, 0.08) 0%, rgba(0, 122, 255, 0.04) 100%);
    backdrop-filter: blur(8px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    border-bottom: 2px solid rgba(0, 122, 255, 0.15);
    padding: 0.5rem 0.65rem;
    white-space: nowrap;
}

body.dark-mode .table thead th {
    background: linear-gradient(180deg, rgba(10, 132, 255, 0.12) 0%, rgba(10, 132, 255, 0.06) 100%);
    color: var(--color-text-secondary);
    border-bottom-color: rgba(10, 132, 255, 0.25);
}

.table tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table tbody td,
.table tbody th {
    padding: 0.35rem 0.65rem !important;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: rgba(0, 122, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.08);
}

body.dark-mode .table tbody tr {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .table tbody tr:hover {
    background: rgba(10, 132, 255, 0.1) !important;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.15);
}

body.dark-mode .table tbody td {
    padding: 0.35rem 0.65rem !important;
    vertical-align: middle;
    color: var(--color-text-primary);
    background-color: transparent !important;
}

/* Hover en filas de tabla modo oscuro */
body.dark-mode .table tbody tr:hover td {
    background-color: rgba(10, 132, 255, 0.1) !important;
    color: #f5f5f7;
}

/* Eliminar background blanco de DataTables en modo oscuro */
body.dark-mode table.dataTable tbody tr {
    background-color: transparent !important;
}

body.dark-mode table.dataTable tbody tr:hover {
    background-color: rgba(10, 132, 255, 0.1) !important;
}

body.dark-mode table.dataTable.table-striped tbody tr.odd {
    background-color: rgba(28, 28, 30, 0.5) !important;
}

body.dark-mode table.dataTable.table-striped tbody tr.even {
    background-color: transparent !important;
}

body.dark-mode table.dataTable tbody td {
    background-color: transparent !important;
}

/* ========================================
   9. SIDEBAR - PREMIUM ENHANCEMENT
   ======================================== */

.app-sidebar {
    background: linear-gradient(180deg, rgba(28, 28, 30, 0.98) 0%, rgba(44, 44, 46, 0.98) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

/* Logo Area */
.app-logo img {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 240, 245, 0.85) 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 14px;
    padding: 8px 12px;
}

/* Menu Links */
.app-menu-link {
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.65rem 1rem;
    margin: 0.15rem 0.5rem;
    position: relative;
    overflow: hidden;
}

.app-menu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transform: translateX(4px);
}

/* Active Link - Liquid Glass Style */
.app-menu-link.active {
    background: 
        linear-gradient(to bottom, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(145deg, rgba(0, 122, 255, 0.85) 0%, rgba(0, 81, 213, 0.95) 100%);
    box-shadow: 
        0 4px 12px rgba(0, 122, 255, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.3),
        inset 0 -1px 1px rgba(0, 0, 0, 0.1);
    color: #ffffff;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.app-menu-link.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 12px 12px 0 0;
    pointer-events: none;
}

/* Menu Groups (Dropdowns) */
.app-menu-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    margin: 0.25rem 0.5rem;
    padding: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.app-menu-group:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.app-menu-group.open {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Toggle Button inside Group */
.app-menu-toggle {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.app-menu-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.app-menu-group.open .app-menu-toggle {
    color: #ffffff;
}

/* Items inside Group */
.app-menu-items .app-menu-link {
    margin: 0.1rem 0;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    font-size: 0.9em;
    border-radius: 8px;
}

.app-menu-items .app-menu-link::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.app-menu-items .app-menu-link:hover::before {
    background: #ffffff;
    transform: translateY(-50%) scale(1.5);
}

.app-menu-items .app-menu-link.active::before {
    background: #ffffff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* ========================================
   10. UTILIDADES & HELPERS
   ======================================== */

.glass-surface {
    background: var(--glass-bg-light);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-light);
    border-radius: var(--radius-lg);
}

body.dark-mode .glass-surface {
    background: var(--glass-bg-dark);
    border-color: var(--glass-border-dark);
}

.premium-shadow-sm { box-shadow: var(--shadow-sm); }
.premium-shadow-md { box-shadow: var(--shadow-md); }
.premium-shadow-lg { box-shadow: var(--shadow-lg); }
.premium-shadow-xl { box-shadow: var(--shadow-xl); }

.premium-radius-sm { border-radius: var(--radius-sm); }
.premium-radius-md { border-radius: var(--radius-md); }
.premium-radius-lg { border-radius: var(--radius-lg); }
.premium-radius-xl { border-radius: var(--radius-xl); }

/* Animación de modal */
.modal.fade .modal-dialog {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.95) translateY(-20px);
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Animación de entrada suave */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   11. ELEMENTOS INTERACTIVOS GLOBALES
   ======================================== */

* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 0.4s;
}

/* Excluir transiciones en elementos que no las necesitan */
*,
*::before,
*::after {
    transition-property: none;
}

/* Aplicar selectivamente a elementos interactivos */
a, button, .btn, .card, .form-control, .form-select, 
.app-menu-link, .app-menu-group, .modal-content,
.table tbody tr, input, select, textarea {
    transition: var(--transition-base);
}

/* ========================================
   12. SCROLLBAR PERSONALIZADO
   ======================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.05);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

body.dark-mode ::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* ========================================
   13. BADGES & PILLS
   ======================================== */

.badge {
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.75rem;
    font-weight: 600;
    font-size: var(--font-size-xs);
    letter-spacing: 0.025em;
    backdrop-filter: blur(8px);
}

/* ========================================
   14. BOTONES DE ACCIÓN EN TABLAS
   ======================================== */

/* Botones compactos solo con íconos */
.btn-sm {
    padding: 0.35rem 0.7rem;
    border-radius: 10px;
    font-size: var(--font-size-xs);
    min-width: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 10px !important;
    transition: var(--transition-base);
    position: relative;
}

.btn-icon-only:hover {
    transform: rotate(5deg) scale(1.05);
}

/* Mixin líquido reutilizable por color eliminado para usar el nuevo estilo Liquid Glass */

/* Tooltips estilo Apple para botones de tabla únicamente */
.btn-icon-only[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    background: rgba(0, 0, 0, 0.92);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeInRotate 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.dark-mode .btn-icon-only[title]:hover::after {
    background: rgba(60, 60, 67, 0.95);
}

/* Flecha del tooltip */
.btn-icon-only[title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.92);
    pointer-events: none;
    z-index: 10000;
    animation: tooltipFadeInRotate 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body.dark-mode .btn-icon-only[title]:hover::before {
    border-top-color: rgba(60, 60, 67, 0.95);
}

@keyframes tooltipFadeInRotate {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px) rotate(0deg);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) rotate(5deg);
    }
}

/* Íconos SVG dentro de botones */
.btn svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    transition: var(--transition-fast);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

.btn-icon-only svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 2 !important;
    flex-shrink: 0;
}

.btn:hover svg {
    transform: scale(1.1);
}

/* Espacio entre botones en tablas */
.table td .btn + .btn,
.table td a.btn + a.btn,
.table td button + button {
    margin-left: 0.5rem;
}

/* ========================================
   15. AJUSTES FINALES DE INTEGRACIÓN
   ======================================== */

body {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
}

.container-fluid {
    padding-left: 2rem;
    padding-right: 2rem;
}

/* Espaciado consistente */
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }
.py-4 { padding-top: 2rem !important; padding-bottom: 2rem !important; }

/* Mejora de legibilidad */
p, li, td {
    line-height: 1.6;
}

/* Text colors globales */
.text-muted {
    color: var(--color-text-secondary) !important;
}

body.dark-mode .text-muted {
    color: var(--color-text-secondary) !important;
}

/* Badges modernos */
.badge {
    font-weight: 600;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
}

.badge-primary {
    background: linear-gradient(135deg, var(--color-accent-primary) 0%, var(--color-accent-hover) 100%);
    color: #ffffff;
}

.badge-success {
    background: linear-gradient(135deg, var(--color-green) 0%, var(--color-green-hover) 100%);
    color: #ffffff;
}

.badge-danger {
    background: linear-gradient(135deg, var(--color-red) 0%, var(--color-red-hover) 100%);
    color: #ffffff;
}

.badge-warning {
    background: linear-gradient(135deg, var(--color-orange) 0%, var(--color-orange-hover) 100%);
    color: #ffffff;
}

/* Links premium */
a {
    color: var(--color-accent-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--color-accent-hover);
}

body.dark-mode a {
    color: var(--color-accent-primary);
}

body.dark-mode a:hover {
    color: var(--color-accent-hover);
}

/* ========================================
   16. DATATABLES - MODO OSCURO FIXES
   ======================================== */

/* Controles de DataTables en modo oscuro */
body.dark-mode .dataTables_wrapper .dataTables_length select,
body.dark-mode .dataTables_wrapper .dataTables_filter input {
    background: rgba(28, 28, 30, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
}

body.dark-mode .dataTables_wrapper .dataTables_length select:focus,
body.dark-mode .dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
    outline: none;
}

/* Info de paginación */
body.dark-mode .dataTables_info {
    color: var(--color-text-secondary) !important;
}

/* Processing message */
body.dark-mode .dataTables_processing {
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    color: #f5f5f7;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

/* Empty table message */
body.dark-mode .dataTables_empty {
    color: var(--color-text-secondary) !important;
}

/* Row selected */
body.dark-mode table.dataTable tbody tr.selected {
    background-color: rgba(10, 132, 255, 0.2) !important;
}

body.dark-mode table.dataTable tbody tr.selected:hover {
    background-color: rgba(10, 132, 255, 0.25) !important;
}

body.dark-mode table.dataTable tbody tr.selected td {
    background-color: rgba(10, 132, 255, 0.2) !important;
    color: #f5f5f7;
}

/* Asegurar que no haya fondos blancos residuales */
body.dark-mode table.dataTable,
body.dark-mode table.dataTable tbody,
body.dark-mode table.dataTable tbody tr,
body.dark-mode table.dataTable tbody tr td {
    background-color: transparent !important;
}

/* Override específico para filas striped */
body.dark-mode table.dataTable.table-striped > tbody > tr.odd {
    background-color: rgba(28, 28, 30, 0.5) !important;
}

body.dark-mode table.dataTable.table-striped > tbody > tr.odd > td {
    background-color: rgba(28, 28, 30, 0.5) !important;
}

body.dark-mode table.dataTable.table-striped > tbody > tr.even {
    background-color: transparent !important;
}

body.dark-mode table.dataTable.table-striped > tbody > tr.even > td {
    background-color: transparent !important;
}

/* Hover state específico */
body.dark-mode table.dataTable.table-hover > tbody > tr:hover,
body.dark-mode table.dataTable.table-hover > tbody > tr:hover > td {
    background-color: rgba(10, 132, 255, 0.1) !important;
}


