/* ==========================================================================
   1. CORE VARIABLES & MASTER CONTROL
   ========================================================================== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --sidebar-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-link-color: #4b5563;
    --sidebar-link-hover-bg: #f3f4f6;
    --sidebar-link-hover-color: #111827;
    --sidebar-link-active-bg: #eef2ff;
    --sidebar-link-active-color: #4338ca;
}

.fs-7 {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   2. SIDEBAR CONTAINER & NAVIGATION
   ========================================================================== */
#sidebarFrame {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    transition: var(--sidebar-transition);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

    #sidebarFrame .sidebar-logo {
        height: 70px;
        display: flex;
        align-items: center;
        padding: 0 0.85rem;
        border-bottom: 1px solid var(--sidebar-border);
    }

    #sidebarFrame .logo-img {
        height: 42px;
        transition: var(--sidebar-transition);
    }

    #sidebarFrame .logo-text-wrapper {
        display: flex;
        flex-direction: column;
        line-height: 1.15;
    }

    #sidebarFrame .logo-title {
        font-size: 0.85rem;
        font-weight: 700;
        color: #1f2937;
        white-space: nowrap;
    }

    #sidebarFrame .logo-subtitle {
        font-size: 0.68rem;
        font-weight: 600;
        color: #0d6efd;
        white-space: nowrap;
    }

/* Vertical Links Engine */
.vertical-sidebar {
    flex-grow: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--sidebar-link-color);
    text-decoration: none;
    border-radius: 0.375rem;
    font-size: 0.925rem;
    font-weight: 500;
    margin: 0 0.5rem;
    transition: var(--sidebar-transition);
}

    .nav-link-custom:hover {
        background-color: var(--sidebar-link-hover-bg);
        color: var(--sidebar-link-hover-color);
    }

    .nav-link-custom.active {
        background-color: var(--sidebar-link-active-bg);
        color: var(--sidebar-link-active-color);
    }

/* Hide compact logo by default in normal sidebar view */
#sidebarFrame .logo-compact {
    display: none !important;
}
/* ==========================================================================
   3. DESKTOP COLAAPSED STATE (MINI RAIL MODE)
   ========================================================================== */
@media (min-width: 768px) {
    body.sidebar-collapsed #sidebarFrame {
        width: var(--sidebar-collapsed-width);
        min-width: var(--sidebar-collapsed-width);
        max-width: var(--sidebar-collapsed-width);
    }

        /* --- LOGO SWAP MECHANICS --- */
        /* Hide the full image and text wrapper when collapsed */
        body.sidebar-collapsed #sidebarFrame .logo-full,
        body.sidebar-collapsed #sidebarFrame .logo-text-wrapper {
            display: none !important;
        }

        /* Unhide the compact icon version */
        body.sidebar-collapsed #sidebarFrame .logo-compact {
            display: block !important;
            margin-right: 0 !important; /* Center alignment clean-up */
        }
    /* --------------------------- */

    body.sidebar-collapsed .main-content-wrapper {
        width: calc(100% - var(--sidebar-collapsed-width));
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding: 0.5rem 0;
    }

    body.sidebar-collapsed .logo-img {
        margin-right: 0 !important;
    }

    body.sidebar-collapsed .nav-link-custom {
        justify-content: center;
        padding: 0.75rem 0;
    }

        body.sidebar-collapsed .nav-link-custom i {
            font-size: 1.2rem;
        }

    /* Hide text labels entirely */
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-section-title,
    body.sidebar-collapsed .sidebar-section-admin,
    body.sidebar-collapsed .nav-text-label {
        display: none !important;
    }
}

/* ==========================================================================
   4. CONTENT WRAPPER MANAGEMENT
   ========================================================================== */
.main-content-wrapper {
    transition: var(--sidebar-transition);
    width: calc(100% - var(--sidebar-width));
}

/* ==========================================================================
   5. MOBILE DRAWERS OVERLAY ENGINE
   ========================================================================== */
@media (max-width: 767.98px) {
    #sidebarFrame {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        z-index: 1050;
    }

    .main-content-wrapper {
        width: 100% !important;
    }

    body.sidebar-open #sidebarFrame {
        transform: translateX(0);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
    }
}

/* ==========================================================================
   6. LOGIN VIEWPORTS RULES
   ========================================================================== */
.login-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    width: 100%;
}

    .login-shell > main {
        width: 100%;
        max-width: 420px;
    }

    .login-shell .login-header {
        margin-bottom: 1.5rem;
    }

    .login-shell .login-footer {
        margin-top: 1.5rem;
        color: #64748b;
        font-size: .75rem;
        text-align: center;
    }

        .login-shell .login-footer a {
            color: #4338ca;
            text-decoration: none;
        }

            .login-shell .login-footer a:hover {
                text-decoration: underline;
            }

@media (prefers-reduced-motion: reduce) {
    #sidebarFrame, .main-content-wrapper, .logo-img, .nav-link-custom {
        transition: none !important;
    }
}
