/* ═══════════════════════════════════════════════
   LMRT SIDEBAR NAVIGATION
   Left-side collapsible image-tile sidebar.
   Desktop: hover to expand, blur+transparency when collapsed.
═══════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --sidebar-collapsed: 64px;
    --sidebar-expanded:  240px;
    --sidebar-transition: 0.55s cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar-bg: var(--text-color);
    --sidebar-fg: var(--background-color);
    --sidebar-opacity: 0.5;
    --sidebar-nav-height: 135px;
}

/* ── Sidebar shell ── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-collapsed);
    height: 100vh;
    background-color: transparent;
    z-index: 101;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--sidebar-transition);
    will-change: transform;
    transform: translateZ(0);
}

/* Base background: covers entire sidebar, always semi-transparent */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--sidebar-bg);
    opacity: var(--sidebar-opacity);
    filter: blur(var(--sidebar-blur));
    transition: opacity 0.4s ease, filter 0.4s ease;
    z-index: -1;
}

/* ── Expanded state ── */
.sidebar.is-open {
    width: var(--sidebar-expanded);
}


/* ── Sidebar page-load fade-in ── */
@keyframes sidebar-fade-in {
    from { opacity: 0; }
}

.sidebar.sidebar-fade-in .sidebar-logo-wrap,
.sidebar.sidebar-fade-in .sidebar-nav,
.sidebar.sidebar-fade-in .sidebar-bottom,
.sidebar.sidebar-fade-in::before {
    animation: sidebar-fade-in 0.8s ease 0.3s backwards;
}

/* ── Logo ── */
.sidebar-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--sidebar-collapsed);
    transition: width var(--sidebar-transition), height var(--sidebar-transition), padding var(--sidebar-transition);
    z-index: 1;
    height: 120px;
    padding: 0;
    overflow: hidden;
}

.sidebar.is-open .sidebar-logo-wrap {
    width: var(--sidebar-expanded);
    height: auto;
    padding: 30px 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.sidebar-logo-img {
    height: auto;
    width: auto;
    max-height: max(calc(14px * var(--logo-scale)), calc(0.9vw * var(--logo-scale) * var(--scale)));
    max-width: calc(var(--sidebar-collapsed) - 16px);
    object-fit: contain;
    display: block;
    transform: rotate(-90deg);
    transition: transform var(--sidebar-transition), max-width var(--sidebar-transition);
}

/* When sidebar is open: horizontal logo */
.sidebar.is-open .sidebar-logo-img {
    max-width: calc(var(--sidebar-expanded) - 40px);
    transform: rotate(0deg);
}

.sidebar-logo-text {
    font-family: var(--font1);
    font-size: max(10px, calc(0.7vw * var(--scale)));
    font-weight: var(--text-thickness);
    text-transform: var(--text-style);
    letter-spacing: 0.15em;
    white-space: nowrap;
    color: rgba(255,255,255,0.5);
    transition: transform var(--sidebar-transition);
    transform: rotate(0deg);
}

.sidebar:not(.is-open) .sidebar-logo-text {
    transform: rotate(-90deg);
}

/* ── Nav tiles ── */
.sidebar-nav {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ghost renders {{navigation}} as <ul class="nav"> */
.sidebar-nav .nav {
    display: flex !important;
    flex-direction: column;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: visible;
    gap: 1px;
    opacity: 1 !important;
    height: auto !important;
    background-color: transparent;
    transition: background-color 0.4s ease;
}

.sidebar:hover .sidebar-nav .nav {
    background-color: var(--sidebar-bg);
}

/* Each top-level nav item = one image tile */
.sidebar-nav .nav > li {
    position: relative;
    height: var(--sidebar-nav-height);
    flex: 0 0 var(--sidebar-nav-height);
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
    opacity: var(--sidebar-opacity);
    transition: opacity 0.4s ease;
}

.sidebar:hover .sidebar-nav .nav > li {
    opacity: 1;
}

.sidebar.is-open:hover .sidebar-nav .nav > li > .nav-tile-bg {
    filter: brightness(0.75) saturate(0.95) opacity(0.7);
}

/* Active indicator — floating bar that slides between nav items */
.sidebar-nav-indicator {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: var(--sidebar-nav-height);
    background-color: var(--sidebar-fg);
    z-index: 3;
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    pointer-events: none;
}

/* The anchor link */
.sidebar-nav .nav > li > .nav-link,
.sidebar-nav .nav > li > .links-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    z-index: 2;
    text-decoration: none;
    cursor: pointer;
    font-size: 0;
    color: transparent;
}

/* Image overlay gradient */
.sidebar-nav .nav > li::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0) 40%,
        rgba(0,0,0,0.25) 100%
    );
    z-index: 1;
    transition: opacity 0.4s ease;
    opacity: 0;
}

.sidebar-nav .nav > li:hover::after,
.sidebar-nav .nav > li:has(.nav-link[aria-current="page"])::after {
    opacity: 1;
}

/* Nav item background image */
.sidebar-nav .nav > li > .nav-tile-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.75) saturate(0.95) opacity(0.7) blur(3px);
    transition: filter 0.5s ease, transform 0.7s cubic-bezier(0.16,1,0.3,1);
    z-index: 0;
}

/* Expanded: nearly full brightness */
.sidebar.is-open .sidebar-nav .nav > li > .nav-tile-bg {
    filter: brightness(0.75) saturate(0.95) opacity(0.7) blur(0.5px);
}


/* Label layout inside the tile */
.nav-tile-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

/* Text label */
.nav-tile-label {
    font-size: max(12px, calc(0.76vw * var(--scale)));
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: var(--text-style);
    color: #fff;
    white-space: nowrap;
    transform: rotate(-90deg);
    pointer-events: none;
    opacity: 1;
    color: #fff;
    transition: opacity 0.06s ease, color 0.12s ease;
}

/* Collapsed: dim non-active nav labels */
.sidebar:not(.is-open) .sidebar-nav .nav > li .nav-tile-label {
    opacity: 0.6;
}

.sidebar:not(.is-open) .sidebar-nav .nav > li:has(.nav-link[aria-current="page"]) .nav-tile-label {
    opacity: 1;
}

/* Hide text during transition */
.sidebar.is-transitioning .nav-tile-label {
    opacity: 0;
    color: rgba(255,255,255,0.2);
    transition: opacity 0.08s ease, color 0.05s ease;
}

/* Expanded: larger, horizontal */
.sidebar.is-open .nav-tile-label {
    transform: rotate(0deg);
    font-size: max(13px, calc(0.9vw * var(--scale)));
    font-weight: 600;
    letter-spacing: 0.1em;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.06s ease, color 0.12s ease;
}

.sidebar.is-open .sidebar-nav .nav > li:hover .nav-tile-label {
    transform: rotate(0deg) translateY(-3px);
}

/* Sub-menu (2nd level) — hidden */
.sidebar-nav .nav > li .secondary-links {
    display: none;
}

/* ── Sidebar SVG icon color override ── */
.sidebar svg [fill] {
    fill: var(--sidebar-fg);
}

.sidebar svg [stroke] {
    stroke: var(--sidebar-fg);
}

/* ── Bottom search (sticky) ── */
.sidebar-bottom {
    height: 50px;
    min-height: 50px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-util-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: opacity 0.3s;
    color: var(--sidebar-fg);
    text-decoration: none;
    cursor: pointer;
}

.sidebar-util-btn:hover {
    opacity: 0.8;
}

.sidebar-util-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Mobile toggle button (desktop hidden) ── */
.sidebar-toggle-mobile {
    display: none;
}

/* ── Mobile overlay backdrop ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════
   MOBILE  (≤ 991px)
   Sidebar becomes full-screen overlay drawer
═══════════════════════════════════════════════ */
@media (max-width: 991px) {
    :root {
        --sidebar-collapsed: 0px;
        --sidebar-expanded: 280px;
    }

    .sidebar {
        width: 0;
        opacity: 1;
    }

    /* Mobile toggle button — fixed, always visible */
    .sidebar-toggle-mobile {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        width: 56px;
        height: 56px;
        align-items: center;
        justify-content: center;
        background-color: var(--sidebar-bg);
        border: none;
        padding: 0;
        cursor: pointer;
        z-index: 202;
    }

    .sidebar-toggle-lines {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .sidebar-toggle-lines span {
        display: block;
        width: 18px;
        height: 1px;
        background-color: var(--sidebar-fg);
        transition: transform 0.4s ease, opacity 0.3s ease;
        transform-origin: center;
    }

    body.sidebar-is-open .sidebar-toggle-mobile .sidebar-toggle-lines span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }
    body.sidebar-is-open .sidebar-toggle-mobile .sidebar-toggle-lines span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    body.sidebar-is-open .sidebar-toggle-mobile .sidebar-toggle-lines span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .sidebar.is-open {
        width: var(--sidebar-expanded);
    }

    /* On mobile, logo always horizontal */
    .sidebar:not(.is-open) .sidebar-logo-img {
        transform: rotate(0deg);
    }
    .sidebar:not(.is-open) .sidebar-logo-text {
        transform: rotate(0deg);
    }

    /* Remove blur on mobile — not needed for overlay drawer */
    .sidebar::before {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .sidebar-backdrop {
        display: block;
        pointer-events: none;
    }

    body.sidebar-is-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .horizontal-outer {
        padding-top: 0;
    }
}

@media (max-width: 479px) {
    .sidebar-toggle-mobile {
        width: 48px;
        height: 48px;
    }
}
