/* ==========================================================================
   1. CORE LAYOUT & VARIABLES
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #5a67d8;
    --primary-dark: #434190;
    --secondary: #64748b;
    --success: #10b981;
    --info: #3b82f6;
    --warning: #f59e0b;
    --danger: #ef4444;
    --light: #f8fafc;
    --dark: #1e293b;
    --sidebar-width: 250px;
    --header-height: 70px;
    --body-bg: #f1f5f9;
    --sidebar-bg: #ffffff;
    --text-color: #334155;
}

body {
    background-color: var(--body-bg);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-color);
    overflow-x: hidden;
}

/* ==========================================================================
   2. MAIN WRAPPER & STRUCTURE
   ========================================================================== */
.main-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* CONTENT AREA */
.main-content {
    padding-left: var(--sidebar-width);
    padding-top: calc(var(--header-height) + 30px);
    padding-right: 30px;
    padding-bottom: 30px;
    width: 100%;
    position: relative;
    min-height: 100vh; /* Pushes footer down */
    transition: all 0.3s ease;
}

/* ==========================================================================
   3. NAVBAR (HEADER)
   ========================================================================== */
.navbar-bg {
    content: " ";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 115px;
    background: linear-gradient(135deg, #5a67d8 0%, #7c3aed 100%);
    z-index: -1;
}

.navbar {
    height: var(--header-height);
    position: absolute;
    left: var(--sidebar-width);
    right: 0;
    top: 0;
    z-index: 890;
    background-color: transparent;
    padding: 0 30px;
    transition: all 0.3s ease;
}

/* ==========================================================================
   4. SIDEBAR (Restoring the structure you liked)
   ========================================================================== */
.main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    z-index: 891;
    background-color: var(--sidebar-bg);
    box-shadow: 0 4px 25px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.sidebar-brand {
    display: inline-block;
    width: 100%;
    text-align: center;
    height: var(--header-height);
    line-height: var(--header-height);
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #f1f5f9;
}

.sidebar-brand a { color: var(--dark); text-decoration: none; }
.sidebar-brand-sm { display: none; text-align: center; font-size: 20px; font-weight: 800; line-height: 70px;}
.sidebar-brand-sm a { color: var(--dark); text-decoration: none; }

.sidebar-menu {
    padding: 20px 15px;
    list-style: none;
    margin: 0;
}

.sidebar-menu li.menu-header {
    padding: 10px 15px;
    color: #94a3b8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
}

.sidebar-menu li a {
    position: relative;
    display: flex;
    align-items: center;
    height: 46px;
    padding: 0 15px;
    width: 100%;
    border-radius: 8px;
    color: var(--secondary);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.sidebar-menu li a i {
    width: 28px;
    font-size: 15px;
    margin-right: 8px;
    text-align: center;
}

.sidebar-menu li a span { margin-top: 2px; }

/* Active State */
.sidebar-menu li.active > a {
    background: #5a67d8; /* Solid color matches your original preference */
    color: #fff;
    box-shadow: 0 4px 10px rgba(90, 103, 216, 0.3);
}

.sidebar-menu li.active > a:hover { background: #434190; }

/* Dropdowns */
.sidebar-menu li.dropdown ul.dropdown-menu {
    padding: 5px 0;
    margin: 0;
    display: none; /* jQuery toggles this */
    position: relative; /* CRITICAL: Pushes content down */
    background: transparent;
    border: none;
    box-shadow: none;
    list-style: none;
    width: 100%;
}

.sidebar-menu li.dropdown ul.dropdown-menu li a {
    padding-left: 50px;
    height: 38px;
    font-size: 13px;
    background: transparent;
    color: var(--secondary);
}

.sidebar-menu li.dropdown ul.dropdown-menu li.active > a {
    color: var(--primary);
    font-weight: 700;
    background: transparent;
    box-shadow: none;
}

.sidebar-menu li.dropdown ul.dropdown-menu li a:hover {
    color: var(--primary);
    background: rgba(90, 103, 216, 0.1);
}

/* ==========================================================================
   5. FOOTER (Fixed the overlap issue)
   ========================================================================== */
.main-footer {
    padding: 20px 30px;
    margin-top: auto; /* Pushes to bottom if content is short */
    border-top: 1px solid #e2e8f0;
    display: inline-block;
    width: 100%;
    background: #fff;
    /* CRITICAL FIXES BELOW */
    padding-left: calc(var(--sidebar-width) + 30px); 
    position: relative;
    z-index: 1;
}

.footer-left { float: left; }
.footer-right { float: right; }

/* ==========================================================================
   6. RESPONSIVE (MOBILE/TABLET)
   ========================================================================== */
@media (max-width: 1024px) {
    /* Navbar expands to full width */
    .navbar { left: 0; padding: 0 20px; }
    
    /* Content expands to full width */
    .main-content { padding-left: 20px; padding-right: 20px; }
    
    /* Footer expands to full width */
    .main-footer { padding-left: 20px; text-align: center; }
    .footer-left, .footer-right { float: none; display: block; }
    
    /* Sidebar Hides */
    .main-sidebar { left: -260px; }
    
    /* Active State (Sidebar Open) */
    body.sidebar-show .main-sidebar { left: 0; }
    body.sidebar-show { overflow: hidden; } /* Prevent scrolling when menu open */
    
    /* Overlay for mobile */
    body.sidebar-show::after {
        content: "";
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 890;
        animation: fadeIn 0.3s;
    }
}