/* ==========================================
   Portal Sidebar Navigation Styles
   ========================================== */

/* Sidebar Container */
.portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--color-primary);
    color: white;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.portal-sidebar.collapsed {
    width: 70px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 70px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.sidebar-logo img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s;
}

.portal-sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

/* Collapse Toggle Button */
.sidebar-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-toggle i {
    transition: transform 0.3s;
}

.portal-sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Menu Items */
.sidebar-menu-item {
    margin: 0.25rem 0.5rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu-link.active {
    background: var(--color-secondary);
    color: white;
}

.sidebar-menu-link i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-menu-text {
    overflow: hidden;
    transition: opacity 0.3s;
}

.portal-sidebar.collapsed .sidebar-menu-text {
    opacity: 0;
    width: 0;
}

/* Menu Section Headers */
.sidebar-section {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
}

.portal-sidebar.collapsed .sidebar-section {
    opacity: 0;
    height: 0;
    padding: 0;
}

/* Submenu */
.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.open {
    max-height: 500px;
}

.sidebar-submenu .sidebar-menu-link {
    padding-left: 3rem;
    font-size: 0.9rem;
}

.portal-sidebar.collapsed .sidebar-submenu .sidebar-menu-link {
    padding-left: 1rem;
}

/* Submenu Toggle */
.sidebar-menu-link.has-submenu {
    cursor: pointer;
}

.sidebar-menu-link.has-submenu::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.sidebar-menu-link.has-submenu.open::after {
    transform: rotate(180deg);
}

.portal-sidebar.collapsed .sidebar-menu-link.has-submenu::after {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    transition: opacity 0.3s;
}

.portal-sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: capitalize;
}

/* Main Content Wrapper */
.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

.portal-content {
    flex: 1;
    margin-left: 280px;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

.sidebar-collapsed .portal-content {
    margin-left: 70px;
}

/* Mobile Hamburger Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--color-primary);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .portal-sidebar {
        transform: translateX(-100%);
    }

    .portal-sidebar.mobile-open {
        transform: translateX(0);
    }

    .portal-content {
        margin-left: 0 !important;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

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

    /* Adjust header for mobile menu button */
    body.has-sidebar header {
        padding-left: 70px;
    }
}

/* Tooltip for collapsed sidebar */
.portal-sidebar.collapsed .sidebar-menu-link {
    position: relative;
}

.portal-sidebar.collapsed .sidebar-menu-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    white-space: nowrap;
    margin-left: 10px;
    font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1001;
}

.portal-sidebar.collapsed .sidebar-menu-link.has-submenu:hover::after {
    content: none;
}

/* Badge for counts */
.sidebar-badge {
    background: var(--color-accent);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    margin-left: auto;
}

.portal-sidebar.collapsed .sidebar-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 0.1rem 0.3rem;
}

/* Logout link special styling */
.sidebar-menu-link.logout-link {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-menu-link.logout-link:hover {
    background: rgba(220, 20, 60, 0.2);
    color: #ff6b6b;
}

/* Scrollbar styling for sidebar nav */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
