:root {
    --nav-width: 260px;
    --nav-collapsed-width: 80px;
    --transition-speed: 0.25s;
    --transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
                /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
}
/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #2a2e34;      /* Gunmetal grey for cards, nav */
    --bg-secondary: #3c424a;    /* Lighter grey for hovers, inputs */
    --bg-tertiary: #181a1b;      /* Very dark grey for main background */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #4a5058;    /* A subtle border color for the new theme */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-speed) var(--transition-ease),
                color var(--transition-speed) var(--transition-ease);
    padding-top: 56px; /* Space for the fixed header */
}
/* Fixed Header */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}
.header-container {
    height: 100%;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.mobile-menu-toggle {
    display: none; /* Hidden by default, shown on mobile via media query */
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}
.mobile-menu-toggle:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}
.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 24px;
}
.search-bar {
    position: relative;
    width: 100%;
}
.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}
.search-bar input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 40px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}
.search-bar input:focus {
    border-color: var(--accent);
    background-color: var(--bg-primary);
}
.search-bar input::placeholder {
    color: var(--text-tertiary);
}
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-icon-button {
    position: relative;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}
.header-icon-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Expand User Drawer Button */
.expand-user-drawer-button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    color: var(--text-secondary);
}
.expand-user-drawer-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.expand-user-drawer-button.active {
    background-color: var(--bg-secondary);
    color: var(--accent);
}
.expand-user-drawer-button svg {
    width: 20px;
    height: 20px;
}
/* User Drawer */
.user-drawer {
    position: fixed;
    top: 56px;
    right: 16px;
    width: 280px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 99;
}
.user-drawer.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(8px);
}
.drawer-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}
.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.drawer-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.drawer-user-details h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.drawer-user-details p {
    font-size: 12px;
    color: var(--text-secondary);
}
.drawer-nav {
    padding: 8px;
}
.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}
.drawer-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.drawer-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    z-index: 98;
    display: none;
}
.drawer-overlay.active {
    display: block;
}
/* Main Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}
/* Flex Navigation */
.flex-nav {
    width: var(--nav-width);
    background-color: var(--bg-primary);
    transition: width var(--transition-speed) var(--transition-ease), left var(--transition-speed) var(--transition-ease);
    position: fixed;
    top: 56px; /* Adjusted to start below the fixed header */
    left: 0;
    height: calc(100vh - 56px); /* Adjusted height to account for the fixed header */
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    z-index: 90;
    overflow-y: auto;
}
.flex-nav.collapsed {
    width: var(--nav-collapsed-width);
}
/* Nav Header */
.nav-header {
    height: 56px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.nav-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-logo-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed) var(--transition-ease);
    overflow: hidden;
}
.collapsed .nav-logo-text {
    opacity: 0;
    width: 0;
}
/* THE FLEX NAV COLLAPSE BUTTON - Enhanced Design */
.flex-nav-collapse-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) var(--transition-ease);
    box-shadow: var(--shadow-sm);
    z-index: 20;
    padding: 0;
    outline: none;
}
.flex-nav-collapse-button:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-50%) scale(1.1);
}
.flex-nav-collapse-button:active {
    transform: translateY(-50%) scale(0.95);
}
/* Button Icon - Double Arrow */
.flex-nav-collapse-button svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-secondary);
    stroke-width: 2.5;
    transition: all var(--transition-speed) var(--transition-ease);
    transform: rotate(180deg);
}
.collapsed .flex-nav-collapse-button svg {
    transform: rotate(0deg);
}
.flex-nav-collapse-button:hover svg {
    stroke: var(--accent);
}
/* Nav Menu */
.nav-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.nav-section {
    margin-bottom: 24px;
}
.nav-section-title {
    padding: 8px 24px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    transition: opacity var(--transition-speed) var(--transition-ease);
    overflow: hidden;
    white-space: nowrap;
}
.collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0 24px;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    margin: 2px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-speed) var(--transition-ease);
    gap: 12px;
    position: relative;
    font-size: 14px;
    font-weight: 500;
}
.nav-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.nav-item.active {
    background-color: var(--bg-secondary);
    color: var(--accent);
}
.nav-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed) var(--transition-ease);
    overflow: hidden;
}
.collapsed .nav-item {
    padding: 10px;
    margin: 2px 8px;
    justify-content: center;
}
.collapsed .nav-item-text {
    opacity: 0;
    width: 0;
}
/* Tooltip for collapsed state */
.tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}
.tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-right-color: var(--text-primary);
}
.collapsed .nav-item:hover .tooltip {
    opacity: 1;
}
/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    transition: margin-left var(--transition-speed) var(--transition-ease);
    margin-left: var(--nav-width); /* Pushed by the fixed nav */
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 24px;
    align-items: start;
}
.main-column-left {
    max-width: 1200px; /* Keep max-width on the main content flow */
}
.main-column-right {
    position: sticky;
    top: 80px; /* 56px for fixed header + 24px padding */
}
.flex-nav.collapsed + .main-content {
    margin-left: var(--nav-collapsed-width); /* Adjust margin when nav is collapsed */
}
.content-header {
    margin-bottom: 32px;
}
.content-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.content-header p {
    color: var(--text-secondary);
    font-size: 16px;
}
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}
.content-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    transition: all var(--transition-speed) var(--transition-ease);
    box-shadow: var(--shadow-sm);
}
.content-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.content-card h3 {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.content-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex; /* Show hamburger menu on mobile */
    }
    .header-logo {
        font-size: 14px; /* Smaller logo text on mobile */
    }
    .header-logo svg {
        width: 20px;
        height: 20px;
    }
    .header-center {
        margin: 0 16px; /* Adjust margin for search bar */
    }
    .flex-nav {
        width: var(--nav-width);
        left: calc(-1 * var(--nav-width)); /* Hidden off-canvas by default */
        box-shadow: var(--shadow-md); /* Add shadow when open */
        top: 0; /* On mobile, nav starts from top of viewport */
        height: 100vh; /* On mobile, nav takes full viewport height */
    }
    .flex-nav.mobile-open {
        left: 0; /* Slide in when open */
    }
    .flex-nav-collapse-button {
        display: none; /* Hide collapse button on mobile */
    }
    .main-content {
        margin-left: 0; /* No margin-left on mobile */
        width: 100%; /* Take full width */
        padding: 24px; /* Adjust padding for mobile */
        display: block; /* Stack columns on mobile */
    }
    .main-column-right {
        margin-top: 24px; /* Add space between stacked columns */
    }
    .collapsed .nav-item .tooltip {
        opacity: 0; /* Hide tooltips on mobile */
    }
}
