/* --- Global Variables & Theme --- */
:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-dark: #1e293b;
    --border-color: #e2e8f0;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg-main);
    color: var(--text-dark);
}

/* --- Global Navbar Layout --- */
.navbar {
    height: 65px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.nav-logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--sidebar-bg);
}

.nav-logo span {
    color: var(--accent);
}

.nav-status {
    font-size: 0.85rem;
    background: #bbf7d0;
    color: #166534;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}

/* Base structural flexbox container */
.main-container {
    display: flex;
    margin-top: 65px;
}

/* --- Common Sidebar Components --- */
.sidebar-brand {
    padding: 0 24px 12px 24px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.sidebar-search {
    padding: 0 16px 16px 16px;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 8px;
}

#sidebarSearch {
    width: 100%;
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f8fafc;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

#sidebarSearch:focus {
    border-color: var(--accent);
}

#sidebarSearch::placeholder {
    color: #64748b;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-divider {
    padding: 16px 24px 8px 24px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    font-weight: 600;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-menu li:not(.menu-divider):hover a {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-menu li.active a {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* --- Dynamic Workspace Elements --- */
.frame-wrapper {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

h1 {
    margin-top: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
}


/* ==========================================
   RESPONSIVE MEDIA QUERIES (Prevents Mobile Overlay)
   ========================================== */

/* 1. Desktop Layout Optimization (Screens wider than 768px) */
@media (min-width: 769px) {
    .sidebar {
        width: 260px;
        position: fixed;
        top: 65px;
        bottom: 0;
        left: 0;
        background: var(--sidebar-bg);
        padding: 24px 0;
        overflow-y: auto;
    }
    
    .content {
        margin-left: 260px; /* Shifts content frame past desktop sidebar */
        padding: 32px;
        min-height: calc(100vh - 65px);
        flex: 1;
    }

    .frame-wrapper {
        padding: 32px;
    }
}

/* 2. Mobile Layout Optimization (Screens 768px wide and below) */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column; /* Stack components into a column stream */
    }

    .sidebar {
        position: static; /* Let sidebar adapt to natural mobile scrolling height */
        width: 100%;       /* Fill full screen width */
        height: auto;
        padding: 16px 0;
        background: var(--sidebar-bg);
        border-bottom: 1px solid #1e293b;
    }

    .sidebar-search {
        padding: 0 24px 12px 24px;
    }

    .content {
        margin-left: 0;    /* Drops desktop margin so layout text is centered */
        padding: 16px;     /* Snugs layout closer to mobile border edges */
        width: 100%;
    }

    .frame-wrapper {
        padding: 20px;     /* Comfortable content bounds on screens */
    }
}/* --- Sidebar Toggle System --- */
.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--sidebar-bg);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: var(--bg-main);
}

/* Desktop Collapse State */
@media (min-width: 769px) {
    .sidebar {
        transition: transform 0.3s ease, width 0.3s ease;
    }
    .content {
        transition: margin-left 0.3s ease;
    }
    
    /* When sidebar is hidden on desktop */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-260px);
    }
    body.sidebar-collapsed .content {
        margin-left: 0;
    }
}

/* Mobile Slide-out Menu Overrides */
@media (max-width: 768px) {
    .toggle-btn {
        color: var(--text-dark);
    }

    .sidebar {
        position: fixed !important;
        top: 65px;
        left: 0;
        bottom: 0;
        width: 280px;
        height: calc(100vh - 65px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 99;
        border-bottom: none;
        border-right: 1px solid #1e293b;
    }

    /* When sidebar is pulled out on mobile */
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    
    /* Dark background overlay when mobile menu is active */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 65px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 98;
    }
}