/* ==========================================================================
   Base & CSS Variables (Design Tokens)
   ========================================================================== */
   :root {
    --hue-primary: 220;
    --color-primary: hsl(var(--hue-primary), 80%, 55%);
    --color-primary-hover: hsl(var(--hue-primary), 80%, 45%);
    --color-primary-light: hsl(var(--hue-primary), 80%, 95%);
    
    --hue-success: 152;
    --color-success: hsl(var(--hue-success), 68%, 45%);
    --color-success-light: hsl(var(--hue-success), 68%, 95%);
    
    --hue-warning: 40;
    --color-warning: hsl(var(--hue-warning), 90%, 55%);
    --color-warning-light: hsl(var(--hue-warning), 90%, 95%);
    
    --hue-danger: 0;
    --color-danger: hsl(var(--hue-danger), 75%, 50%);
    --color-danger-light: hsl(var(--hue-danger), 75%, 95%);
    
    --bg-body: hsl(220, 20%, 97%);
    --bg-surface: hsl(0, 0%, 100%);
    --bg-sidebar: hsl(220, 25%, 15%);
    --bg-elem: hsl(220, 15%, 93%);
    --bg-elem-hover: hsl(220, 15%, 88%);
    
    --text-main: hsl(220, 30%, 15%);
    --text-muted: hsl(220, 15%, 45%);
    --text-inverse: hsl(0, 0%, 100%);
    
    --border-color: hsl(220, 15%, 90%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: hsl(220, 20%, 8%);
    --bg-surface: hsl(220, 20%, 12%);
    --bg-sidebar: hsl(220, 25%, 10%);
    --bg-elem: hsl(220, 20%, 16%);
    --bg-elem-hover: hsl(220, 20%, 22%);
    --text-main: hsl(220, 15%, 90%);
    --text-muted: hsl(220, 15%, 65%);
    --border-color: hsl(220, 20%, 18%);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4);
    --color-primary-light: hsl(var(--hue-primary), 40%, 20%);
    --color-success-light: hsl(var(--hue-success), 40%, 15%);
    --color-warning-light: hsl(var(--hue-warning), 40%, 15%);
    --color-danger-light: hsl(var(--hue-danger), 40%, 15%);
}

/* ==========================================================================
   Reset & Document
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden; /* Proteger siempre de salidas horizontales */
    width: 100%;
    position: relative;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 15px;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-hover); }

/* ==========================================================================
   Layout (Sidebar + Main)
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    z-index: 1000; /* Z-index muy alto */
    transition: transform var(--transition-normal);
}

.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
}

.sidebar-header { height: 70px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.logo-box { display: flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.03em; }
.logo-box i { color: var(--color-primary); font-size: 1.5rem; }


.close-sidebar-btn { 
    display: none !important; /* !important para que .icon-btn no le gane */
}

.sidebar-nav { flex: 1; padding: 24px 16px; overflow-y: auto; }
.nav-section { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255, 255, 255, 0.4); font-weight: 600; margin-bottom: 12px; padding-left: 12px; }
.mt-4 { margin-top: 32px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: rgba(255, 255, 255, 0.7); border-radius: var(--radius-sm); margin-bottom: 4px; font-weight: 500; }
.nav-item i { font-size: 1.25rem; opacity: 0.7; transition: opacity var(--transition-fast); }
.nav-item:hover { background-color: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item:hover i { opacity: 1; }
.nav-item.active { background-color: var(--color-primary); color: #fff; }
.nav-item.active i { opacity: 1; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255, 255, 255, 0.05); display: flex; align-items: center; justify-content: space-between; }
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; background: linear-gradient(135deg, var(--color-primary), hsl(250, 80%, 60%)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.user-info .details { display: flex; flex-direction: column; }
.user-info .name { font-weight: 500; font-size: 0.9rem; }
.user-info .role { font-size: 0.75rem; color: rgba(255, 255, 255, 0.5); }
.logout-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.5); }
.logout-btn:hover { background-color: rgba(255, 0, 0, 0.1); color: #ff5252; }

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

.top-header {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky; top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    background-color: rgba(var(--bg-surface), 0.8);
}

.search-bar-global {
    display: flex; align-items: center; gap: 12px;
    background-color: var(--bg-elem);
    padding: 8px 16px;
    border-radius: 20px;
    width: 400px;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}
.search-bar-global:focus-within { border-color: var(--color-primary); background-color: var(--bg-surface); box-shadow: 0 0 0 3px rgba(var(--color-primary), 0.1); }
.search-bar-global i { color: var(--text-muted); font-size: 1.1rem; }
.search-bar-global input { border: none; background: transparent; outline: none; width: 100%; color: var(--text-main); font-size: 0.95rem; }

.header-actions { display: flex; align-items: center; gap: 16px; }

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%; border: none;
    background-color: var(--bg-elem); color: var(--text-main);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer; transition: all var(--transition-fast);
}
.icon-btn:hover { background-color: var(--bg-elem-hover); color: var(--color-primary); }

.content-wrapper { padding: 32px; flex: 1; }

/* ==========================================================================
   Public Layout (Login)
   ========================================================================== */
.public-content { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top right, var(--color-primary-light), var(--bg-body) 60%); padding: 16px; }
.login-card { background-color: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 48px; width: 100%; max-width: 440px; border: 1px solid var(--border-color); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; }
.login-header p { color: var(--text-muted); font-size: 0.95rem; }

/* ==========================================================================
   Forms & Buttons
   ========================================================================== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.9rem; color: var(--text-main); }
.form-control { width: 100%; padding: 12px 16px; border: 1px solid var(--border-color); background-color: var(--bg-body); color: var(--text-main); border-radius: var(--radius-md); font-size: 0.95rem; transition: all var(--transition-fast); font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(var(--color-primary), 0.1); }
textarea.form-control { resize: vertical; min-height: 100px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-md); font-weight: 600; font-size: 0.95rem; cursor: pointer; border: none; transition: all var(--transition-fast); font-family: inherit; text-align: center; }
.btn-primary { background-color: var(--color-primary); color: #fff; }
/* .btn-primary:hover { background-color: var(--color-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(var(--hue-primary), 80%, 50%, 0.3); } */
.btn-primary:hover {
    background-color: var(--color-primary-dark, #004494); /* Un azul m��s oscuro, por ejemplo */
    color: #ffffff !important; /* MANTIENE el texto blanco al hacer hover */
}
.btn-block { width: 100%; }
.btn-subtle { background-color: var(--bg-elem); color: var(--text-main); }
.btn-subtle:hover { background-color: var(--bg-elem-hover); }

/* ==========================================================================
   Micro Animations & Glassmorphism
   ========================================================================== */
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 2000; animation: fadeIn var(--transition-fast); }
.modal-overlay.hidden { display: none; }
.modal-card { background-color: var(--bg-surface); border-radius: var(--radius-lg); width: 90%; max-width: 600px; box-shadow: var(--shadow-lg); border: 1px solid var(--border-color); animation: slideDown var(--transition-fast); max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 1.25rem; margin: 0; }
.close-modal { background: transparent; border: none; cursor: pointer; font-size: 1.25rem; color: var(--text-muted); transition: color var(--transition-fast); }
.close-modal:hover { color: var(--color-danger); }
.modal-body { padding: 24px; }

/* ==========================================================================
   Toasts (Notifications)
   ========================================================================== */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 3000; }
.toast { background-color: var(--bg-surface); border-left: 4px solid var(--color-primary); padding: 16px 20px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 12px; animation: slideDown var(--transition-fast); max-width: 350px; border-right: 1px solid var(--border-color); border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }

/* Utility Classes */
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.card { background-color: var(--bg-surface); border-radius: var(--radius-md); border: 1px solid var(--border-color); padding: 24px; }

/* ==========================================================================
   EL SALVADOR: MOBILE Y RESPONSIVE FIXES
   ========================================================================== */

/* TABLETS Y PANTALLAS PEQUEÑAS (MENÚ LATERAL) */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .close-sidebar-btn {
        display: block !important;
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-menu-toggle {
        display: flex !important;
    }
    .top-header {
        padding: 0 16px;
    }
}

/* SMARTPHONES (COLAPSO DE GRID DEL DASHBOARD) */
@media (max-width: 768px) {
    .content-wrapper {
        padding: 16px;
        width: 100vw;
        overflow-x: hidden;
    }
    
    /* 🔴 LA BALA DE PLATA: Obliga a cualquier div con estilos de grid (ej: Dashboard) a ser de 1 sola columna en móvil */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    /* Ocultar el buscador gigante en móviles pequeños para que quepa el header */
    .search-bar-global {
        display: none !important;
    }

    /* Títulos y botones superiores */
    .header-with-actions {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 16px;
    }
    .header-with-actions > div {
        width: 100%;
    }
    .header-with-actions .btn {
        width: 100%;
    }

    /* Proteger tablas de administración */
    .card {
        overflow-x: auto;
        padding: 16px;
        width: 100%;
    }
    table {
        min-width: 600px;
    }

    /* Ajuste de Modales */
    .modal-card, .modal-box {
        width: 95%;
        margin: 10px;
        padding: 16px;
    }
    
    /* Toasts centrados */
    .toast-container {
        bottom: 16px; right: 16px; left: 16px;
    }
    .toast {
        max-width: 100%; width: 100%;
    }
    
    /* Login en Móvil */
    .login-card {
        padding: 24px;
    }
}
/* Restaurar formato de texto enriquecido (TinyMCE/Quill) */
.formato-html-limpio ul {
    list-style-type: disc !important;
    padding-left: 2.5rem !important;
    margin-bottom: 1rem;
}

.formato-html-limpio ol {
    list-style-type: decimal !important;
    padding-left: 2.5rem !important;
    margin-bottom: 1rem;
}

.formato-html-limpio li {
    margin-bottom: 0.5rem;
}

.formato-html-limpio p {
    margin-bottom: 1rem;
}

.formato-html-limpio strong, .formato-html-limpio b {
    font-weight: 700;
} 