﻿/* ================================
   ROOT VARIABLES
================================ */
:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 68px;
    --transition: 260ms cubic-bezier(.4,0,.2,1);
    --bg-sidebar: #212529;
    --bg-main: #f8f9fa;
    --accent: #0d6efd;
}

/* ================================
   BASE (🔥 FIX SCROLL ISSUE)
================================ */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background-color: lightgrey;
    overflow: hidden; /* 🔥 IMPORTANT */
}

/* ================================
   DASHBOARD LAYOUT
================================ */
.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh; /* 🔥 FIX */
    overflow: hidden;
}

/* ================================
   TOPBAR
================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 1rem;
    background: linear-gradient(135deg, #ff512f 0%, #dd2476 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1100;
    height: 56px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

    .topbar .brand {
        color: #fff;
        -webkit-text-decoration: none;
        text-decoration: none;
        font-weight: 600;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
    }

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 6px;
    margin-right: .5rem;
}

.brand-text{
    display: inline-block;
}

@media (max-width: 420px){
    .brand-text {
        display: none;
    }
}

/* ================================
   LAYOUT BODY
================================ */
.layout-body {
    display: flex;
    flex: 1;
    height: calc(100vh - 56px); /* 🔥 FIX */
    overflow: hidden; /* 🔥 NO SCROLL HERE */
}

/* ================================
   SIDEBAR (🔥 STICKY)
================================ */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0; /* 🔥 PREVENT SHRINK */
    transition: width var(--transition), transform var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,.12);
    z-index: 1000;
}

    /* SCROLLBAR */
    #sidebar::-webkit-scrollbar {
        width: 6px;
    }

    #sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 4px;
    }

    /* COLLAPSED */
    #sidebar.collapsed {
        width: var(--sidebar-collapsed-width);
        min-width: var(--sidebar-collapsed-width);
    }

    /* ================================
   SIDEBAR CONTENT
================================ */
    #sidebar .sidebar-inner {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    #sidebar .nav,
    #sidebar .nav .nav {
        list-style: none;
        margin: 0;
        padding: 0;
    }

        #sidebar .nav > li {
            width: 100%;
        }

        #sidebar .nav a {
            display: flex;
            align-items: center;
            gap: .5rem;
            padding: .5rem .9rem;
            color: rgba(255,255,255,.92);
            text-decoration: none;
            transition: all .2s ease;
            font-size: 0.95rem;
            min-height: 38px;
            width: 100%;
            border-radius: 6px;
        }

    /* ICON */
    #sidebar .menu-icon {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        background: rgba(255,255,255,.06);
        flex-shrink: 0;
    }

    /* HOVER */
    #sidebar .nav a:hover {
        background: rgba(255,255,255,.1);
        transform: translateX(4px);
    }

    /* ACTIVE */
    #sidebar .nav a.active {
        background: rgba(255,255,255,.15);
        color: #fff;
    }

    /* SUBMENU */
    #sidebar .nav .nav {
        margin-left: .25rem;
        display: flex;
        flex-direction: column;
    }

        #sidebar .nav .nav a {
            padding-left: 1.3rem;
            font-size: 0.92rem;
            min-height: 34px;
        }

/* CARET */
.menu-caret {
    margin-left: auto;
    transition: transform var(--transition);
    font-size: 0.8rem;
}

.menu-toggle.open .menu-caret {
    transform: rotate(90deg);
}

/* COLLAPSED MODE */
#sidebar.collapsed .menu-label,
#sidebar.collapsed .menu-caret {
    display: none;
}

#sidebar.collapsed .nav a {
    justify-content: center;
    padding: .5rem 0 !important;
    gap: 0 !important;
}

#sidebar.collapsed .menu-icon {
    width: 100%;
    background: transparent;
}

    #sidebar.collapsed .menu-icon i {
        font-size: 1.25rem;
    }

/* ================================
   MAIN CONTENT (🔥 ONLY SCROLL AREA)
================================ */
#main {
    flex: 1;
    height: calc(100vh - 56px); /* 🔥 FIX */
    overflow-y: auto; /* ✅ ONLY SCROLL HERE */
    overflow-x: hidden;
    background: var(--bg-main);
}

/* PAGE */
.page-container {
    padding: 1rem 1.25rem;
    box-sizing: border-box;
}

/* FOOTER */
footer.site-footer {
    padding: .75rem 1.25rem;
    color: #6c757d;
}

/* ================================
   MOBILE
================================ */
@media (max-width: 768px) {

    html, body {
        overflow: auto; /* allow scroll on mobile */
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 220px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1200;
    }

        #sidebar.open {
            transform: translateX(0);
        }

            #sidebar.open::after {
                content: "";
                position: fixed;
                top: 0;
                left: 220px;
                width: calc(100vw - 220px);
                height: 100vh;
                background: rgba(0,0,0,0.35);
                backdrop-filter: blur(2px);
                z-index: 1100;
            }

    .layout-body {
        flex-direction: column;
        height: auto;
    }

    #main {
        height: auto;
        overflow: visible;
    }
}
