/* =========================================
   SIDEBAR + OVERLAY (v10) — STABLE
   - JS: overlay.classList.toggle('open')
   - JS: html/body kapja a 'sidebar-open' class-t
   - Cél: gyors nyitás, stabil scroll iOS-en is
   ========================================= */

:root {
    --sidebar-speed: 200ms;
    --sidebar-ease: cubic-bezier(.2, .8, .2, 1);
}

/* Scroll lock csak nyitott menünél */
html.sidebar-open,
body.sidebar-open {
    overflow: hidden;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 110;

    background: rgba(0, 0, 0, .48);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 160ms ease, visibility 0s linear 160ms;
}

.overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transition: opacity 160ms ease, visibility 0s linear 0s;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 120;

    width: min(100%, 780px);

    transform: translateX(100%);
    transition: transform var(--sidebar-speed) var(--sidebar-ease);

    display: flex;
    flex-direction: column;

    background: rgba(15, 16, 18, .96);
    border-left: 1px solid rgba(255, 255, 255, .08);

    height: 100dvh;
    /* modern */
    max-height: 100dvh;
    /* modern */

    outline: none;

    /* Performance: blur OFF */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Blur csak opt-in */
html.allow-blur .sidebar {
    background: rgba(15, 16, 18, .90);
}

@supports ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
    html.allow-blur .sidebar {
        backdrop-filter: blur(10px) saturate(120%);
        -webkit-backdrop-filter: blur(10px) saturate(120%);
    }
}

.sidebar.open {
    transform: translateX(0);
}

/* Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;

    font-weight: 800;
    color: #fff;
}

.sidebar-close {
    height: 34px;
    min-width: 34px;

    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #181a1f;
    color: #fff;

    display: grid;
    place-items: center;
    cursor: pointer;

    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.sidebar-close:hover {
    background: #1d2026;
    border-color: rgba(255, 255, 255, .18);
}

.sidebar-close:active {
    transform: translateY(1px);
}

/* Search */
.sidebar-search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;

    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-search input[type="search"] {
    height: 40px;
    padding: 0 12px;

    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .14);

    background: rgba(23, 25, 30, .95);
    color: #fff;

    font-weight: 600;
    letter-spacing: .2px;
}

.sidebar-search input[type="search"]::placeholder {
    color: rgba(255, 255, 255, .45);
}

.sidebar-search button {
    height: 40px;
    min-width: 40px;

    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .14);

    background: rgba(23, 25, 30, .95);
    color: #fff;

    font-weight: 900;
    cursor: pointer;

    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.sidebar-search button:hover {
    background: rgba(28, 31, 38, .95);
    border-color: rgba(255, 255, 255, .18);
}

.sidebar-search button:active {
    transform: translateY(1px);
}

/* NAV (scroll) */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;

    padding: 12px 12px 18px;
    display: grid;
    gap: 8px;

    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.nav-group__title {
    margin: 10px 8px 2px;
    font-size: 12px;
    letter-spacing: .3px;
    color: rgba(255, 255, 255, .55);
    text-transform: uppercase;
    font-weight: 800;
}

.nav-link {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 10px;

    min-height: 44px;
    padding: 10px 12px;

    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .02);

    /* transform hover OFF (kevesebb jank) */
    transition: background 140ms ease, border-color 140ms ease;

    font-size: 14px;
    color: #fff;
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .14);
}

.nav-link.is-active {
    border-color: rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .08);
}

.nav-ico {
    width: 28px;
    height: 28px;

    display: grid;
    place-items: center;

    border-radius: 8px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-ico svg {
    width: 18px;
    height: 18px;
    display: block;
}

.nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link.hidden {
    display: none !important;
}

@media (max-width: 420px) {
    .sidebar {
        width: 100%;
    }

    .nav-link {
        grid-template-columns: 24px 1fr;
        padding: 10px;
    }

    .nav-ico {
        width: 24px;
        height: 24px;
    }

    .nav-ico svg {
        width: 16px;
        height: 16px;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {

    .sidebar,
    .overlay,
    .nav-link,
    .sidebar-close,
    .sidebar-search button {
        transition: none !important;
    }
}