﻿/* ----------  Sidebar  ---------- */
.eUI .sidebar {
    position: relative;
    /*max-width: 300px;*/
    width: 290px;
    /*min-width: 280px;*/
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    transition: margin .3s ease, width .3s ease;
    margin: 8px;
    overflow: hidden;

    &.collapsed {
        width: 74px;
        min-width: 74px;
    }
}
/* =========================================================
    SIDEBAR NAVIGATION
========================================================= */
.eUI .brand {
    padding: var(--spacing-3xl) var(--spacing-2xl) 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-600);

    & > div.sidebar__logo {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding-bottom: var(--spacing-lg);
        border-bottom: 2px solid var(--brand-600);
        box-sizing: border-box;
        cursor: pointer;
    }

    & img {
        max-height: 80px;
        max-width: 100%;
        object-fit: contain;
    }

    & .sidebar__logo img {
        max-height: 80px;
        max-width: 100%;
        object-fit: contain;
    }
}

.eUI .--eMenu {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;

    .--eNav {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .--eBlockDown {
        flex-shrink: 0;
        border-top: 1px solid var(--brand-300);
        margin: 8px 0;
        padding-top: 12px
    }
}

/* Portal Settings Link (Manage Site) */
.eUI .portal-settings-link {
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 6px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    overflow: hidden;

    &:hover {
        color: var(--brand-600);
        background-color: rgba(0, 123, 255, 0.08);
    }

    &:hover svg {
        transform: rotate(90deg);
    }

    svg {
        transition: transform 0.3s ease;
        flex-shrink: 0;
    }

    .settings-label {
        max-width: 0;
        opacity: 0;
        white-space: nowrap;
        overflow: hidden;
        transition: max-width 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
        margin-right: 0;
    }

    &:hover .settings-label {
        max-width: 80px;
        opacity: 1;
        margin-right: 6px;
    }
}

.eUI .toggle--sidebar {
    padding: 0;
}

.eUI nav[role="navigation"] {
    flex: 1;
}

.eUI .nav-link,
.eUI .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: var(--navLinkW, 100%);
    padding: 10px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;

    &:hover {
        background: var(--gray-100);
    }

    & .setting__item {
        display: flex;
        text-align: center;
        align-items: center;
        gap: 8px;
    }
}

/* Compact sidebar */
.eUI .sidebar.collapsed .nav-label {
    display: none;
}

.eUI .sidebar.collapsed .nav-link,
.eUI .sidebar.collapsed .submenu-toggle {
    justify-content: center;
}

/* Sub‑menu */
.eUI .submenu {
    list-style: none;
    padding-left: 28px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;

    &.show {
        max-height: 500px;
    }

    & .nav-link {
        font-size: 13px;
        padding: 8px 16px;
    }
}

.eUI .account {
    margin: 8px 16px;
}

.eUI .--eBlockDown {
    & .nav-label {
        color: var(--gray-700);
        font-size: 14px;
        font-weight: 600;
    }

    & .account__user {
       display: flex;
       gap: 12px;
    }
}

.eUI .account__wrapper {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 12px;
    width: 100%;

    @supports (width: -webkit-fill-available) {
        & {
            width: -webkit-fill-available;
        }
    }

    @supports (width: -moz-available) {
        & {
            width: -moz-available;
        }
    }

    & .nav-label {
        color: var(--gray-700);
        font-size: 16px;
        font-weight: 600;
    }

    & .account__user {
       display: flex;
       gap: 12px;
    }

    
}

.eUI .sidebar.collapsed .account__wrapper {
    & .nav-label {
        display: none;
    }

    & .chevron {
        display: none;
    }
}



.eUI .top__drop-down {
    margin: 8px 16px;
    & p {
        margin-bottom: 0;
    }

    & .wrapper__drop-down {
        padding: 8px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-lg);
        width: 100%;

        @supports (width: -webkit-fill-available) {
            & {
                width: -webkit-fill-available;
            }
        }

        @supports (width: -moz-available) {
            & {
                width: -moz-available;
            }
        }
    }
}

.eUI .sidebar.collapsed .top__drop-down {
    display: none;
}

.eUI .form-label.small {
    color: var(--gray-700);  
    font-size: 14px; 
    font-weight: 500;
    margin-bottom: 0 !important;
}

/* =========================================================
    ACCESSIBILITY
========================================================= */
.eUI :focus-visible {
    /*outline: 2px dashed var(--brand-primary);
    outline-offset: 2px;*/
    outline: none;
    outline-offset: 0;
}

/* =========================================================
    PAGINATION
========================================================= */

.eUI .pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--gray-600);

    & button:disabled {
        opacity: .35;
        cursor: default;
    }
}

/* =========================================================
    SEARCH
========================================================= */

.eUI .search {
    width: 100%;
    min-width: 350px;
    height: 40px;
    padding: 8px 12px;
    background: var(--white);
    box-shadow: var(--shadow-xs-card);
    border: .1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: start;
    align-items: center;
    gap: 8px;

    & .eTextBox {
        height: inherit;
        border: 1px solid transparent;
    }

    & .eTextBox .k-input-solid.k-focus {
        border: 1px solid transparent;
    }

    &:has( .eTextBox .k-input-solid.k-focus) {
        border: 1px solid var(--brand-600);
    }

    --eTextBoxBorderColor: transparent;

    & input {
        width: 100%;
        border: none;
        border-radius: var(--radius-sm);
    }

        & input:focus-visible,
        & input:focus {
            outline: 0;
            outline-offset: 0;
        }
}
    /* =========================================================
    PANEL SHOW
========================================================= */

.eUI .show__panel {
    position: absolute;
    height: 100vh;
    top: 0;
    left: -100%;
    max-width: 100%;
    width: auto;
    background: transparent;
    z-index: 11;
    transition: left .5s ease;
    overflow-y: hidden;
}

.eUI .show__panel--doc {
    position: fixed;
    inset: 0 auto 0 0;
    max-width: 100vw;
    width: 100%;
    min-width: 340px;
    height: 100vh;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform .4s ease;
    z-index: 11;
    pointer-events: none;
}

[data-accent="dark"] .show__panel--doc {
    & .k-treeview {
        color: var(--gray-600) !important;
    }
}

#panelBody .k-resize-handle-e {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 12px;
    z-index: 5;
    cursor: ew-resize;
}

    .eUI .--eRow:has( .folder__view-switch:checked) ~ .show__panel--doc {
        transform: translateX(0);
    }

    .eUI .k-splitter .k-scrollable {
        overflow: hidden !important;
    }

    .eUI .show__panel--doc {
        .k-ghost-splitbar.k-ghost-splitbar-horizontal {
            display: none !important;
        }
    }

    #overlaySplitter {
        height: 100%;
    }

    #overlaySplitter .k-splitbar-horizontal {
        width: 12px;
        background: var(--gray-100);
        border-left: 1px solid var(--gray-200);
        border-right: 1px solid var(--gray-200);
        cursor: ew-resize;
    }

    [data-accent="dark"] #overlaySplitter .k-splitbar-horizontal {
        background: var(--gray-400);
    }

    #overlaySplitter .k-splitbar-horizontal .k-resize-handle {
        left: 50%;
        transform: translateX(-50%);
        opacity: .75;
    }

    #overlaySplitter .k-splitbar-horizontal:hover .k-resize-handle {
        opacity: 1;
    }

    #overlaySplitter .k-pane:last-child {
        background: transparent !important;
        pointer-events: none;
        flex-basis: revert;
    }

    #overlaySplitter .k-pane:first-child,
    #overlaySplitter .k-splitbar,
    #overlaySplitter .k-splitbar-horizontal,
    #overlaySplitter .k-resize-handle {
        pointer-events: auto;
    }

    .eUI .--eRow:has( .folder__view-switch:checked) ~ .show__panel {
        left: 0;
    }

    .eUI .folder__view {
        position: relative;
        display: flex;
        align-items: center;
        cursor: default;
    }

    .eUI .folder__view-icon-label {
        position: relative;
        display: flex;
        cursor: pointer;
    }

    .eUI .folder__view-switch {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .eUI .icon__view {
        display: block;
        width: 28px;
        height: 28px;
        transition: background-image .25s ease;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;

        & .close__svg {
            display: block;
        }

        & .open__svg {
            display: none;
        }
    }

    .eUI .folder__view-switch:checked ~ .icon__view {
        & .close__svg {
            display: none;
        }

        & .open__svg {
            display: block;
        }
    }

    .eUI .panel__help {
        position: absolute;
        top: 50%;
        z-index: 4;
        position: absolute;
        padding: 4px 16px;
        color: var(--brand-50);
        background: var(--brand-600);
        border-top-left-radius: var(--radius-xs);
        border-top-right-radius: var(--radius-xs);
        transform: rotate(270deg);
        right: -24px;
        cursor: pointer;

        &:hover {
            opacity: .7;
        }

        & .help-label {
            color: var(--text-on-brand);
        }

        & .help__item {
            display: flex;
            gap: 4px;
            align-items: center;
        }
    }

    .eUI .panel__favorite {
        position: absolute;
        top: calc(50% + 112px);
        z-index: 4;
        padding: 4px 16px;
        color: var(--text-on-brand);
        background: var(--brand-600);
        border-top-left-radius: var(--radius-xs);
        border-top-right-radius: var(--radius-xs);
        transform: rotate(270deg);
        right: -36px;
        cursor: pointer;

        &:hover {
            opacity: .7;
        }

        & .favorite-label {
            color: var(--text-on-brand);
        }

        & .favorite__item {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        /* When page is favorited: fill the star icon */
        & #favoriteIcon.is-favorite svg {
            fill: var(--text-on-brand);
        }
    }

    @media (prefers-reduced-motion: no-preference) {
        .eUI .sidebar {
            will-change: transform;
            /*overflow-y: auto;*/
        }
    }

/* =========================================================
    SIDEBAR TOGGLE SYSTEM
    CSS-checkbox state carrier — desktop collapse / mobile drawer
========================================================= */

/* ── Hidden state carrier ── */
.sidebar-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* ── Desktop: collapse tab (thin vertical strip on right edge of sidebar) ── */
.eUI .sidebar-collapse-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 48px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    cursor: pointer;
    z-index: 2;
    color: var(--gray-400);
    transition: background .2s ease, color .2s ease, border-color .2s ease;

    & svg {
        flex-shrink: 0;
        transition: transform .3s ease;
    }

    &:hover {
        background: var(--brand-50);
        color: var(--brand-600);
        border-color: var(--brand-200);
    }

    &:focus-visible {
        outline: 2px solid var(--brand-400);
        outline-offset: -2px;
    }
}

/* ── Desktop: "Show Menu" tab — styled like the Help/Favorite side tabs,
   mirrored onto the left screen edge. Hidden while the sidebar is open. ── */
.eUI .sidebar-show-tab {
    display: none;
    position: fixed;
    top: 50%;
    /* Fixed width + center-origin rotation make the on-screen position
       deterministic (independent of text width): the rotated pill is ~H(28px)
       wide and its visual left edge ≈ left + (width - 28)/2 ≈ -2px → flush. */
    left: -38px;
    width: 104px;
    box-sizing: border-box;
    text-align: center;
    z-index: 50;
    padding: 4px 16px;
    color: var(--brand-50);
    background: var(--brand-600);
    border-bottom-left-radius: var(--radius-xs);
    border-bottom-right-radius: var(--radius-xs);
    transform: rotate(270deg);
    transform-origin: center center;
    cursor: pointer;
    white-space: nowrap;

    &:hover {
        opacity: .7;
    }

    & .show-menu-label {
        color: var(--text-on-brand);
    }

    &:focus-visible {
        outline: 2px solid var(--brand-400);
        outline-offset: 2px;
    }
}

/* ── Desktop only: checked = sidebar slides off-screen, "Show Menu" tab appears ── */
@media (min-width: 997px) {
    /* Sidebar slides out past the left edge AND releases its layout space,
       so the content area expands to full width. */
    .sidebar-toggle-input:checked ~ .admin .sidebar {
        margin-left: -298px;
        pointer-events: none;
    }

    /* Reveal the "Show Menu" tab */
    .sidebar-toggle-input:checked ~ .admin .sidebar-show-tab {
        display: block;
    }
}

/* ── Mobile-only elements: hidden on desktop ── */
.eUI .mobile-menu-btn,
.eUI .sidebar-overlay {
    display: none;
}

/* ── Mobile: sidebar becomes a fixed overlay drawer ── */
@media (max-width: 996px) {
    /* Drawer starts off-screen and invisible */
    .eUI .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100dvh;
        width: 290px;
        margin: 0;
        border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .3s ease;
        visibility: hidden;
        pointer-events: none;
        overflow: hidden;
    }

    /* Open state: drawer slides in */
    .sidebar-toggle-input:checked ~ .admin .sidebar {
        transform: translateX(0);
        width: 290px;
        min-width: 290px;
        visibility: visible;
        pointer-events: auto;
    }

    /* Content fills full width on mobile */
    .eUI .content-wrapper {
        width: 100%;
        padding-left: var(--spacing-xl);
        padding-right: var(--spacing-xl);
        padding-top: calc(var(--spacing-xl) + 52px);
    }

    /* Hide rotated side panels (Help / Favorite tabs) */
    .eUI .panel__help,
    .eUI .panel__favorite {
        display: none;
    }

    /* Backdrop overlay — click to close the drawer */
    .eUI .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .42);
        z-index: 199;
        cursor: pointer;
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
    }

    .sidebar-toggle-input:checked ~ .admin .sidebar-overlay {
        display: block;
    }

    /* Mobile hamburger button */
    .eUI .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 300;
        width: 40px;
        height: 40px;
        background: var(--white);
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-card);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--gray-700);
        transition: background .2s ease, color .2s ease;
    }

    .eUI .mobile-menu-btn:hover {
        background: var(--brand-50);
        color: var(--brand-600);
    }

    .eUI .mobile-menu-btn:focus-visible {
        outline: 2px solid var(--brand-400);
        outline-offset: 2px;
    }

    /* Hamburger disappears once drawer is open (overlay provides close) */
    .sidebar-toggle-input:checked ~ .admin .mobile-menu-btn {
        display: none;
    }

    /* Desktop collapse button not needed on mobile */
    .eUI .sidebar .sidebar-collapse-btn {
        display: none;
    }

    /* ── Bug 2: single scroll container inside the drawer ── */

    /* .--eNav (flex: 1, min-height: 0) becomes the scrollable area */
    .eUI .sidebar .--eMenu .--eNav {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Neutralize competing scroll container from site.css (.--eNav > section) */
    .eUI .sidebar .--eMenu .--eNav > section {
        overflow: visible;
    }

    /* Neutralize competing scroll container from site.css (.portal__menu) */
    .eUI .sidebar .--eMenu .portal__menu {
        height: auto;
        overflow: visible;
    }

    /* Keep account/logout footer always in view at the bottom of the scroll area */
    .eUI .sidebar .--eMenu .--eBlockDown {
        position: sticky;
        bottom: 0;
        background: var(--white);
    }
}