/* MoonlightWeb — Layout: app shell (header, main, footer) */

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    /* Mobile: viewport-fit=cover + translucent status bar push content under
       the notch/status bar — inset the header so the title stays visible. */
    padding-top: max(var(--space-3), env(safe-area-inset-top));
    padding-left: max(var(--space-5), env(safe-area-inset-left));
    padding-right: max(var(--space-5), env(safe-area-inset-right));
    background: var(--surface-glass);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid var(--border-1);
    box-shadow: var(--shadow-1);
    flex-shrink: 0;
    z-index: 100;
}

/* The product name, here and on the stream's own bar (.stream-brand-title in
   stream.css). ONE rule for both, not two that look alike: the stream bar exists
   to carry the same three facts the header carries, and a reader who sees them
   set differently reads two different things. text-transform is spelled out
   because base.css gives it to h1 and the stream's copy is not one. */
.app-header h1,
.stream-brand-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-1);
    text-shadow: 0 0 12px var(--accent-ring);
}

.version {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-2);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    /* The version is a fixed short token; letting it shrink would hyphenate a
       number. The instance name beside it is the elastic one. */
    flex-shrink: 0;
}

/* ── Instance name / switcher ───────────────────────────────────────────────
   Which machine this page is talking to. A plain label while the browser knows
   only one; a dropdown the moment it knows two, with the caret as the only
   standing hint and a background lift on hover as the confirmation.

   Both states share the same box metrics on purpose: gaining a second machine
   must not shift the header's layout, or the whole bar would jump the first
   time someone visits a new PC. */
.instance-menu {
    position: relative;
    /* The one part of the header that may give up space: the title, the version
       tag and the action buttons are all fixed-size. */
    min-width: 0;
    flex-shrink: 1;
}

.instance-name {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-2);
    /* One line, always. A machine name is a label, not a sentence, and a header
       that wraps is a header that changes height. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* The plain-label state carries the button's own padding so the two states line
   up with the title identically. */
.instance-menu:not(.has-menu) .instance-name {
    padding: 3px 8px;
}

.instance-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 100%;
    padding: 3px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    transition:
        background-color 0.12s ease,
        border-color 0.12s ease;
}

/* The whole affordance, in two lines: something to hover, and something that
   answers. Deliberately quiet — this sits next to the product name, and a neon
   button there would read as the page's primary action, which it is not. */
.instance-btn:hover,
.instance-menu.is-open .instance-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-1);
}
.instance-btn:hover .instance-name,
.instance-menu.is-open .instance-name {
    color: var(--text-1);
}

.instance-btn:focus-visible {
    outline: 1px solid var(--border-2);
    outline-offset: 1px;
}

.instance-caret {
    display: flex;
    flex-shrink: 0;
    color: var(--text-3);
    transition:
        transform 0.12s ease,
        color 0.12s ease;
}
.instance-caret .icon {
    width: 14px;
    height: 14px;
}
.instance-btn:hover .instance-caret {
    color: var(--text-2);
}
.instance-menu.is-open .instance-caret {
    transform: rotate(180deg);
    color: var(--text-2);
}

.instance-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 2 * var(--space-4)));
    padding: var(--space-1);
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
}

.instance-panel-title {
    margin: 0;
    padding: var(--space-2) var(--space-3) var(--space-1);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.instance-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: inherit;
    font-size: var(--fs-sm);
    text-align: left;
    cursor: pointer;
}
.instance-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.instance-item.is-current {
    color: var(--accent-1);
    cursor: default;
}
.instance-item-icon {
    display: flex;
    flex-shrink: 0;
    color: var(--text-3);
}
.instance-item.is-current .instance-item-icon {
    color: inherit;
}
.instance-item-icon .icon {
    width: 15px;
    height: 15px;
}
.instance-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Reserved whether or not it holds a tick, so the names of the other machines
   line up with the current one instead of sitting a check-width to its left. */
.instance-item-mark {
    display: flex;
    flex-shrink: 0;
    width: 15px;
}
.instance-item-mark .icon {
    width: 15px;
    height: 15px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

/* ── Main content — the ONLY scroll container of the app ────────────────── */
#main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-6) var(--space-5) var(--space-8);
    width: 100%;
}

/* Inner views are centered with a max width — the scrollbar stays on the
   right edge of the viewport, below the header. */
.hosts-view,
.apps-view,
.settings-view,
.admin-view,
.login-view {
    max-width: 960px;
    margin: 0 auto;
}

.settings-view,
.admin-view {
    max-width: 680px;
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: var(--space-2) var(--space-5);
    /* Extend the footer's dark background into the home-indicator safe area
       so its text clears the indicator and no white bar shows underneath. */
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    padding-left: max(var(--space-5), env(safe-area-inset-left));
    padding-right: max(var(--space-5), env(safe-area-inset-right));
    font-size: var(--fs-xs);
    color: var(--text-3);
    border-top: 1px solid var(--border-1);
    background-color: rgba(13, 17, 24, 0.6);
    flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #main-content {
        padding: var(--space-3);
    }

    .app-header {
        padding: var(--space-3) var(--space-4);
        /* Keep the safe-area insets — the shorthand above would otherwise
           reset padding-top and let the title slide under the status bar. */
        padding-top: max(var(--space-3), env(safe-area-inset-top));
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
        gap: var(--space-2);
    }

    /* Of the two tags beside the title, one has to go on a phone, and it is
       this one: the version answers a question nobody asks twice and is still
       on the admin page, while the machine name answers "which PC am I looking
       at?" — which is the question a second device makes urgent. */
    .version {
        display: none;
    }
}
