/* ── header-2026.css ───────────────────────────────────────────────────────
   Shared structural CSS for the header-2026 desktop sidebar.
   Include in both GoBrik and Buwana — no brand colours here.

   On viewports ≥ 1201px the main-menu overlay becomes a fixed 360px sidebar
   that slides in from the left and pushes #page-content to the right.
   Below 1201px the existing full-screen overlay behaviour is preserved.
-------------------------------------------------------------------------- */

@media screen and (min-width: 1201px) {

    /* The menu panel itself */
    #main-menu-overlay.sidebar-panel {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 360px !important;        /* fixed width, not 100% */
        display: flex !important;       /* always rendered; visibility driven by transform */
        flex-direction: column;
        transform: translateX(-360px);  /* hidden off-screen to the left */
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: hidden;
        overflow-x: hidden;
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }

    #main-menu-overlay.sidebar-panel.sidebar-open {
        transform: translateX(0);       /* slides in */
    }

    /* Push the page content to the right when the sidebar is open */
    #page-content.sidebar-pushed {
        margin-left: 360px;
        max-width: calc(100vw - 360px);
        overflow-x: clip; /* clip does not create a scroll container — avoids double-scroll */
        transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Compress #main to fit within the remaining viewport width */
    #page-content.sidebar-pushed #main {
        max-width: 100%;
        box-sizing: border-box;
    }

    #page-content {
        transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Slide the fixed header to match the remaining viewport space */
    #header {
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    top 0.3s ease, height 0.3s ease, transform 0.3s ease;
    }

    body.sidebar-is-open #header {
        width: calc(100vw - 360px);
    }

    /* Remove the hamburger from layout (not just hidden) so logo fills the space */
    body.sidebar-is-open .side-menu-button {
        display: none;
    }

    /* Center the Buwana/app logo within the remaining header space.
       margin-right: 70px was there to counterbalance the hamburger button;
       once the hamburger is hidden the offset must be cleared so the
       background-position:center re-centres relative to the full flex column. */
    body.sidebar-is-open #buwana-top-logo,
    body.sidebar-is-open #top-app-logo {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* Keep the settings/login buttons pinned to the top-right of the
       adjusted (shifted) header — they must not drift with the logo. */
    body.sidebar-is-open #function-icons {
        flex-shrink: 0;
        margin-left: auto;
    }

    /* X close button — top-right corner of the sidebar */
    #main-menu-overlay.sidebar-panel .sidebar-close-btn {
        display: flex;
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 201;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 1.4rem;
        line-height: 1;
        color: var(--text-color);
        padding: 6px 8px;
        border-radius: 6px;
        opacity: 0.7;
        transition: opacity 0.2s, background 0.2s;
    }

    #main-menu-overlay.sidebar-panel .sidebar-close-btn:hover {
        opacity: 1;
        background: rgba(128,128,128,0.15);
    }

    /* Hide the original overlay-style X button on desktop */
    #main-menu-overlay.sidebar-panel > .x-button:not(.sidebar-close-btn) {
        display: none;
    }

    /* Make the logo holder & content fill the column layout */
    #main-menu-overlay.sidebar-panel .overlay-content-settings {
        flex: 1;
        overflow-y: auto;
        padding-top: 10px;
    }
}

/* ── Side-menu typography — shared across GoBrik and Buwana ──────────────── */

/* App slogan line beneath the menu items */
.app-slogan {
    font-family: 'Mulish', sans-serif;
    color: var(--subdued-text);
    font-size: 1.0em;
    margin-top: 30px;
    text-align: center;
    padding: 0 12px;
}

/* "Authentication by …" / "Authentication by Buwana" label */
.menu-auth-by {
    font-family: 'Arvo', serif;
    font-size: smaller;
    text-align: center;
    margin: auto;
    margin-bottom: 5px;
    color: var(--subdued-text);
}

/* ── Settings Expand Panel (header-2026b) ────────────────────────────────── *
 *                                                                             *
 *  The #settings-buttons div acts as the whole panel. It is position:        *
 *  absolute within #header, slides in from the right (existing behaviour),   *
 *  and now also GROWS DOWNWARD when lang or app button is clicked.            *
 *  The grids (#language-menu-slider, #login-menu-slider) live inside it.     *
 * -------------------------------------------------------------------------- */

/* Keep original off-screen start — with min-width 300px the gear icon
   still peeks ~55px into the viewport (300 - 245 = 55px visible) */
#settings-buttons {
    right: -245px;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    min-width: 300px;
    /* keep existing: transition: right 0.4s ease — added box-shadow below */
    transition: right 0.4s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden; /* clip expand panel to rounded corners */
}

/* The top button row — always visible when settings panel is slid in */
#settings-btn-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px 10px 12px;
    gap: 4px;
    transition: border-bottom 0.2s ease;
}

/* Divider between button row and expanded grid */
#settings-buttons.panel-expanded #settings-btn-row {
    border-bottom: 1px solid var(--divider-line);
}

/* Elevated styling when a grid is showing */
#settings-buttons.panel-expanded {
    box-shadow: 0 10px 36px var(--expand-glow);
    border: 2px solid var(--settings-border);
}

/* The wrapper that expands vertically */
#settings-expand-panel {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

#settings-expand-panel.panel-open {
    max-height: 800px;
}

/* Each interchangeable grid section (lang or apps) */
.expand-grid-section {
    display: none;
    padding: 12px;
}

.expand-grid-section.grid-visible {
    display: block;
    animation: bapFadeDown 0.26s ease forwards;
}

.expand-grid-section.grid-hiding {
    display: block;
    animation: bapFadeUp 0.16s ease forwards;
}

@keyframes bapFadeDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bapFadeUp {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-4px); }
}

/* ── App / language drawer header row ───────────────────────────────────── */

.bap-header {
    display: flex;
    align-items: center;
    padding: 0 4px 8px;
}

/* "+" add-app link — far right of the drawer header */
.bap-add-app {
    margin-left: auto;
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 300;
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.55;
    padding: 0 8px 2px;
    border-radius: 6px;
    transition: opacity 0.18s, background 0.2s;
}

.bap-add-app:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.15);
}

/* Language tile — mirrors .bap-app-tile from main.css */
.bap-lang-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 7px;
    border-radius: 12px;
    background-color: var(--app-tile-bg);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.18s ease;
    gap: 4px;
    border: none;
    color: var(--text-color);
}

.bap-lang-tile:hover {
    background-color: var(--app-tile-bg-hover);
}

.bap-lang-flag {
    font-size: 1.55rem;
    line-height: 1.15;
}

/* ── Fix: reset ID-level positioning that main.css applies to the slider
   elements when they are repurposed as inline expand-panel sections ────────
   #language-menu-slider has position:absolute + opacity:0 + visibility:hidden
   #login-menu-slider   has position:fixed   + display:none
   Both specificity wins over .expand-grid-section, so we need double-ID
   selectors (specificity 2-0-0) + !important to neutralise main.css rules. */

#settings-expand-panel #language-menu-slider,
#settings-expand-panel #login-menu-slider {
    position:         static      !important;
    display:          none        !important;
    opacity:          1           !important;
    visibility:       visible     !important;
    transform:        none        !important;
    box-shadow:       none        !important;
    border:           none        !important;
    background-color: transparent !important;
    padding:          0           !important;
    margin:           0           !important;
    width:            auto        !important;
    max-width:        none        !important;
    max-height:       none        !important;  /* cancel main.css max-height:0 on #language-menu-slider */
    top:              auto        !important;
    right:            auto        !important;
    z-index:          auto        !important;
    border-radius:    0           !important;
    transition:       none        !important;
    flex-direction:   column      !important;
}

#settings-expand-panel #language-menu-slider.grid-visible,
#settings-expand-panel #login-menu-slider.grid-visible {
    display:   block   !important;
    padding:   12px    !important;
    animation: bapFadeDown 0.26s ease forwards;
}

#settings-expand-panel #language-menu-slider.grid-hiding,
#settings-expand-panel #login-menu-slider.grid-hiding {
    display:   block   !important;
    padding:   12px    !important;  /* match grid-visible padding so layout doesn't snap */
    animation: bapFadeUp 0.16s ease forwards;
}

/* ── Alert Modal (non-fullscreen confirmation dialog) ────────────────────── */

.alert-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.alert-modal-box {
    background: var(--form-field-background, #fff);
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
    width: 100%;
    max-width: 460px;
    padding: 28px 28px 24px;
    font-family: 'Mulish', sans-serif;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: alertModalIn 0.22s ease;
}

@keyframes alertModalIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.alert-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-modal-title {
    flex: 1;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--h1);
    line-height: 1.3;
}

.alert-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    padding: 2px 6px;
    color: var(--subdued-text);
    border-radius: 6px;
    transition: background 0.18s, color 0.18s;
    flex-shrink: 0;
}

.alert-modal-close:hover {
    background: rgba(128, 128, 128, 0.15);
    color: var(--h1);
}

.alert-modal-body {
    font-size: 0.97rem;
    line-height: 1.55;
    color: var(--text-color);
}

.alert-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 4px;
}

.alert-modal-btn {
    padding: 9px 20px;
    border: none;
    border-radius: 7px;
    font-family: 'Mulish', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.18s, background 0.18s;
}

.alert-modal-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.alert-modal-btn-cancel {
    background: var(--lighter, #f0f0f0);
    color: var(--text-color);
}

.alert-modal-btn-cancel:hover:not(:disabled) {
    background: var(--light, #e4e4e4);
}

.alert-modal-btn-danger {
    background: #c0392b;
    color: #fff;
}

.alert-modal-btn-danger:hover:not(:disabled) {
    background: #a93226;
}
