/* Chrome — top bar, tabs, status bar.
   Ported from marisight_UI_Desing/styles.css with hex literals replaced by tokens. */

#ms-app { height: 100vh; display: flex; flex-direction: column; }

/* ---- Top bar ---- */
.ms-topbar {
    /* min-height (not a fixed height): when the grouped nav can't fit on one
       line at laptop widths (RTL especially) it wraps to a second row and the
       BAR GROWS rather than the groups clipping/overlapping the page below
       (#topbar-responsive). Wide screens never wrap → stays 52px. The laptop
       media queries below trim the right cluster + compact the nav so the
       wrap is at most one extra row. */
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 14px;
    flex-shrink: 0;
    background: var(--ms-bg2);
    border-bottom: 1px solid var(--ms-panel-border);
    color: var(--ms-text);
}

.ms-brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ms-brand-mark {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--ms-accent);
    color: var(--ms-accent);
    display: grid; place-items: center;
}
.ms-brand-name {
    font-size: 16px; font-weight: 700;
    font-family: var(--ms-font-brand);
    color: var(--ms-text);
}
.ms-brand-sub {
    font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--ms-text-mute);
}

.ms-tabs { display: flex; align-items: center; gap: 4px; flex: 1; }
.ms-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 16px 12px 14px;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: var(--ms-cursor-pointer);
    font-family: inherit;
    color: var(--ms-text-dim);
    text-decoration: none;
    display: inline-block;
}
.ms-tab:hover { color: var(--ms-text); }
.ms-tab.active {
    font-weight: 600;
    color: var(--ms-text);
    border-bottom-color: var(--ms-accent);
}

.ms-topbar-right { display: flex; align-items: center; gap: 14px; }
.ms-live {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    font-family: var(--ms-font-mono);
    letter-spacing: 0.1em;
    color: var(--ms-ok);
}
.ms-dot {
    width: 7px; height: 7px; border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
}
.ms-clock { text-align: end; min-width: 90px; }
.ms-clock-time {
    font-family: var(--ms-font-mono);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--ms-text);
}
.ms-clock-date {
    font-family: var(--ms-font-mono);
    font-size: 10px;
    /* --ms-text-mute on the dark topbar fails WCAG AA 4.5:1 (#a11y-audit);
       --ms-text-dim clears it while staying visually secondary. */
    color: var(--ms-text-dim);
}
.ms-sel {
    background: var(--ms-panel);
    color: var(--ms-text);
    border: 1px solid var(--ms-panel-border);
    border-radius: 0;
    padding: 5px 8px;
    font-size: 11px;
    font-family: var(--ms-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: var(--ms-cursor-pointer);
    outline: none;
}

/* Language switcher gets a globe marker so operators spot the AR↔DE toggle
   at a glance (Tarek 2026-07-18); the select keeps the .ms-sel look. */
.ms-sel-lang {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ms-accent);
}
.ms-sel-lang svg { flex: 0 0 auto; }
.ms-sel-lang .ms-sel { border-color: color-mix(in srgb, var(--ms-accent) 45%, var(--ms-panel-border)); }

/* PWA install button (TopBar) — accent-bordered so it reads as a call to
   action next to the .ms-sel dropdowns. Unhidden by js/pwa.js only when the
   browser supports install and the app isn't installed yet. */
.ms-pwa-install {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ms-panel);
    color: var(--ms-accent);
    border: 1px solid var(--ms-accent);
    border-radius: 0;
    padding: 5px 10px;
    font-size: 11px;
    font-family: var(--ms-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: var(--ms-cursor-pointer);
}
.ms-pwa-install:hover {
    background: var(--ms-accent);
    color: var(--ms-bg);
}
.ms-pwa-install[hidden] { display: none; }

.ms-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px;
    border: 1px solid var(--ms-panel-border);
    border-radius: 2px;
    color: var(--ms-text);
    text-decoration: none;
}
.ms-avatar {
    width: 28px; height: 28px; border-radius: 2px;
    display: grid; place-items: center;
    background: var(--ms-accent);
    color: var(--ms-bg);
    font-weight: 700;
    font-size: 11px;
    font-family: var(--ms-font-mono);
    letter-spacing: 0.05em;
}
.ms-user-name { font-size: 12px; }
.ms-user-role {
    font-size: 10px;
    /* WCAG AA contrast on the dark topbar (#a11y-audit) — see .ms-clock-date. */
    color: var(--ms-text-dim);
    font-family: var(--ms-font-mono);
}
.ms-user-logout-form { display: inline; margin: 0; }
.ms-user-logout {
    background: transparent;
    border: 1px solid var(--ms-panel-border);
    color: var(--ms-text-dim);
    width: 24px; height: 24px;
    margin-inline-start: 6px;
    cursor: var(--ms-cursor-pointer);
    font-size: 13px;
    padding: 0;
    line-height: 1;
}
.ms-user-logout:hover {
    color: var(--ms-alert);
    border-color: var(--ms-alert);
}

/* ---- Status bar ---- */
.ms-status {
    height: 28px;
    display: flex; align-items: center; gap: 22px;
    padding: 0 14px;
    flex-shrink: 0;
    background: var(--ms-bg2);
    border-top: 1px solid var(--ms-panel-border);
    color: var(--ms-text-dim);
    font-size: 11px;
    /* The status chips don't fit a phone width — clip the strip so they never
       expand the document scroll width (#topbar-responsive, RTL). overflow:hidden
       (not auto) keeps it out of the keyboard tab order — passive readout. */
    min-width: 0;
    overflow: hidden;
}
.ms-status > .ms-stat { flex-shrink: 0; }
.ms-stat {
    display: flex; align-items: center; gap: 6px;
    font-family: var(--ms-font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 10px;
}
.ms-stat-value {
    color: var(--ms-text);
    font-family: var(--ms-font-mono);
}
.ms-stat-spacer { flex: 1; }
.ms-stat-build {
    color: var(--ms-text-mute);
    font-family: var(--ms-font-mono);
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
}

/* Main content area between TopBar and StatusBar. */
.ms-shell-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
    background: var(--ms-bg);
    color: var(--ms-text);
}

/* Phase-placeholder pages — temporary until each phase ships its real screen. */
.ms-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}
.ms-placeholder-title {
    font-family: var(--ms-font-mono);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 28px;
    color: var(--ms-accent);
    margin: 0 0 12px;
}
.ms-placeholder-body {
    color: var(--ms-text-dim);
    max-width: 540px;
    line-height: 1.55;
    margin: 0;
}

/* ---- Maintenance-mode full-screen lock (non-admins) ---- */
.ms-maint-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 12, 22, 0.94);
    backdrop-filter: blur(4px);
}
.ms-maint-box { text-align: center; max-width: 440px; padding: 32px; }
.ms-maint-spinner {
    width: 48px; height: 48px;
    margin: 0 auto 20px;
    border: 4px solid var(--ms-panel-border);
    border-top-color: var(--ms-accent);
    border-radius: 50%;
    animation: ms-maint-spin 1s linear infinite;
}
@keyframes ms-maint-spin { to { transform: rotate(360deg); } }
.ms-maint-title { font-size: 22px; font-weight: 700; color: var(--ms-text); margin-bottom: 8px; }
.ms-maint-sub { color: var(--ms-text-dim); font-size: 14px; line-height: 1.5; }
.ms-maint-since { margin-top: 14px; font-family: var(--ms-font-mono); font-size: 12px; color: var(--ms-text-mute); }
@media (prefers-reduced-motion: reduce) { .ms-maint-spinner { animation-duration: 2.4s; } }

/* ── Grouped dropdown nav + mobile bottom tab bar (UI-cleanup v2 2026-06-21) ──
   Prominent group tabs (icon + label), a clear hover/active state, and dropdown
   menus that are comfortably padded and legible. Spacing from the --space-* scale. */
.ms-tabs-grouped { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.ms-navgroup { position: relative; }
.ms-navgroup > summary {
    list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md); border-radius: 8px; font-weight: 600; font-size: 0.92rem;
    color: var(--ms-text-dim); border: 1px solid transparent; white-space: nowrap; min-height: 40px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ms-navgroup > summary::-webkit-details-marker { display: none; }
.ms-navgroup > summary::after { content: "▾"; font-size: 0.62em; opacity: 0.6; margin-inline-start: 2px; }
.ms-navgroup > summary .ms-navicon { width: 17px; height: 17px; flex: 0 0 auto; opacity: 0.85; }
.ms-navgroup > summary:hover { background: var(--ms-panel-header); color: var(--ms-text); }
.ms-navgroup[open] > summary {
    background: color-mix(in srgb, var(--ms-accent) 16%, transparent);
    color: var(--ms-text); border-color: color-mix(in srgb, var(--ms-accent) 45%, transparent);
}
.ms-navmenu {
    display: none; position: absolute; inset-block-start: calc(100% + 6px); inset-inline-start: 0;
    min-width: 210px; flex-direction: column; gap: 2px; padding: var(--space-sm);
    background: var(--ms-panel); border: 1px solid var(--ms-panel-border); border-radius: 10px;
    /* Dropdown tier (ms-zindex.css, 2000): must paint over the Lagebild side
       panels (--z-panel), which sit later in the DOM and were covering open
       dropdowns near the panel edge (Tarek 2026-07-18). Modals (3000) paint
       over an open dropdown. */
    box-shadow: 0 12px 32px rgba(0,0,0,0.45); z-index: var(--z-dropdown);
    /* Never run off the bottom of small screens — scroll inside instead. */
    max-height: calc(100vh - 72px); overflow-y: auto;
}
/* js/topnav.js flips a menu to end-alignment when it would leave the viewport
   on the inline axis (screen-bounds check; works in LTR and RTL). */
.ms-navmenu.ms-navmenu-end { inset-inline-start: auto; inset-inline-end: 0; }
.ms-navgroup[open] > .ms-navmenu { display: flex; }
.ms-navitem {
    padding: var(--space-sm) var(--space-md); border-radius: 7px; color: var(--ms-text); text-decoration: none;
    white-space: nowrap; font-size: 0.9rem; min-height: 44px; display: flex; align-items: center; gap: var(--space-sm);
    transition: background 0.1s;
}
.ms-navitem:hover { background: var(--ms-panel-header); }
.ms-navitem.active {
    background: var(--ms-accent); color: #07131d; font-weight: 700;
    box-shadow: inset 3px 0 0 color-mix(in srgb, #07131d 35%, transparent);
}

/* Die zweisprachigen Dual-Labels (Arabisch + Deutsch-Untertitel, 2026-07-17)
   sind entfernt (Tarek 2026-07-18: nur noch die lokalisierte Beschriftung). */

.ms-bottomnav { display: none; }

/* Laptop / small-desktop (#topbar-responsive). The full bar needs ~1500px to
   keep the 4 grouped-nav tabs + the right cluster on one line. Below that,
   progressively free space so the nav fits (or wraps to at most one extra row
   via the topbar's min-height): first drop the redundant LIVE pill (the status
   bar already shows SignalR state) and compact the nav groups, then the clock. */
@media (max-width: 1400px) {
    .ms-topbar .ms-live { display: none; }
    .ms-tabs-grouped { gap: 2px; }
    .ms-navgroup > summary { padding: var(--space-sm) var(--space-sm); font-size: 0.86rem; }
    .ms-navgroup > summary::after { display: none; } /* drop the ▾ caret to save width */
    .ms-navgroup > summary .ms-navicon { width: 15px; height: 15px; }
}
@media (max-width: 1100px) {
    .ms-topbar .ms-clock { display: none; }
}

/* Phones + small tablets: the grouped top nav can't fit, so hand navigation to
   the fixed bottom bar (#topbar-responsive). 860px keeps 768px tablet-portrait
   on the clean bottom-nav layout instead of a 3-row-tall wrapped top bar. */
@media (max-width: 860px) {
    .ms-tabs-grouped { display: none; }
    .ms-bottomnav {
        display: flex; position: fixed; inset-inline: 0; inset-block-end: 0;
        background: var(--ms-panel); border-block-start: 1px solid var(--ms-panel-border);
        z-index: var(--z-controls); justify-content: space-around; align-items: stretch;
        padding-block-end: env(safe-area-inset-bottom, 0);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    }
    .ms-bottomtab {
        flex: 1; text-align: center; padding: var(--space-sm) var(--space-xs); font-size: 0.66rem;
        min-height: 56px; gap: 3px; color: var(--ms-text-dim); text-decoration: none; list-style: none;
        cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
    }
    .ms-bottomtab .ms-navicon { width: 22px; height: 22px; }
    .ms-bottomtab::-webkit-details-marker { display: none; }
    .ms-bottomtab.active { color: var(--ms-accent); font-weight: 700; }
    .ms-bottomtab.active .ms-navicon { opacity: 1; }
    .ms-morenav { flex: 1; position: relative; }
    .ms-morenav[open] > .ms-navmenu.up {
        display: flex; position: fixed; inset-block-end: 60px; inset-inline: var(--space-sm); z-index: var(--z-dropdown);
        max-height: 60vh; overflow-y: auto;
    }
    /* free up the dense top bar on phones — the bottom bar carries navigation */
    .ms-topbar .ms-clock, .ms-topbar .ms-live { display: none; }
    /* Keep the bar a single compact row (#topbar-responsive): the grouped nav is
       hidden here (bottom bar carries it), so show the brand MARK only (drop the
       long name + subtitle) and the user's avatar only (drop name/role), leaving
       room for the theme/language selects + logout. overflow-x:hidden is a final
       backstop so nothing pushes the page sideways. */
    .ms-topbar { overflow-x: hidden; }
    .ms-brand { min-width: 0; flex: 0 0 auto; }
    /* !important to beat Bootstrap's .d-block (display:block !important) on these
       brand/user spans. */
    .ms-topbar .ms-brand-name, .ms-topbar .ms-brand-sub { display: none !important; }
    .ms-topbar .ms-user-name, .ms-topbar .ms-user-role { display: none !important; }
    .ms-topbar-right { gap: 8px; }
}

/* ── Connection banner ────────────────────────────────────────────────────
   "The picture you are looking at is not live." Full width, pinned to the
   top of the viewport, above everything (--z-banner) and non-dismissable —
   an operator must never be able to mistake a dead feed for an empty sea.
   Layout is logical (flex row + inline gaps) so RTL needs no overrides. */
.ms-conn-banner {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: var(--z-banner);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    font-size: 0.86rem;
    line-height: 1.25;
    color: var(--ms-bg, #0b1220);
    background: var(--ms-warn, #fbbf24);
    border-block-end: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.ms-conn-banner.alert {
    background: var(--ms-alert, #ef4444);
    color: #fff;
}

.ms-conn-banner-icon { font-size: 1.05rem; }

.ms-conn-banner-text {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.ms-conn-banner-age {
    margin-inline-start: auto;
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
    opacity: 0.9;
}

.ms-conn-banner-stale { font-variant-numeric: tabular-nums; font-weight: 600; }
