/* ============================================================
   DUAL-SIDEBAR MODERN ERP ARCHITECTURE
   ============================================================ */

:root {
    --bm-primary: #5b6fed;
    --bm-primary-dark: #4657d6;
    --bm-primary-light: #eef0ff;
    --bm-rail-width: 80px;
    --bm-drawer-width: 280px;
    --bm-topbar-height: 64px;
    --bm-body-bg: #f4f6fb;
    --bm-surface: #ffffff;
    --bm-border: #eaecf3;
    --bm-text: #2b2f42;
    --bm-text-muted: #8a8fa3;
    --bm-radius: 12px;
    --bm-shadow: 0 2px 10px rgba(31, 41, 82, 0.06);
    --bm-shadow-hover: 0 6px 20px rgba(31, 41, 82, 0.10);
    --bm-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body.erp-app-shell {
    background: var(--bm-body-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--bm-text);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Container Wrapping Rail + Drawer for Mouse Hover Detection */
.sidebar-hover-area {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;
}

/* ------------------------------------------------------------
   1. NAVIGATION RAIL (Fixed 80px Left Sidebar)
   ------------------------------------------------------------ */
.nav-rail {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--bm-rail-width);
    background: var(--bm-surface);
    border-right: 1px solid var(--bm-border);
    z-index: 1055;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
}

.rail-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-bottom: 20px;
}

    .rail-brand .logo-box {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: linear-gradient(135deg, var(--bm-primary), #8b5cf6);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
        font-size: 15px;
        box-shadow: 0 4px 12px rgba(91, 111, 237, 0.3);
    }

.rail-nav-wrapper {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

    .rail-nav-wrapper::-webkit-scrollbar {
        width: 0px;
    }

.rail-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rail-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

.rail-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--bm-text-muted);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: var(--bm-transition);
}

    .rail-btn:hover {
        background: var(--bm-primary-light);
        color: var(--bm-primary-dark);
    }

    .rail-btn.active {
        background: var(--bm-primary);
        color: #ffffff;
        box-shadow: 0 6px 14px rgba(91, 111, 237, 0.35);
    }

/* ------------------------------------------------------------
   2. NAVIGATION DRAWER (280px Sliding Drawer)
   ------------------------------------------------------------ */
.nav-drawer {
    position: absolute;
    top: 0;
    left: var(--bm-rail-width);
    bottom: 0;
    width: var(--bm-drawer-width);
    background: #f8f9fe;
    border-right: 1px solid var(--bm-border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: var(--bm-transition);
    opacity: 0;
    visibility: hidden;
}

body.drawer-open .nav-drawer {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.drawer-header {
    height: var(--bm-topbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid var(--bm-border);
    background: var(--bm-surface);
}

.drawer-title {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    color: var(--bm-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

    .drawer-body::-webkit-scrollbar {
        width: 4px;
    }

    .drawer-body::-webkit-scrollbar-thumb {
        background: #d8dcec;
        border-radius: 4px;
    }

.drawer-panel {
    display: none;
}

    .drawer-panel.active {
        display: block;
    }

/* Drawer Links & Accordions */
.drawer-group {
    margin-bottom: 4px;
}

.drawer-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 2px 0;
    border-radius: 10px;
    color: #545a72;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--bm-transition);
}

    .drawer-nav-link i {
        width: 20px;
        text-align: center;
        font-size: 15px;
        color: #9297ac;
        flex-shrink: 0;
    }

    .drawer-nav-link:hover {
        background: var(--bm-surface);
        color: var(--bm-primary);
        box-shadow: var(--bm-shadow);
    }

        .drawer-nav-link:hover i {
            color: var(--bm-primary);
        }

    .drawer-nav-link.active {
        background: var(--bm-primary);
        color: #ffffff;
        box-shadow: 0 4px 12px rgba(91, 111, 237, 0.3);
    }

        .drawer-nav-link.active i {
            color: #ffffff;
        }

    .drawer-nav-link .chevron {
        margin-left: auto;
        font-size: 10px;
        transition: transform 0.2s ease;
        color: #9297ac;
    }

.drawer-menu-toggle.open .chevron {
    transform: rotate(90deg);
}

.drawer-submenu {
    max-height: 0;
    overflow: hidden;
    padding-left: 12px;
    transition: max-height 0.25s ease-in-out;
}

    .drawer-submenu.open {
        max-height: 1000px;
    }

/* ------------------------------------------------------------
   3. TOPBAR
   ------------------------------------------------------------ */
.topbar {
    position: fixed;
    top: 0;
    left: var(--bm-rail-width);
    right: 0;
    height: var(--bm-topbar-height);
    background: var(--bm-surface);
    border-bottom: 1px solid var(--bm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1030;
    transition: var(--bm-transition);
}

body.drawer-open .topbar {
    left: calc(var(--bm-rail-width) + var(--bm-drawer-width));
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    border: none;
    background: var(--bm-primary-light);
    color: var(--bm-primary-dark);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: var(--bm-transition);
}

    .sidebar-toggle:hover {
        background: var(--bm-primary);
        color: #ffffff;
    }

.breadcrumb-title {
    font-weight: 700;
    font-size: 15px;
}

.breadcrumb-sub {
    font-size: 12px;
    color: var(--bm-text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-icon-btn {
    border: none;
    background: transparent;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bm-text-muted);
    cursor: pointer;
    transition: var(--bm-transition);
}

    .topbar-icon-btn:hover {
        background: var(--bm-primary-light);
        color: var(--bm-primary-dark);
    }

.topbar-divider {
    width: 1px;
    height: 26px;
    background: var(--bm-border);
    margin: 0 8px;
}

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
}

    .topbar-user-btn:hover {
        background: var(--bm-primary-light);
    }

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bm-primary), #8b5cf6);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quick Access Grid */
.quick-grid {
    width: 280px;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--bm-shadow-hover);
    border: 1px solid var(--bm-border);
}

.quick-grid-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--bm-text-muted);
    text-transform: uppercase;
}

.quick-grid-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.quick-grid-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: 8px;
    background: var(--bm-body-bg);
    color: var(--bm-text);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: var(--bm-transition);
}

    .quick-grid-box:hover {
        background: var(--bm-primary-light);
        color: var(--bm-primary-dark);
    }

    .quick-grid-box i {
        font-size: 18px;
    }

/* History Dropdown */
.history-dropdown {
    width: 260px;
    border-radius: 12px;
    box-shadow: var(--bm-shadow-hover);
    border: 1px solid var(--bm-border);
    padding: 8px 0;
}

/* ------------------------------------------------------------
   4. MAIN CONTENT
   ------------------------------------------------------------ */
.app-content {
    margin-left: var(--bm-rail-width);
    margin-top: var(--bm-topbar-height);
    min-height: calc(100vh - var(--bm-topbar-height));
    display: flex;
    flex-direction: column;
    transition: var(--bm-transition);
}

body.drawer-open .app-content {
    margin-left: calc(var(--bm-rail-width) + var(--bm-drawer-width));
}

.content-body {
    padding: 24px;
    flex: 1;
}

.app-footer {
    padding: 16px 24px;
    background: var(--bm-surface);
    border-top: 1px solid var(--bm-border);
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--bm-text-muted);
}

/* Backdrop */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1035;
    display: none;
}

/* ------------------------------------------------------------
   5. RESPONSIVE DESIGN (Mobile & Tablet handling)
   ------------------------------------------------------------ */
@media (max-width: 991.98px) {
    .nav-drawer {
        left: 0;
        z-index: 1060;
    }

    body.drawer-open .topbar,
    body.drawer-open .app-content {
        left: 0;
        margin-left: var(--bm-rail-width);
    }

    body.mobile-drawer-open .sidebar-backdrop {
        display: block;
    }

    /* ==========================================================================
   Dashboard Helper & Badge Utility Classes
   ========================================================================== */
    .fs-7 {
        font-size: 0.825rem !important;
    }

    .bg-primary-subtle {
        background-color: #ecf2ff !important;
        color: #5d87ff !important;
    }

    .bg-info-subtle {
        background-color: #e8f7ff !important;
        color: #49beff !important;
    }

    .bg-warning-subtle {
        background-color: #fef5e5 !important;
        color: #ffae1f !important;
    }

    .bg-success-subtle {
        background-color: #e6fffa !important;
        color: #13de8f !important;
    }

    .bg-danger-subtle {
        background-color: #fdede8 !important;
        color: #fa896b !important;
    }

    /* ==========================================================================
   MatDash FullCalendar Custom Styling
   ========================================================================== */
    .fc .fc-toolbar-title {
        font-size: 1.25rem;
        font-weight: 700;
        color: #5d87ff;
    }

    /* Primary Toolbar Navigation Buttons (Month / Week / Day) */
    .fc .fc-button-primary {
        background-color: #f6f9fc;
        border: none;
        color: #2a3547;
        font-weight: 500;
        padding: 0.4rem 0.8rem;
        box-shadow: none !important;
    }

        .fc .fc-button-primary:hover {
            background-color: #eaeef4;
            color: #2a3547;
        }

    /* Active Navigation View Button */
    .fc .fc-button-active {
        background-color: #111c2d !important;
        color: #ffffff !important;
    }

    /* MatDash Purple "Add Event" Action Button */
    .fc .fc-addEventButton-button {
        background-color: #5d87ff !important;
        color: #ffffff !important;
        border-radius: 8px !important;
        padding: 0.4rem 1rem !important;
        font-weight: 600;
    }

    .fc .fc-prev-button,
    .fc .fc-next-button {
        border-radius: 8px !important;
        background-color: #f6f9fc;
        color: #2a3547;
        margin-right: 4px;
    }

    /* Grid & Border Formatting */
    .fc-theme-standard td,
    .fc-theme-standard th {
        border-color: #ebf1f6;
    }

    .fc .fc-col-header-cell-cushion {
        color: #2a3547;
        font-weight: 600;
        font-size: 0.85rem;
        padding: 10px 0;
    }

    .fc .fc-daygrid-day-number {
        color: #7c889c;
        font-size: 0.8rem;
        font-weight: 500;
    }

    /* Rounded Event Pill Design */
    .fc-event {
        font-size: 0.78rem;
        margin-top: 2px !important;
        margin-bottom: 2px !important;
    }
}
