/* Modern Sidebar Layout - Light Theme */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #334155;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #e2e8f0;
    --sidebar-accent: #2563eb;
    --topbar-height: 60px;
}

/* Responsive sidebar width adjustments */
@media (max-width: 1400px) {
    :root {
        --sidebar-width: 260px;
    }
}
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 240px;
    }
}
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 210px;
    }
}
@media (max-width: 1000px) {
    :root {
        /* Mobile overlay width */
        --sidebar-width: 250px; 
    }
}

body.authenticated-layout {
    /* Mover el contenido a la derecha en escritorio */
    padding-top: var(--topbar-height);
    transition: padding-left 0.3s ease;
}

@media (min-width: 1001px) {
    body.authenticated-layout {
        padding-left: var(--sidebar-width);
        /* Keep padding-top on desktop so content doesn't go under the topbar */
        padding-top: var(--topbar-height);
    }
    
    /* Desktop collapsed state */
    body.sidebar-collapsed {
        padding-left: 0 !important;
    }
    body.sidebar-collapsed .prd-sidebar {
        transform: translateX(-100%);
    }
}

/* Toggle button - always inside the topbar, not fixed independently */
.prd-sidebar-toggle {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    background: transparent;
    color: var(--sidebar-text);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: background 0.2s;
}
.prd-sidebar-toggle:hover {
    background: var(--sidebar-hover);
}

/* The toggle is always visible now, we removed the desktop display: none */

/* Top bar - always visible at all sizes */
.prd-mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    padding: 0 15px 0 60px; /* 60px = espacio para el toggle absoluto */
    z-index: 1040;
    gap: 10px;
}
/* Topbar is always visible */
.prd-mobile-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: #111827;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sidebar Styles */
.prd-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1045;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 15px rgba(0,0,0,0.05);
    border-right: 1px solid #e2e8f0;
}

/* Collapsed state on mobile - full height, no gap at top */
@media (max-width: 1000px) {
    .prd-sidebar {
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1046; /* por encima del topbar en móvil */
    }
    .prd-sidebar.show {
        transform: translateX(0);
    }
}

/* Sidebar Header */
.prd-sidebar-header {
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.prd-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.prd-user-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #0f172a;
}

.prd-user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--sidebar-accent), #60a5fa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.prd-user-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.prd-bell-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}
.prd-bell-btn:hover {
    background: #f1f5f9;
}
.prd-bell-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.6rem;
}

.prd-admin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.prd-admin-btn:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

/* Sidebar Navigation */
.prd-sidebar-nav {
    padding: 15px 0;
    flex: 1;
}

.prd-sidebar-nav .nav-item {
    margin-bottom: 2px;
    padding: 0 12px;
}

.prd-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: #475569;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.prd-sidebar-link i.bi {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.prd-sidebar-link:hover, .prd-sidebar-link[aria-expanded="true"] {
    background: var(--sidebar-hover);
    color: #0f172a;
}

.prd-sidebar-link.active {
    background: #eff6ff;
    color: var(--sidebar-accent);
}

.prd-sidebar-link .arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.prd-sidebar-link[aria-expanded="true"] .arrow {
    transform: rotate(180deg);
}

/* Submenus */
.prd-submenu {
    padding-left: 0;
    margin-top: 4px;
    margin-bottom: 4px;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

.prd-submenu li a {
    display: flex;
    align-items: center;
    padding: 9px 12px 9px 16px;
    color: #475569;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s, background 0.2s;
    border-radius: 6px;
    margin: 2px 6px;
}

.prd-submenu li a .flex-1 {
    flex: 1;
    min-width: 0;
}

.prd-submenu li a:hover, .prd-submenu li a.active {
    color: var(--sidebar-accent);
    background: #eff6ff;
    font-weight: 500;
}

/* Overlay for mobile */
.prd-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1044;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.prd-sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Sidebar Footer */
.prd-sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.prd-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ef4444;
    text-decoration: none;
    font-weight: 500;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.prd-logout-btn:hover {
    background: #fef2f2;
}

/* Responsive typography and padding */
@media (max-width: 991.98px) {
    .prd-sidebar-header {
        padding: 15px;
    }
    .prd-user-name {
        font-size: 0.95rem;
    }
    .prd-sidebar-link {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    .prd-sidebar-link i.bi {
        font-size: 1.1rem;
        width: 20px;
    }
    .prd-admin-btn {
        font-size: 0.85rem;
        padding: 8px;
    }
    .prd-submenu li a {
        padding: 8px 10px 8px 40px;
        font-size: 0.85rem;
    }
    .prd-sidebar-footer {
        padding: 10px 15px;
    }
    .prd-logout-btn {
        font-size: 0.9rem;
        padding: 8px;
    }
}
