/*
 * Single-sidebar overrides.
 *
 * Stock Kanakku uses a two-column nav (60px icon rail + ~216px menu = 276px)
 * and offsets .header / .page-wrapper by that width.
 *
 * This app hides the icon rail and keeps one 240px sidebar (#sidebar-two).
 * Stock [data-layout=single] rules still offset content by only 216px, which
 * lets .page-wrapper slide under the 240px menu. Re-align everything here
 * with equal-or-higher specificity so content never covers the sidebar, and
 * paint the nav with --menu-bg to match the Kanakku demo.
 *
 * IMPORTANT: desktop offset selectors use html[data-*] (high specificity +
 * !important). Every mobile reset MUST match or exceed that specificity or
 * the header/content stay pushed 240px on phones/tablets.
 */

:root {
    --sidenav-width: 240px;
    --sidenav-gap: 0px;
    --sidenav-mini-width: 56px;
}

/* Hide the unused two-column icon rail only. */

/*
 * Sidebar fill — all breakpoints.
 * Stock .sidebar uses background: inherit (picks up white body) and several
 * children/simplebar layers can paint white over --menu-bg. Force the Kanakku
 * off-white (--menu-bg → --light / #F7F8F9) on the full nav stack.
 */
.sidebar,
.sidebars,
#sidebar-two,
html[data-layout] .sidebar,
html[data-layout] .sidebars,
html[data-layout] #sidebar-two,
html[data-sidebar] .sidebar,
html[data-sidebar] #sidebar-two,
html[data-bs-theme] .sidebar,
html[data-bs-theme] #sidebar-two {
    background: var(--menu-bg, var(--light)) !important;
    background-color: var(--menu-bg, var(--light)) !important;
}

.sidebar .sidebar-logo,
.sidebar .sidebar-search,
.sidebar .sidebar-inner,
.sidebar .sidebar-menu,
.sidebar .sidebar-footer,
.sidebar .simplebar-wrapper,
.sidebar .simplebar-mask,
.sidebar .simplebar-offset,
.sidebar .simplebar-content-wrapper,
.sidebar .simplebar-content,
.sidebar [data-simplebar],
.sidebars .sidebar-logo,
.sidebars .sidebar-inner,
.sidebars .sidebar-menu,
.sidebars .simplebar-wrapper,
.sidebars .simplebar-mask,
.sidebars .simplebar-content-wrapper,
.sidebars .simplebar-content,
#sidebar-two .sidebar-logo,
#sidebar-two .sidebar-search,
#sidebar-two .sidebar-inner,
#sidebar-two .sidebar-menu,
#sidebar-two .sidebar-footer,
#sidebar-two .simplebar-wrapper,
#sidebar-two .simplebar-mask,
#sidebar-two .simplebar-offset,
#sidebar-two .simplebar-content-wrapper,
#sidebar-two .simplebar-content,
#sidebar-two [data-simplebar] {
    background: transparent !important;
    background-color: transparent !important;
}

/* Trial/footer card inside sidebar can stay white; don't force it transparent. */
.sidebar .sidebar-footer .trial-item,
#sidebar-two .sidebar-footer .trial-item {
    background-color: var(--white) !important;
}

#two-col-sidebar {
    display: none !important;
}

/* ------------------------------------------------------------------ */
/* Desktop / tablet landscape (>= 992px): content sits beside sidebar */
/* ------------------------------------------------------------------ */
@media (min-width: 992px) {
    .header,
    [data-layout] .header,
    [data-size] .header,
    [data-layout=single] .header,
    [data-size=single] .header,
    [data-layout=default] .header,
    [data-layout=mini] .header,
    [data-layout=transparent] .header,
    [data-layout=without-header] .header,
    html[data-layout] .header,
    html[data-size] .header,
    html[data-layout=single] .header,
    html[data-size=single] .header,
    html[data-layout=default] .header,
    html[data-layout=mini] .header,
    html[data-layout=transparent] .header {
        left: calc(var(--sidenav-width) + var(--sidenav-gap)) !important;
    }

    .page-wrapper,
    [data-layout] .page-wrapper,
    [data-size] .page-wrapper,
    [data-layout=single] .page-wrapper,
    [data-size=single] .page-wrapper,
    [data-layout=default] .page-wrapper,
    [data-layout=mini] .page-wrapper,
    [data-layout=transparent] .page-wrapper,
    html[data-layout] .page-wrapper,
    html[data-size] .page-wrapper,
    html[data-layout=single] .page-wrapper,
    html[data-size=single] .page-wrapper,
    html[data-layout=default] .page-wrapper,
    html[data-layout=mini] .page-wrapper,
    html[data-layout=transparent] .page-wrapper {
        margin-left: calc(var(--sidenav-width) + var(--sidenav-gap)) !important;
        margin-right: 0 !important;
        left: auto !important;
    }

    /* Nav shell */
    .sidebar,
    .sidebars,
    #sidebar-two {
        left: 0 !important;
        width: var(--sidenav-width) !important;
        background: var(--menu-bg, var(--light)) !important;
        background-color: var(--menu-bg, var(--light)) !important;
        z-index: 100; /* above page content, below .header (999) */
    }

    /* Mini: collapsed icon strip (class is usually on <body>). */
    body.mini-sidebar .header,
    html body.mini-sidebar .header,
    .mini-sidebar .header,
    html[data-layout] body.mini-sidebar .header,
    html[data-layout=single] body.mini-sidebar .header,
    html[data-size=single] body.mini-sidebar .header {
        left: calc(var(--sidenav-mini-width) + var(--sidenav-gap)) !important;
    }

    body.mini-sidebar .page-wrapper,
    html body.mini-sidebar .page-wrapper,
    .mini-sidebar .page-wrapper,
    html[data-layout] body.mini-sidebar .page-wrapper,
    html[data-layout=single] body.mini-sidebar .page-wrapper,
    html[data-size=single] body.mini-sidebar .page-wrapper,
    [data-layout=single] .mini-sidebar .page-wrapper,
    [data-size=single] .mini-sidebar .page-wrapper {
        margin-left: calc(var(--sidenav-mini-width) + var(--sidenav-gap)) !important;
        left: auto !important;
    }

    body.mini-sidebar .sidebar,
    body.mini-sidebar .sidebars,
    body.mini-sidebar #sidebar-two,
    .mini-sidebar .sidebar,
    .mini-sidebar #sidebar-two {
        width: var(--sidenav-mini-width) !important;
    }

    /* Hover-expand mini back to full width (header follows). */
    body.mini-sidebar.expand-menu .header,
    body.expand-menu.mini-sidebar .header,
    .expand-menu.mini-sidebar .header,
    html[data-layout] body.mini-sidebar.expand-menu .header {
        left: calc(var(--sidenav-width) + var(--sidenav-gap)) !important;
    }

    body.mini-sidebar.expand-menu .sidebar,
    body.mini-sidebar.expand-menu #sidebar-two,
    .expand-menu.mini-sidebar .sidebar,
    .expand-menu.mini-sidebar #sidebar-two {
        width: var(--sidenav-width) !important;
    }

    /* Horizontal: menu is in the topbar — no side offset. */
    [data-layout="horizontal"] .header,
    html[data-layout="horizontal"] .header {
        left: 0 !important;
    }

    [data-layout="horizontal"] .page-wrapper,
    html[data-layout="horizontal"] .page-wrapper {
        margin-left: 0 !important;
        left: auto !important;
    }
}

/* ------------------------------------------------------------------ */
/* Phone + tablet portrait (<= 991.98px): off-canvas sidebar           */
/* ------------------------------------------------------------------ */
@media (max-width: 991.98px) {
    /*
     * Full-bleed header and content. Selectors must match the desktop
     * html[data-*] specificity or those !important rules keep a 240px hole.
     */
    .header,
    [data-layout] .header,
    [data-size] .header,
    [data-layout=single] .header,
    [data-size=single] .header,
    [data-layout=default] .header,
    [data-layout=mini] .header,
    [data-layout=transparent] .header,
    [data-layout=without-header] .header,
    html[data-layout] .header,
    html[data-size] .header,
    html[data-layout=single] .header,
    html[data-size=single] .header,
    html[data-layout=default] .header,
    html[data-layout=mini] .header,
    html[data-layout=transparent] .header,
    html[data-layout=without-header] .header,
    body.mini-sidebar .header,
    html body.mini-sidebar .header,
    html[data-layout] body.mini-sidebar .header,
    body.mini-sidebar.expand-menu .header {
        left: 0 !important;
        right: 0 !important;
    }

    .page-wrapper,
    [data-layout] .page-wrapper,
    [data-size] .page-wrapper,
    [data-layout=single] .page-wrapper,
    [data-size=single] .page-wrapper,
    [data-layout=default] .page-wrapper,
    [data-layout=mini] .page-wrapper,
    [data-layout=transparent] .page-wrapper,
    html[data-layout] .page-wrapper,
    html[data-size] .page-wrapper,
    html[data-layout=single] .page-wrapper,
    html[data-size=single] .page-wrapper,
    html[data-layout=default] .page-wrapper,
    html[data-layout=mini] .page-wrapper,
    html[data-layout=transparent] .page-wrapper,
    body.mini-sidebar .page-wrapper,
    html body.mini-sidebar .page-wrapper,
    html[data-layout] body.mini-sidebar .page-wrapper,
    [data-layout=single] .mini-sidebar .page-wrapper,
    [data-size=single] .mini-sidebar .page-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /*
     * Sidebar is off-canvas by default. Stock uses margin-left: -575px;
     * keep that and only force width/background/z-index. Do NOT force
     * left: 0 here in a way that fights the slide-in, and do not pin
     * margin-left: 0 or the drawer never hides.
     */
    .sidebar,
    .sidebars,
    #sidebar-two {
        width: min(280px, 85vw) !important;
        background: var(--menu-bg, var(--light)) !important;
        background-color: var(--menu-bg, var(--light)) !important;
        z-index: 1041 !important; /* above header while the drawer is open */
        top: 56px !important;
        /* let stock margin-left: -575px hide it; slide-nav brings it back */
        left: 0 !important;
        margin-left: -575px !important;
        transition: margin-left 0.4s ease, left 0.4s ease !important;
    }

    /* Opened by #mobile_btn → body.slide-nav (or .main-wrapper.slide-nav). */
    .slide-nav .sidebar,
    .slide-nav .sidebars,
    .slide-nav #sidebar-two,
    body.slide-nav .sidebar,
    body.slide-nav .sidebars,
    body.slide-nav #sidebar-two,
    .main-wrapper.slide-nav .sidebar,
    .main-wrapper.slide-nav #sidebar-two {
        margin-left: 0 !important;
    }

    /* Overlay covers the page while the drawer is open. */
    .sidebar-overlay {
        z-index: 1040 !important;
    }

    .sidebar-overlay.opened {
        display: block !important;
    }
}

/* Sidebar menu icons need separation from their label (all breakpoints). */
.sidebar .sidebar-menu > ul > li > a > i,
.sidebars .sidebar-menu > ul > li > a > i,
.sidebar .sidebar-menu > ul > li > ul > li > a > i,
.sidebars .sidebar-menu > ul > li > ul > li > a > i {
    margin-right: 10px;
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* ---------------------------------------------------------------------------
   Top bar crowding.

   The right-hand cluster grew over time: POS, branch switcher, search,
   language, notifications, theme toggle and the profile menu. Each was given a
   fixed size and none could shrink, so on a laptop-width screen the search box
   ran under the POS button and the branch name collided with whatever sat next
   to it.

   The fix is to make the row behave like a row: the search box is the only
   flexible thing, so it absorbs the spare space and gives it back first, and
   the buttons that must stay legible are told not to shrink.
   --------------------------------------------------------------------------- */

.header .header-user .user-menu > .d-flex {
    /* Keep everything on one line and let the gap do the spacing rather than
       per-element margins that cannot collapse. */
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
}

/* The search field is the give in the layout. */
.header .header-user .user-menu .input-icon-end {
    flex: 1 1 220px;
    min-width: 120px;
    max-width: 320px;
}

.header .header-user .user-menu .input-icon-end .form-control {
    width: 100%;
}

/* Buttons and dropdowns keep their size instead of being squeezed into
   overlapping each other. */
.header .header-user .user-menu .btn,
.header .header-user .user-menu .dropdown,
.header .header-user .user-menu .nav-item,
.header .header-user .user-menu .theme-item,
.header .header-user .user-menu .notification_item {
    flex: 0 0 auto;
}

/* The branch name can be long, so it truncates rather than pushing its
   neighbours out of the bar. */
.header .header-user .user-menu .btn-menubar {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Below a wide desktop the search box is the first thing to go: the icon in
   the sidebar still reaches it, and the buttons are what people actually press
   from the bar. */
@media (max-width: 1399.98px) {
    .header .header-user .user-menu .input-icon-end {
        flex-basis: 160px;
        max-width: 200px;
    }
}

@media (max-width: 1199.98px) {
    .header .header-user .user-menu .input-icon-end {
        display: none;
    }

    /* The language picker is the next least useful thing in a cramped bar. */
    .header .header-user .user-menu .flag-nav {
        display: none;
    }
}

/* On a narrow desktop the POS label is dropped to its icon, which is still an
   unmistakable target. */
@media (max-width: 1299.98px) {
    .header .header-user .user-menu .btn-pos span {
        display: none;
    }

    .header .header-user .user-menu .btn-pos i {
        margin-right: 0 !important;
    }
}


/* ------------------------------------------------------------------ */
/* Sidebar submenu, matched to the Kanakku admin-dashboard-2 demo:     */
/*  - a thin vertical guide line runs behind every dropdown's items,   */
/*    and the active item's segment of that line turns primary;        */
/*  - the group holding the current page stays open after navigation   */
/*    (.active.subdrop ~ ul is forced visible, as in the demo).        */
/* ------------------------------------------------------------------ */
#sidebar-two .sidebar-menu li.submenu > ul {
    margin: 8px 0;
    position: relative;
}
#sidebar-two .sidebar-menu li.submenu > ul > li > a {
    position: relative;
    padding: 8px 4px 8px 32px;
    font-size: 13px;
}
#sidebar-two .sidebar-menu li.submenu > ul > li > a::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 0;
    width: 1.5px;
    height: 100%;
    background: var(--gray-100);
    opacity: 1;
}
#sidebar-two .sidebar-menu li.submenu > ul > li > a.active::before,
#sidebar-two .sidebar-menu li.submenu > ul > li > a.subdrop::before {
    background: var(--primary);
}
#sidebar-two .sidebar-menu li.submenu > ul > li > a.active {
    color: var(--menu-active-color, var(--primary));
}
#sidebar-two .sidebar-menu li.submenu > a.subdrop {
    background: var(--menu-item-active-bg);
    border-radius: 5px;
}
#sidebar-two .sidebar-menu .active.subdrop ~ ul {
    display: block !important;
}
.mini-sidebar:not(.expand-menu) #sidebar-two .sidebar-menu .active.subdrop ~ ul {
    display: none !important;
}
body.layout-mode-rtl #sidebar-two .sidebar-menu li.submenu > ul > li > a::before {
    right: 13px;
    left: unset;
}
