:root {
    --header-height: 64px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --primary-color: #3b82f6;
    --secondary-color: #64748b;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- Layout Structure --- */
.admin-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1050;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

/* Sidebar Toggle */
.sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    transform: scale(1.05);
}

/* --- Sidebar --- */
.admin-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    transition: width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar styling for sidebar */
.admin-sidebar::-webkit-scrollbar {
    width: 5px;
}

.admin-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.admin-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Content Container */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 0.75rem;
    gap: 0.25rem;
}

/* navigation items - Scoped to sidebar */
.admin-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-sidebar .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-text-hover);
    padding-left: 1rem;
    /* Subtle indent effect */
}

.admin-sidebar .nav-item.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.admin-sidebar .nav-icon {
    font-size: 1.1rem;
    min-width: 24px;
    display: flex;
    justify-content: center;
}

.admin-sidebar .nav-text {
    flex: 1;
    font-weight: 500;
}

.admin-sidebar .nav-badge {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
}

/* Nav Groups (Collapsible) */
.nav-group {
    margin-bottom: 0.25rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.875rem;
    color: var(--sidebar-text);
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-group-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text-hover);
}

.nav-group-items {
    display: none;
    flex-direction: column;
    gap: 0.1rem;
    padding-left: 0.5rem;
    margin-top: 0.25rem;
}

.nav-group-items.show {
    display: flex;
}

.nav-arrow {
    transition: transform 0.2s;
}

.nav-arrow.rotate {
    transform: rotate(180deg);
}

.nav-section {
    padding: 1rem 0.875rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Main Content --- */
.admin-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 1.5rem;
    /* Reduced from 2rem */
    padding-top: 1rem;
    /* Tighter top spacing */
    transition: margin-left 0.3s ease;
    width: auto;
    overflow-x: hidden;
    /* Prevent content from spilling */
}

/* --- Collapsed State --- */
.admin-layout.sidebar-collapsed .admin-sidebar {
    width: var(--sidebar-collapsed-width);
}

.admin-layout.sidebar-collapsed .admin-main {
    margin-left: var(--sidebar-collapsed-width);
}

.admin-layout.sidebar-collapsed .nav-text,
.admin-layout.sidebar-collapsed .nav-arrow,
.admin-layout.sidebar-collapsed .nav-badge,
.admin-layout.sidebar-collapsed .nav-group-header .nav-text,
.admin-layout.sidebar-collapsed .nav-section {
    display: none;
}

.admin-layout.sidebar-collapsed .nav-group-header {
    justify-content: center;
    padding: 0.75rem;
}

.admin-layout.sidebar-collapsed .nav-group-items {
    padding-left: 0;
}

.admin-layout.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

.admin-layout.sidebar-collapsed .nav-icon {
    margin: 0;
}

/* --- Responsive (Mobile) --- */
/* --- Mobile Backdrop --- */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    /* Below sidebar (1040) but above header/content */
    /* backdrop-filter: blur(2px); */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- Responsive (Mobile) --- */
@media (max-width: 768px) {

    /* Hide sidebar by default on mobile */
    .admin-sidebar {
        left: -100%;
        /* Fully hidden */
        width: var(--sidebar-width) !important;
        /* Force full width when open */
    }

    /* When NOT collapsed (Open on mobile), show it */
    .admin-layout:not(.sidebar-collapsed) .admin-sidebar {
        left: 0;
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    }

    /* Ensure collapsed state on mobile is definitely hidden (override desktop mini-sidebar) */
    .admin-layout.sidebar-collapsed .admin-sidebar {
        width: var(--sidebar-width);
        /* Reset width definition */
        left: -100%;
        transform: none;
    }

    /* Main Content adjustments */
    .admin-main {
        margin-left: 0 !important;
        padding: 0.5rem;
        /* Minimal padding for mobile */
        width: 100%;
    }

    /* Reduce header padding to align */
    .admin-header {
        padding: 0 0.75rem;
    }

    /* Hide generic header parts if needed */
    .header-title {
        font-size: 1.1rem;
    }
}

/* --- Utilities --- */
.notification-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.5rem;
    border-radius: 50%;
}

.notification-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border-radius: 9px;
}

.profile-btn {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: 30px;
    transition: all 0.3s ease;
}

.profile-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.profile-name {
    font-weight: 500;
    color: #1e293b;
}

/* Dropdown menu simplified */
.profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem;
    z-index: 2000;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    color: #1e293b;
    text-decoration: none;
    border-radius: 0.25rem;
}

.menu-item:hover {
    background: #f1f5f9;
}

.menu-item.logout {
    color: #ef4444;
}