/* ===================================
   Estilos del Sidebar - CoverSur Admin (Sobrio & Formal)
   =================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background-color: #0f172a; /* Deep Slate 900 - Sobrio y formal */
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-brand {
    text-align: left;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #ffffff;
    text-transform: uppercase;
}

.sidebar-header p {
    font-size: 11px;
    color: #64748b;
    margin: 4px 0 0 0;
    font-weight: 500;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: #ffffff;
}

/* Cabecera Móvil y Overlay */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.mobile-logo {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 998;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 12px 0;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu li {
    margin: 0;
    padding: 2px 12px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #94a3b8; /* Slate 400 */
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-menu a:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar-menu a.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-weight: 600;
}

.sidebar-menu .icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #64748b; /* Muted icon */
    transition: color 0.2s ease-in-out;
}

.sidebar-menu a:hover .icon,
.sidebar-menu a.active .icon {
    color: #ffffff;
}

.sidebar-menu .icon svg {
    width: 18px;
    height: 18px;
}

/* Elemento de cerrar sesión */
.logout-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #f87171; /* Soft red */
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.logout-link .icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #ef4444;
}

.logout-link .icon svg {
    width: 16px;
    height: 16px;
}

.logout-link:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.logout-link:hover .icon {
    color: #fca5a5;
}

/* Footer de información de usuario */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #0b0f19;
    font-size: 12px;
}

.sidebar-footer p {
    margin: 0;
    line-height: 1.4;
}

.sidebar-footer p:first-child {
    color: #64748b;
    font-size: 11px;
    margin-bottom: 2px;
}

.sidebar-footer p:nth-child(2) {
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-footer p:nth-child(3) {
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Ajuste del main-content cuando hay sidebar */
.main-content {
    margin-left: 250px;
    transition: margin-left 0.3s ease;
}

/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        z-index: 1001; /* Por encima de la cabecera móvil y overlay */
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
    }

    .sidebar-close {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px 16px !important;
        padding-top: 80px !important; /* Margen para no quedar oculto por la cabecera móvil */
    }
}

/* ===================================
   Estilos de Dropdowns / Submenús
   =================================== */

.sidebar-dropdown {
    position: relative;
}

.sidebar-dropdown-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    color: #94a3b8; /* Slate 400 */
    background: none;
    border: none;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
}

.sidebar-dropdown-toggle:focus {
    outline: none;
}

.sidebar-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar-dropdown-toggle:hover .icon {
    color: #ffffff;
}

.sidebar-dropdown-toggle .arrow {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: #64748b;
}

.sidebar-dropdown-toggle:hover .arrow {
    color: #ffffff;
}

/* Flecha hacia abajo cuando está abierto */
.sidebar-dropdown.open .sidebar-dropdown-toggle .arrow {
    transform: rotate(90deg);
    color: #ffffff;
}

.sidebar-dropdown.open .sidebar-dropdown-toggle {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-dropdown.open .sidebar-dropdown-toggle .icon {
    color: #ffffff;
}

/* Si tiene un sub-elemento activo */
.sidebar-dropdown.has-active-child .sidebar-dropdown-toggle {
    color: #ffffff;
    font-weight: 600;
}

.sidebar-dropdown.has-active-child .sidebar-dropdown-toggle .icon {
    color: #ffffff;
}

/* Submenú */
.sidebar-submenu {
    list-style: none;
    padding: 4px 0 4px 12px;
    margin: 4px 12px 8px 24px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: none; /* Oculto por defecto, manejado por jQuery */
}

/* Mostrar si ya viene abierto por PHP (ej. recarga de página) */
.sidebar-dropdown.open .sidebar-submenu {
    display: block;
}

.sidebar-submenu li {
    margin: 0;
    padding: 1px 0;
}

.sidebar-submenu a {
    padding: 8px 12px;
    font-size: 13px;
    color: #94a3b8;
    background-color: transparent;
    display: flex;
    align-items: center;
    border-radius: 4px;
}

.sidebar-submenu a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-submenu a.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

/* ===================================
   Navbar Superior Global (Premium)
   =================================== */
.global-top-navbar {
    position: fixed;
    top: 0;
    left: 250px; /* Ancho del sidebar */
    right: 0;
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: left 0.3s ease;
}

.navbar-left {
    display: flex;
    align-items: center;
}

.navbar-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-profile-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(37,99,235,0.15);
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.btn-navbar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #fee2e2;
    background-color: #fef2f2;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-navbar-logout:hover {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 6px -1px rgba(239,68,68,0.2);
}

/* Ajuste general del content-area para todas las vistas */
.content-area, .main-content {
    padding-top: 110px !important; /* Desplaza el contenido hacia abajo para que no lo tape la barra */
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    .global-top-navbar {
        left: 0;
        padding: 0 20px;
        height: 60px;
        top: 60px; /* Abajo de la cabecera móvil de V1 */
    }
    
    .navbar-section-title {
        display: none; /* Ocultar título en móviles para más espacio */
    }
    
    .content-area, .main-content {
        padding-top: 140px !important; /* Más padding en móviles para acomodar ambas barras superiores */
    }
}

