/* Sidebar Menu */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Estado colapsado (Desktop) */
.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    padding: 1.5rem;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1.5rem 0;
}

.sidebar-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

/* Toggle Button (Desktop & Mobile) */
.sidebar-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(1.05);
}

/* Esconde toggle no mobile dentro do header, usamos o hamburger externo */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: none;
    }
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 1rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-item {
    margin-bottom: 0.5rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transform: translateX(4px);
}

.sidebar.collapsed .menu-link:hover {
    transform: none;
}

.menu-item.active .menu-link {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), transparent);
    color: #60a5fa;
    border-left: 3px solid #60a5fa;
}

.menu-icon {
    font-size: 1.25rem;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.menu-link:hover .menu-icon {
    transform: scale(1.1);
}

.menu-text {
    font-size: 0.95rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

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

.sidebar.collapsed .menu-link {
    justify-content: center;
    padding: 0.875rem 0;
}

.sidebar.collapsed .menu-item.active .menu-link {
    border-left: none;
    border-right: 3px solid #60a5fa;
    /* Move border to right when collapsed */
    background: rgba(59, 130, 246, 0.1);
}

/* Mobile Hamburger */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.3);
}

.mobile-menu-btn:hover {
    background: #273549;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.mobile-menu-btn:active {
    transform: scale(0.9);
    background: #60a5fa;
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: all 0.3s ease;
}

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

/* Layout Adjustment */
body {
    margin-left: 260px !important;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed {
    margin-left: 80px !important;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-profile-section {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: transparent;
    border-radius: 8px;
    border: none;
    margin-bottom: 0;
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-profile-section:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    padding: 0.75rem 0.5rem;
    gap: 1rem;
}

.sidebar.collapsed .user-profile-section {
    padding: 0;
    justify-content: center;
    width: 100%;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .user-info {
    display: none;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: capitalize;
}

/* Settings Button (Hidden, we use the profile section click) */
.profile-settings-btn {
    display: none;
}

/* Logout Button (Compact) */
.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.1);
    transition: all 0.2s ease;
    padding: 0;
}

.logout-btn .menu-text {
    display: none;
}

.logout-btn .menu-icon {
    font-size: 1.1rem;
    margin: 0;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    transform: scale(1.05);
}

.sidebar.collapsed .logout-btn {
    display: flex;
    justify-content: center;
    width: 32px;
    height: 32px;
}

/* Re-enable logout in collapsed if desired, but user asked for "one line". In collapsed mode (80px), one line fits avatar but maybe not both comfortably without looking cramped. */
/* Let's keep it clean: expanded = row loop. Collapsed = just avatar (click to open profile, logout inside profile modal? OR show logout below avatar in column) */
/* Wait, "1 line" implies horizontal. */

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        margin-left: 0 !important;
    }

    .mobile-menu-btn {
        display: flex !important;
        z-index: 1100 !important;
        position: fixed !important;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Wider sidebar on mobile for better touch */
        border-right: none;
        z-index: 1050;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar-overlay {
        z-index: 1040;
    }

    /* Mobile Header Styling */
    .sidebar-header {
        background: rgba(30, 41, 59, 0.95);
        padding: 1.5rem;
    }

    .sidebar-menu {
        padding: 1rem;
    }

    .menu-item {
        margin-bottom: 0.75rem;
    }

    .menu-link {
        padding: 1rem;
        /* Larger touch targets */
        background: rgba(255, 255, 255, 0.03);
        font-size: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .menu-link:active {
        background: rgba(255, 255, 255, 0.08);
        transform: scale(0.98);
    }

    .menu-icon {
        font-size: 1.5rem;
    }

    /* Ensure footer is visible on mobile */
    .sidebar-footer {
        padding: 1rem;
    }

    .user-profile-section {
        padding: 0.75rem;
        min-height: 60px;
    }

    .logout-btn {
        padding: 0.75rem;
        min-width: 48px;
        min-height: 48px;
    }
}