/* ============================================
   SIDEBAR - ESTILOS COMPLETOS
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #1a1a2e;
    --sidebar-text-soft: #64748b;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #ede7f6;
    --sidebar-active-text: #6c5b7b;
    --sidebar-plum: #6c5b7b;
    --sidebar-plum-soft: #ede7f6;
    --sidebar-coral: #e8734f;
    --sidebar-coral-soft: #fde8e0;
    --sidebar-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ============================================
   SIDEBAR PRINCIPAL
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: var(--sidebar-shadow);
}

/* Scrollbar personalizado */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-text-soft);
}

/* ============================================
   BRAND / LOGO
   ============================================ */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 14px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--sidebar-plum);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    font-family: 'Baloo 2', sans-serif;
    flex-shrink: 0;
}

.brand-text {
    font-family: 'Baloo 2', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-text);
    line-height: 1.2;
}

.brand-sub {
    font-size: 11px;
    color: var(--sidebar-text-soft);
}

/* ============================================
   NAVEGACIÓN
   ============================================ */
.sidebar nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 8px;
}

/* Títulos de sección */
.nav-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--sidebar-text-soft);
    padding: 10px 8px 4px 8px;
    margin-top: 2px;
}

/* Ítems de navegación */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-plum);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Contador (badge) */
.nav-item .count {
    margin-left: auto;
    background: var(--sidebar-coral);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    line-height: 1.6;
}

.nav-item .count.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Ítem de peligro (logout) */
.nav-item.nav-item-danger {
    color: var(--sidebar-coral);
    margin-top: 4px;
    border-top: 1px solid var(--sidebar-border);
    padding-top: 14px;
}

.nav-item.nav-item-danger:hover {
    background: var(--sidebar-coral-soft);
    color: var(--sidebar-coral);
}

/* ============================================
   FOOTER DEL SIDEBAR
   ============================================ */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
    flex-shrink: 0;
}

/* Avatar del usuario */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--sidebar-plum-soft);
    color: var(--sidebar-plum);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.who-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--sidebar-text);
    line-height: 1.2;
}

.who-role {
    font-size: 11px;
    color: var(--sidebar-text-soft);
}

/* Botón de logout en footer */
.logout-btn {
    margin-left: auto;
    padding: 6px;
    border-radius: 6px;
    color: var(--sidebar-text-soft);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    background: var(--sidebar-coral-soft);
    color: var(--sidebar-coral);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    display: block;
}

/* ============================================
   SIDEBAR OVERLAY (móvil)
   ============================================ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   RESPONSIVE - TABLET Y MÓVIL
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--sidebar-shadow);
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 270px;
        padding: 16px 12px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .brand-text {
        font-size: 15px;
    }

    .nav-item {
        font-size: 13px;
        padding: 8px 10px;
    }

    .nav-title {
        font-size: 9px;
        padding: 8px 6px 2px 6px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 250px;
        padding: 12px 10px;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .brand-text {
        font-size: 14px;
    }

    .brand-sub {
        font-size: 10px;
    }

    .nav-item {
        font-size: 12.5px;
        padding: 7px 10px;
        gap: 10px;
    }

    .nav-item svg {
        width: 16px;
        height: 16px;
    }

    .nav-title {
        font-size: 9px;
        padding: 6px 4px 2px 4px;
    }

    .avatar {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .who-name {
        font-size: 12px;
    }

    .who-role {
        font-size: 10px;
    }

    .sidebar-footer {
        padding-top: 10px;
        gap: 8px;
    }
}

/* ============================================
   UTILIDADES DEL SIDEBAR
   ============================================ */
/* Ocultar sidebar en ciertas páginas */
.sidebar.hidden {
    display: none;
}

/* Sidebar colapsado (solo íconos) */
.sidebar.collapsed {
    width: 68px;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .nav-title,
.sidebar.collapsed .nav-item span:not(.count),
.sidebar.collapsed .who-name,
.sidebar.collapsed .who-role,
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 9px;
}

.sidebar.collapsed .nav-item .count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    font-size: 8px;
    padding: 0 5px;
}

.sidebar.collapsed .brand {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.sidebar.collapsed .avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

/* ============================================
   TEMA OSCURO (opcional)
   ============================================ */
.dark-theme .sidebar {
    --sidebar-bg: #1a1a2e;
    --sidebar-border: #2a2a4a;
    --sidebar-text: #e2e8f0;
    --sidebar-text-soft: #94a3b8;
    --sidebar-hover: #2a2a4a;
    --sidebar-active: #2a2a4a;
    --sidebar-active-text: #a78bfa;
    --sidebar-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.dark-theme .brand-mark {
    background: #6c5b7b;
}

.dark-theme .nav-item .count {
    background: #e8734f;
}

.dark-theme .avatar {
    background: #2a2a4a;
    color: #a78bfa;
}