/* style.css - Estilos Globales Completos (Con Acordeón) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Colores Principales */
    --primary: #3C50E0;
    --primary-hover: #4F61E3;
    
    /* Fondos Modo Claro */
    --bg-body: #F1F5F9;
    --bg-panel: #FFFFFF;
    --bg-header: #FFFFFF;
    --bg-sidebar: #1C2434;
    
    /* Textos Modo Claro */
    --text-main: #1C2434;
    --text-body: #64748B;
    --text-light: #DEE4EE;
    
    /* Bordes y UI */
    --border-color: #E2E8F0;
    --input-bg: #FFFFFF;
    --input-border: #E2E8F0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    
    /* Dimensiones Fijas */
    --sidebar-width: 280px;
    --header-height: 80px; 
    --transition-speed: 0.3s;
}

/* --- MODO OSCURO --- */
body.dark-mode {
    --bg-body: #1A222C;
    --bg-panel: #24303F;
    --bg-header: #24303F;
    --bg-sidebar: #24303F; 
    --text-main: #FFFFFF;
    --text-body: #AEB7C0;
    --border-color: #2E3A47;
    --input-bg: #1D2A39;
    --input-border: #3D4D60;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* --- RESET Y BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { 
    background-color: var(--bg-body); 
    color: var(--text-body); 
    transition: background-color var(--transition-speed), color var(--transition-speed); 
    overflow-x: hidden; 
}
a { text-decoration: none; }
ul { list-style: none; }

/* --- LAYOUT PRINCIPAL --- */
.wrapper { display: flex; height: 100vh; overflow: hidden; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; position: relative; }

/* --- SIDEBAR (BARRA LATERAL) --- */
.sidebar { 
    width: var(--sidebar-width); 
    background-color: var(--bg-sidebar); 
    color: var(--text-light); 
    display: flex; 
    flex-direction: column; 
    transition: width var(--transition-speed); 
    z-index: 999; 
    
    /* Scroll oculto pero funcional */
    overflow-y: auto; 
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.sidebar::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.sidebar-header { padding: 2rem; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-text { font-size: 1.5rem; font-weight: 700; color: #fff; white-space: nowrap; }
.logo-icon { background: var(--primary); padding: 5px; border-radius: 5px; color: white; min-width: 32px; display: flex; justify-content: center; align-items: center; }

.sidebar-menu { padding: 1rem 2rem 4rem; }
.menu-group-title { font-size: 0.85rem; text-transform: uppercase; color: #8A99AF; margin-bottom: 1rem; margin-top: 1.5rem; font-weight: 600; }
.menu-item { margin-bottom: 0.5rem; }

/* Estilos de Enlaces del Menú */
.menu-link { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 10px 15px; 
    color: var(--text-light); 
    border-radius: 5px; 
    transition: 0.2s; 
    font-size: 1rem; 
    white-space: nowrap; 
    position: relative;
}
.menu-link:hover, .menu-link.active, .menu-link.active-parent { 
    background-color: #333A48; 
    color: #fff; 
}

/* --- ESTILOS ACORDEÓN (NUEVO) --- */
.menu-link.has-submenu {
    justify-content: space-between; /* Separa icono izq de flecha der */
    cursor: pointer;
}

.arrow-icon {
    transition: transform 0.3s ease;
    font-size: 0.9rem;
}

/* Rotar flecha al abrir */
.menu-link.active-parent .arrow-icon {
    transform: rotate(180deg);
}

/* Submenú (Hijos) */
.submenu {
    display: none; /* Oculto por defecto */
    list-style: none;
    padding: 0;
    background-color: rgba(0, 0, 0, 0.15); /* Fondo más oscuro */
    border-radius: 5px;
    margin-top: 5px;
    overflow: hidden;
}

.submenu.open {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.submenu .menu-link {
    padding-left: 45px; /* Sangría para jerarquía */
    font-size: 0.9rem;
    color: #8A99AF; /* Color un poco más apagado para hijos */
}
.submenu .menu-link:hover, .submenu .menu-link.active {
    color: #fff;
    background-color: transparent; /* Sin fondo en hover hijos, solo color */
}
.submenu .menu-link.active {
    color: var(--primary); /* Resaltar hijo activo */
    font-weight: 600;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- HEADER (BARRA SUPERIOR) --- */
.header { 
    background-color: var(--bg-header); 
    height: var(--header-height); 
    min-height: var(--header-height); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 2rem; 
    box-shadow: var(--shadow); 
    position: sticky; 
    top: 0; 
    z-index: 99;
    flex-shrink: 0; 
}

.header-left, .header-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

/* Espacio Central Banner */
.header-center {
    display: none; 
    flex-grow: 1; 
    justify-content: center; 
    align-items: center; 
    padding: 0 20px; 
    height: 100%;
}

.header-banner-placeholder {
    width: 100%;
    max-width: 468px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color); 
    border-radius: 5px;
    color: var(--text-body);
    font-size: 0.8rem;
}

/* Botones del Header */
.icon-btn, .toggle-btn { 
    background: transparent; 
    border: none; 
    cursor: pointer; 
    color: var(--text-body); 
    font-size: 1.2rem; 
    padding: 8px; 
    border-radius: 50%; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 40px; 
    height: 40px;
}
.icon-btn:hover, .toggle-btn:hover { background-color: var(--bg-body); color: var(--primary); }

/* --- COMPONENTES GLOBALES (CARDS, TABLAS, FORMS) --- */
.page-content { padding: 1rem 2rem 2rem 2rem; 
} 


.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin-bottom: 1.5rem; }

.card { background-color: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 5px; box-shadow: var(--shadow); overflow: hidden; }
.card-header { background-color: var(--bg-body); border-bottom: 1px solid var(--border-color); padding: 1rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 10px; }

/* Tablas Estilizadas */
.table-responsive { overflow-x: auto; }
.styled-table { width: 100%; border-collapse: collapse; text-align: center; }
.styled-table th, .styled-table td { padding: 12px; border: 1px solid var(--border-color); color: var(--text-main); }
.styled-table th { background-color: var(--bg-body); color: var(--text-body); font-weight: 600; font-size: 0.9rem; }
.styled-table td { font-weight: 500; font-size: 0.95rem; }

/* --- RESPONSIVE MEDIA QUERIES --- */
body.sidebar-collapsed .sidebar { width: 0; transform: translateX(-100%); }

@media(min-width: 992px) {
    .header-center { display: flex; } /* Banner visible en Desktop */
    
    body.sidebar-collapsed .sidebar { width: 90px; transform: translateX(0); }
    
    /* Cuando está colapsado, ocultamos textos y submenús complejos */
    body.sidebar-collapsed .logo-text, 
    body.sidebar-collapsed .menu-group-title, 
    body.sidebar-collapsed .menu-text,
    body.sidebar-collapsed .arrow-icon { display: none; }
    
    body.sidebar-collapsed .sidebar-header { justify-content: center; }
    body.sidebar-collapsed .menu-link { justify-content: center; padding: 15px; }
    
    /* Ajuste Acordeón Colapsado (Opcional: Ocultar submenús o mostrarlos como popup) */
    body.sidebar-collapsed .submenu { display: none !important; } 
}

@media(max-width: 991px) {
    .sidebar { position: fixed; height: 100%; left: 0; transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    
    /* En móvil, el banner header se oculta para dar espacio */
    .header-center { display: none; }
}