/* layout.css — app shell: header, context bar, screen frame, dialogs, footer. */

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16.8px;
    flex-wrap: wrap;
    padding: 11.2px 22.4px;
    background: color-mix(in srgb, #161826 92%, transparent);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 var(--color-divider);
}

.app-brand {
    margin-right: auto;
    display: flex;
    align-items: baseline;
    gap: 8.4px;
}

.app-brand-name {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 18px;
    letter-spacing: -0.015em;
}

.app-brand-region {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-accent);
}

.screen-nav.seg { white-space: nowrap; }
.screen-nav .seg-opt {
    background: none;
    border: 0;
    font: inherit;
    font-size: 13px;
    color: var(--color-text);
}
.screen-nav .seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.screen-nav .seg-opt[aria-selected="true"] {
    color: var(--color-accent);
    box-shadow: inset 0 0 0 1px var(--color-accent);
}
.screen-nav .seg-opt:not([aria-selected="true"]):hover {
    background: color-mix(in srgb, var(--color-text) 7%, transparent);
}

/* ── Context bar ────────────────────────────────────────────────────────── */
.context-bar {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16.8px 22.4px 0;
    display: flex;
    align-items: center;
    gap: 11.2px;
    flex-wrap: wrap;
}

.context-chip {
    display: inline-flex;
    align-items: center;
    gap: 8.4px;
    padding: 5.6px 11.2px;
    border: 1px solid var(--color-divider);
    border-radius: 8px;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
}
.context-chip:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.context-chip > .ph { color: var(--color-accent); }
.context-chip-label { font-size: 14px; }
.context-chip-detail { font-size: 12px; color: var(--color-neutral-500); }
.context-chip-detail:empty { display: none; }

.context-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8.4px;
}

.context-feedback {
    flex-basis: 100%;
    margin: 0;
    font-size: 12px;
    color: var(--color-neutral-400);
}
.context-bar .form-error { flex-basis: 100%; }

/* ── Main frame + screens ───────────────────────────────────────────────── */
.app-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16.8px 22.4px 44.8px;
}

.screen[hidden] { display: none; }
.screen {
    animation: screen-in 200ms cubic-bezier(.22,.61,.36,1) both;
}
@keyframes screen-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ── Empty + error states ───────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 11.2px;
    padding: 56px 22.4px;
    color: var(--color-neutral-400);
}
.empty-state .ph { font-size: 34px; color: var(--color-accent); }
.empty-state p { margin: 0; max-width: 46ch; font-size: 14px; }

.error-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 11.2px;
    padding: 44.8px 22.4px;
    border-radius: 14px;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}
.error-card .ph { font-size: 30px; color: var(--color-accent); }
.error-card p { margin: 0; font-size: 14px; max-width: 52ch; }

/* ── Dialogs ────────────────────────────────────────────────────────────── */
.dialog-backdrop { z-index: 60; }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(460px, 100%); max-height: calc(100vh - 44.8px); overflow-y: auto; }
.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 11.2px;
}
.dialog .field { margin-top: 11.2px; }
.dialog .date-presets { display: flex; margin-top: 5.6px; }
.dialog-actions { align-items: center; }

#picker-map {
    width: 100%;
    height: 300px;
    border-radius: 8px;
    border: 1px solid var(--color-divider);
    touch-action: none;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.app-footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22.4px;
}
.app-footer p { margin: 0; font-size: 11px; color: var(--color-neutral-600); }
.app-footer p + p { margin-top: 5.6px; }
.app-footer a { color: var(--color-neutral-500); }

/* ── Mobile: bottom tab bar + bottom sheets ─────────────────────────────── */
@media (max-width: 700px) {
    /* No backdrop-filter here: it makes the header the containing block for
       position:fixed children, so the bottom tab bar (which lives inside
       the header) would no longer be pinned to the viewport. */
    .app-header { padding: 11.2px 16.8px; backdrop-filter: none; background: #161826; }
    .context-bar { padding: 11.2px 16.8px 0; }
    .app-main { padding: 11.2px 16.8px 88px; }

    .context-chip { flex: 1 1 100%; }
    .context-actions { flex: 1 1 100%; }
    .context-actions .btn-primary { flex: 1; }

    .screen-nav.seg {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        display: flex;
        border: 0;
        border-top: 1px solid var(--color-divider);
        border-radius: 0;
        background: color-mix(in srgb, #161826 96%, transparent);
        backdrop-filter: blur(8px);
    }
    .screen-nav .seg-opt {
        flex: 1;
        flex-direction: column;
        gap: 2.8px;
        min-height: 56px;
        padding: 8.4px 4px;
        font-size: 11px;
        border-left: 0 !important;
    }
    .screen-nav .seg-opt[aria-selected="true"] { box-shadow: none; }
    .screen-nav .seg-opt .ph { font-size: 18px; }

    .dialog-backdrop { align-items: flex-end; padding: 0; }
    .dialog {
        width: 100%;
        border-radius: 14px 14px 0 0;
        max-height: 88vh;
    }
    .dialog::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        margin: 0 auto 8.4px;
        border-radius: 2px;
        background: var(--color-neutral-700);
    }
}
