/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    background: linear-gradient(180deg, #111827 0%, #0c0f1a 100%);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-sidebar);
    width: var(--sidebar-width);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-normal);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .icon {
    color: var(--primary-400);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav-group {
    margin-bottom: 0.5rem;
}

.app-layout.sidebar-collapsed .sidebar-nav-group {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.app-layout.sidebar-collapsed .sidebar-nav-group:last-of-type {
    border-bottom: none;
}

.sidebar-nav-group-title {
    display: block;
    padding: 0.5rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-link .icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.sidebar-nav-link .link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}

.sidebar-nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-link.active {
    color: #fff;
    background: var(--primary-600);
}

.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-400);
    border-radius: 0 2px 2px 0;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.75rem;
    flex-shrink: 0;
}

.sidebar-logout-form {
    display: block;
    max-width: none;
    gap: 0;
    width: 100%;
}

/* Sidebar logout button — mirrors .sidebar-collapse-btn but red */
.sidebar-footer button.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: none;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
    gap: 0.5rem;
    font-family: inherit;
    font-size: inherit;
}

.sidebar-footer button.sidebar-logout-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
}

.sidebar-footer button.sidebar-logout-btn .link-text {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}

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

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user .link-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar collapse toggle */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.25rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
}

.sidebar-collapse-btn:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-collapse-btn .icon {
    transition: transform var(--transition-normal);
}

.sidebar-collapsed .sidebar-collapse-btn .icon {
    transform: rotate(180deg);
}

/* Collapsed sidebar state */
.app-layout.sidebar-collapsed .sidebar-nav-group-title {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar-brand .link-text,
.app-layout.sidebar-collapsed .sidebar-nav-link .link-text,
.app-layout.sidebar-collapsed .sidebar-user .link-text,
.app-layout.sidebar-collapsed .sidebar-logout-btn .link-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 0.65rem;
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1.25rem 0.5rem;
}

.sidebar-collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.25rem;
}

.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 0.25rem;
}

.sidebar-collapsed .sidebar-nav-link.active::before {
    display: none;
}

.app-layout.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.app-layout.sidebar-collapsed main {
    margin-left: var(--sidebar-collapsed-width);
}

.app-layout.sidebar-collapsed .topbar {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sidebar) - 1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

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


/* ============================================
   Responsive - Sidebar Mobile Drawer
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        transition: left var(--transition-normal), width var(--transition-normal);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .topbar,
    .app-layout main {
        margin-left: 0;
        width: 100%;
    }

    .hamburger {
        display: flex;
    }

    .topbar-user span {
        display: none;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .topbar-search {
        max-width: none;
    }
}

@media (max-width: 600px) {
    form {
        max-width: 100%;
    }

    .modal {
        padding: 1.25rem;
        width: 95%;
    }

    .modal h3 {
        font-size: 1rem;
    }

    .modal p {
        font-size: 0.9rem;
    }
}

