/*
 * layout.css
 *
 * App shell: header (GB mark + title, floating tab bar, Dev switch),
 * content area with the main column + floating side sheet, and the floating
 * mobile bottom navigation.
 */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    height: auto;
    overflow: visible;
    background: var(--ground);
}

/* ---------- Header ---------- */

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
}

.app-header__brand,
.app-header__end {
    flex: 1 1 0;
    min-width: 200px;
    display: flex;
    align-items: center;
}

.app-header__brand {
    gap: 12px;
}

.app-header__end {
    justify-content: flex-end;
}

.gb-mark {
    width: 44px;
    height: 44px;
    border-radius: var(--r-14);
    background: var(--ink);
    color: var(--on-fill);
    font-weight: 800;
    font-size: var(--fs-button);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.app-header__titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header__title {
    font-weight: 800;
    font-size: var(--fs-button);
}

.app-header__subtitle {
    font-size: var(--fs-secondary);
    color: var(--muted);
    white-space: nowrap;
}

.tabbar {
    display: flex;
    gap: 4px;
    padding: 5px;
    border-radius: var(--r-pill);
    background: var(--surface);
    box-shadow: var(--shadow-float);
}

.tabbar a {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border-radius: var(--r-pill);
    color: var(--text-2);
    text-decoration: none;
    font-weight: 600;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.tabbar a:active,
.mobile-nav-item:active {
    transform: scale(.96);
}

@media (hover: hover) and (pointer: fine) {
    .tabbar a:hover {
        color: var(--ink);
    }
}

.tabbar a svg {
    display: none;
}

.tabbar a.active {
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-weight: 700;
}

.tabbar a.active svg {
    display: block;
}

/* ---------- Content ---------- */

.content-area {
    flex: 1;
    display: block;
    height: auto;
    overflow: visible;
    padding: 0 20px 20px;
    background: transparent;
}

.view {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
}

.view-main {
    flex: 999 1 560px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Basket, transaction detail and customer profile share one width */
.view-side {
    flex: 1 1 420px;
    min-width: 0;
    max-width: 100%;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
}

.view-side > .sheet {
    /* fits below the header on first view, and while stuck to the top on scroll */
    max-height: calc(100vh - 104px);
    max-height: calc(100dvh - 104px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

@media (max-width: 1099px) and (min-width: 901px) {
    .view-side {
        flex-basis: 360px;
    }
}

/* ---------- Tablets: let the header ends shrink so it stays on one row ---------- */

@media (max-width: 1023px) {
    .app-header__brand,
    .app-header__end {
        min-width: 0;
    }

    .app-header__end {
        flex: 0 0 auto;
    }
}

/* ---------- Mobile bottom navigation ---------- */

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 767px) {
    .app-header {
        padding: 12px 16px;
    }

    .app-header .tabbar {
        display: none;
    }

    .app-header__brand,
    .app-header__end {
        min-width: 0;
    }

    .content-area {
        padding: 0 16px calc(96px + env(safe-area-inset-bottom));
        height: auto;
        overflow: visible;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 50%;
        bottom: calc(12px + env(safe-area-inset-bottom));
        transform: translateX(-50%);
        z-index: var(--z-mobile-nav);
        display: flex;
        gap: 2px;
        padding: 5px;
        width: min(440px, calc(100vw - 24px));
        border-radius: var(--r-pill);
        background: var(--surface);
        box-shadow: var(--shadow-float), 0 0 0 1px var(--hairline);
    }

    .mobile-nav-item {
        flex: 1;
        min-width: 0;
        height: 54px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border-radius: var(--r-pill);
        color: var(--text-2);
        text-decoration: none;
        font-size: var(--fs-micro);
        font-weight: 600;
        background: transparent;
        padding: 0;
    }

    .mobile-nav-item svg {
        width: 22px;
        height: 22px;
        opacity: 1;
    }

    .mobile-nav-item.active {
        background: var(--accent-tint);
        color: var(--accent-strong);
        font-weight: 700;
    }

    .view-side {
        position: static;
        max-height: none;
    }
}
