﻿/* =========================================
   Layout-specific styles (Header/Nav/Offcanvas)
   Theme: Red / White / Black
   ========================================= */

:root {
    --nav-h: 86px;
    --nav-h-compact: 72px;
    --bg: #0b0b0f;
    --panel: rgba(15, 15, 18, 0.72);
    --panel-strong: rgba(10, 10, 12, 0.92);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.66);
    --red: #ff2a2a;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --ease-fast: cubic-bezier(.2, .9, .2, 1);
    /* ✅ WhatsApp */
    --wa: #25D366;
    --ring-wa: 0 0 0 4px rgba(37, 211, 102, 0.22);
    /* FAB */
    --fab-size: 48px;
    --fab-right: 18px;
    --fab-bottom: 18px;
    --fab-gap: 12px;
    /* ✅ Single source of truth for action height (Logout + Switch image) */
    --action-h: 34px;
}

/* Topbar */
.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--nav-h);
    z-index: 1000;
    background: #BF0000;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    transition: height 220ms var(--ease), transform 240ms var(--ease), background 240ms var(--ease), border-color 240ms var(--ease);
    will-change: transform, height;
}

    .topbar.is-compact {
        height: var(--nav-h-compact);
        background: rgba(8,8,10,0.76);
        border-color: rgba(255,255,255,0.12);
    }

    .topbar.is-hidden {
        transform: translateY(-110%);
    }

.topbar__inner {
    height: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
}

/* Brand */
.brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 170px;
    text-decoration: none;
    user-select: none;
}

.brand__logo {
    width: clamp(140px, 16vw, 210px);
    height: clamp(30px, 3.6vw, 42px);
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 12px 18px rgba(0,0,0,0.45));
}

/* Desktop Nav */
.topbar__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 0vw, 22px);
    padding-block: 3px;
    margin-block: -3px;
}

.navlink {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    font-weight: 650;
    letter-spacing: 0.2px;
    font-size: 14.5px;
    border: 1px solid transparent;
    transition: transform 180ms var(--ease-fast), background 180ms var(--ease-fast), border-color 180ms var(--ease-fast), color 180ms var(--ease-fast), box-shadow 180ms var(--ease-fast);
    will-change: transform;
}

    .navlink:hover,
    .navlink:focus-visible {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.12);
        transform: translateY(-1px);
        outline: none;
        box-shadow: 0 16px 28px -20px rgba(0,0,0,0.85), 0 1px 0 rgba(255,255,255,0.10) inset;
    }

    .navlink.is-active,
    .navlink[aria-current="page"] {
        background: rgba(255,255,255,0.10);
        border-color: rgba(255,255,255,0.20);
        box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset;
    }

/* Actions */
.topbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-block: 3px;
    margin-block: -3px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    height: var(--action-h);
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 750;
    letter-spacing: 0.2px;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: transform 180ms var(--ease-fast), box-shadow 180ms var(--ease-fast), background 180ms var(--ease-fast), border-color 180ms var(--ease-fast), filter 180ms var(--ease-fast);
}

.btn--ghost {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.92);
}

    .btn--ghost:hover {
        transform: translateY(-1px);
        background: rgba(255,255,255,0.08);
        border-color: rgba(255,255,255,0.18);
        box-shadow: 0 16px 28px -20px rgba(0,0,0,0.85), 0 1px 0 rgba(255,255,255,0.10) inset;
    }

.btn--primary {
    color: #0b0b0f;
    border-color: rgba(255, 42, 42, 0.55);
    background: white;
    box-shadow: 0 18px 40px rgba(255, 42, 42, 0.25), 0 10px 22px rgba(0, 0, 0, 0.35);
}

    .btn--primary:hover {
        transform: translateY(-1px);
        filter: saturate(1.05) contrast(1.03);
        box-shadow: 0 22px 55px rgba(255, 42, 42, 0.30), 0 12px 26px rgba(0, 0, 0, 0.40);
    }

.btn--block {
    width: 100%;
}

.btn:focus-visible,
.mode-pill:focus-visible,
.icon-btn:focus-visible,
.to-top:focus-visible,
.fab-wa:focus-visible,
.offlink:focus-visible,
.navlink:focus-visible {
    outline: none;
}

/* ✅ Mode pill as PNG image (same height as Logout) */
.mode-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--action-h);
    line-height: 0;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
    user-select: none;
}

    .mode-pill:hover {
        background: transparent !important;
        box-shadow: none !important;
    }

.mode-pill__img {
    display: block;
    height: 31px; /* ✅ exact same height */
    width: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* Icon button */
.icon-btn {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text);
    cursor: pointer;
    transition: transform 180ms var(--ease-fast), background 180ms var(--ease-fast), border-color 180ms var(--ease-fast), box-shadow 180ms var(--ease-fast);
}

    .icon-btn:hover,
    .icon-btn:focus-visible {
        transform: translateY(-1px);
        background: rgba(255,255,255,0.07);
        border-color: rgba(255,255,255,0.16);
        box-shadow: 0 14px 35px rgba(0,0,0,0.35);
    }

.topbar__burger {
    display: none;
}

.burger {
    width: 20px;
    height: 14px;
    display: inline-block;
    position: relative;
    background: var(--red);
    height: 2px;
    border-radius: 999px;
}

    .burger::before,
    .burger::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        height: 2px;
        border-radius: 999px;
        background: white;
    }

    .burger::before {
        top: -6px;
    }

    .burger::after {
        bottom: -6px;
    }

/* Offcanvas */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 220ms var(--ease);
}

    .overlay.is-open {
        opacity: 1;
    }

.offcanvas {
    position: fixed;
    inset: 0;
    z-index: 1200;
    pointer-events: none;
}

.offcanvas__panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    height: 100%;
    background: rgba(12,12,14,0.96);
    border-right: 1px solid rgba(255,255,255,0.10);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 260ms var(--ease);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    padding: 14px 14px 16px;
}

.offcanvas.is-open .offcanvas__panel {
    transform: translateX(0);
}

.offcanvas__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 6px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.offcanvas__brand {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.offcanvas__close .x {
    width: 18px;
    height: 18px;
    position: relative;
    display: inline-block;
}

    .offcanvas__close .x::before,
    .offcanvas__close .x::after {
        content: "";
        position: absolute;
        inset: 0;
        margin: auto;
        width: 18px;
        height: 2px;
        border-radius: 999px;
        background: var(--red);
    }

    .offcanvas__close .x::before {
        transform: rotate(45deg);
    }

    .offcanvas__close .x::after {
        transform: rotate(-45deg);
    }

.offcanvas__nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 6px 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.offlink {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    font-weight: 720;
    font-size: 15px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    transition: transform 180ms var(--ease-fast), background 180ms var(--ease-fast), border-color 180ms var(--ease-fast), box-shadow 180ms var(--ease-fast);
}

    .offlink:hover,
    .offlink:focus-visible {
        transform: translateY(-1px);
        background: rgba(255,255,255,0.07);
        border-color: rgba(255,255,255,0.16);
        box-shadow: 0 18px 30px -22px rgba(0,0,0,0.90), 0 1px 0 rgba(255,255,255,0.10) inset;
    }

    .offlink.is-active,
    .offlink[aria-current="page"] {
        background: rgba(255,255,255,0.09);
        border-color: rgba(255,255,255,0.18);
        box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset;
    }

.offcanvas__divider {
    height: 1px;
    background: rgba(255,255,255,0.10);
    margin: 6px 0;
}

.offcanvas__footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 6px 0;
}

.muted {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.5;
}

/* Page spacing */
.page {
    padding-top: var(--nav-h);
    min-height: 100dvh;
    transition: padding-top 220ms var(--ease);
}

.topbar.is-compact ~ .page {
    padding-top: var(--nav-h-compact);
}

/* WhatsApp FAB */
.fab-wa {
    position: fixed;
    right: var(--fab-right);
    bottom: var(--fab-bottom);
    z-index: 950;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    display: grid;
    place-items: center;
    text-decoration: none;
    color: var(--wa);
    transition: bottom 180ms var(--ease-fast), transform 180ms var(--ease-fast), background 180ms var(--ease-fast), box-shadow 180ms var(--ease-fast);
}

    .fab-wa:focus-visible {
        box-shadow: var(--ring-wa), var(--shadow-soft);
    }

    .fab-wa:hover,
    .fab-wa:focus-visible {
        background: rgba(255,255,255,0.10);
        box-shadow: 0 18px 45px rgba(0,0,0,0.45);
        transform: translateY(-1px);
    }

    .fab-wa.is-raised {
        bottom: calc(var(--fab-bottom) + var(--fab-size) + var(--fab-gap));
    }

/* Scroll to top */
.to-top {
    position: fixed;
    right: var(--fab-right);
    bottom: var(--fab-bottom);
    z-index: 950;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms var(--ease-fast), transform 180ms var(--ease-fast), background 180ms var(--ease-fast);
}

    .to-top.is-visible {
        opacity: 1;
        transform: translateY(0);
    }

    .to-top:hover,
    .to-top:focus-visible {
        background: rgba(255,255,255,0.10);
        box-shadow: 0 18px 45px rgba(0,0,0,0.45);
    }

.to-top__icon {
    width: 16px;
    height: 16px;
    position: relative;
}

    .to-top__icon::before {
        content: "";
        position: absolute;
        inset: 0;
        margin: auto;
        width: 10px;
        height: 10px;
        border-left: 2px solid rgba(255,255,255,0.92);
        border-top: 2px solid rgba(255,255,255,0.92);
        transform: rotate(45deg);
    }

    .to-top__icon::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 9px;
        margin: auto;
        width: 2px;
        height: 10px;
        border-radius: 999px;
        background: var(--red);
    }

body.menu-open {
    overflow: hidden;
    touch-action: none;
}

/* Responsive */
/* ✅ Small screen: Logo center + topbar actions rule */
@media (max-width: 1060px) {
    .topbar__nav {
        display: none;
    }

    .topbar__burger {
        display: inline-grid;
    }

    /* ✅ perfect center logo */
    .topbar__inner {
        grid-template-columns: 1fr auto 1fr;
    }

    .topbar__burger {
        justify-self: start;
    }

    .brand {
        justify-self: center;
        min-width: 0;
    }

    .topbar__actions {
        justify-self: end;
    }

    /* ✅ Signed-in: show ONLY logout on topbar */
    .is-signed-in .topbar__actions > a {
        display: none !important;
    }
    /* hides mode-pill & profile link */
    .is-signed-in .topbar__actions > form {
        display: none !important;
    }
        /* hide all forms first */
        .is-signed-in .topbar__actions > form.logout-form {
            display: block !important;
        }
    /* show only logout form */
}

/* Small phones */
@media (max-width: 420px) {
    :root {
        --action-h: 40px;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .brand__logo {
        width: 160px;
        height: 34px;
    }

    .to-top,
    .fab-wa {
        right: 14px;
        bottom: 14px;
        width: 46px;
        height: 46px;
    }

        .fab-wa.is-raised {
            bottom: calc(14px + 46px + 12px);
        }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .page, .topbar, .navlink, .btn, .mode-pill, .icon-btn, .overlay, .offcanvas__panel, .to-top, .offlink, .fab-wa {
        transition: none !important;
    }
}
