/* App shell modelled on the Meshtastic Android app: top app bar, one content view, bottom tab bar. */
/* Dark theme with a green accent (Windows 11 settings look). */
:root {
    --accent: #4be04b;
    --accent-dim: #2fa32f;
    --mesh-green: #4be04b;
    --mesh-green-dark: #4be04b;
    --app-bar-bg: #0b5a1a;
    --app-bar-fg: #ffffff;
    --app-bg: #202020;
    --surface: #2b2b2b;
    --surface-2: #262626;
    --hover: #343434;
    --line: #3a3a3a;
    --text: #ffffff;
    --text-2: #a8a8a8;
    --on-accent: #000000;
    --app-bottom-nav-height: 72px;
    --app-bar-height: 56px;
    color-scheme: dark;
}

/* No pull-to-refresh (and no overscroll bounce chaining to the page): scrolling up a list too far must never reload
   the app, which would drop queued sends and redo the catch-up. Lists still scroll normally. */
html, body { height: 100%; margin: 0; overscroll-behavior-y: none; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--app-bg); color: var(--text); }
#app { height: 100%; }

.app-shell { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; background: var(--app-bg); box-shadow: 0 0 12px rgba(0,0,0,.5); }

.app-bar { flex: 0 0 var(--app-bar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--app-bar-bg); color: var(--app-bar-fg); }
.app-bar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-bar-logo { flex: 0 0 36px; width: 36px; height: 36px; padding: 4px; border-radius: 10px; background: var(--surface); } /* same tile as the sidebar logo */
.app-bar-title { font-size: 1.25rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-status { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.app-bar-btn { border: 0; background: none; color: inherit; padding: 0; line-height: 1; cursor: pointer; }
.app-bar-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.app-bar-node { font-size: .8rem; font-weight: 700; background: var(--mesh-green); color: #000; border-radius: 12px; padding: 4px 10px; }
.app-bar-node:hover { filter: brightness(1.1); }
.app-loc { position: relative; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.app-loc:hover { background: rgba(255,255,255,.12); }
.app-loc.ok { color: var(--accent); }
.app-loc.wait { color: #ffc107; }
.app-loc.off { color: #ff6b6b; }
.app-loc.idle { color: rgba(255,255,255,.6); }
.app-loc.blocked::after { content: ""; position: absolute; width: 2px; height: 24px; background: currentColor; transform: rotate(45deg); box-shadow: 0 0 0 1px var(--app-bar-bg); }

.app-content { flex: 1 1 auto; position: relative; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; }
.app-map-host { position: absolute; inset: 0; }
.app-hidden { display: none !important; }

.app-bottom-nav { flex: 0 0 calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom)); box-sizing: border-box; display: flex; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
.app-tab { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 0 8px; border: 0; background: none; color: var(--text-2); font-size: .72rem; line-height: 1.2; }
.app-tab i { font-size: 1.3rem; line-height: 1; padding: 6px 20px; border-radius: 16px; transition: background-color .15s; }
.app-tab.active { color: var(--text); font-weight: 600; }
.app-tab.active i { background: var(--accent); color: var(--on-accent); }
/* Connection tab: colour follows the MQTT state (on the active pill the colours are darker so they stay readable). */
.app-tab i.app-tab-ok { color: var(--accent); }
.app-tab i.app-tab-wait { color: #ffc107; }
.app-tab i.app-tab-off { color: #ff6b6b; }
.app-tab.active i.app-tab-ok { color: var(--on-accent); }
.app-tab.active i.app-tab-wait { color: #6b4a00; }
.app-tab.active i.app-tab-off { color: #7a0e0e; }
.app-tab:focus-visible { outline: 2px solid var(--mesh-green-dark); outline-offset: -2px; }

/* Shared list styles for views. */
.app-list { list-style: none; margin: 0; padding: 0; }
.app-list-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; }
.app-list-item:hover { background: var(--hover); }
.app-list-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Avatars: muted (dark green, green text) by default, like the Settings channel list; .solid for "needs attention" (unread). */
.app-avatar { flex: 0 0 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; background: #1f3d24; color: var(--accent); }
.app-avatar.solid { background: var(--mesh-green); color: #000; }
.app-avatar i { font-size: 1.15rem; }
/* A node's avatar in its map colour (NodeColors.Style sets --node-bg/--node-fg). Muted is a ring in that colour,
   because some node colours are too dark to read as text on the dark theme. */
.app-avatar-node { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--node-bg); }
.app-avatar-node.solid { background: var(--node-bg); color: var(--node-fg); box-shadow: none; }
.app-avatar-anon { --node-bg: #6c757d; --node-fg: #fff; }
/* A row action (gear, expand) that stays quiet until its row is hovered or focused. */
/* Shared confirm dialog. */
.app-modal-backdrop { position: fixed; inset: 0; z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.6); }
.app-modal { width: 100%; max-width: 360px; padding: 18px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.app-modal h3 { margin: 0 0 8px; font-size: 1.05rem; }
.app-modal p, .app-modal ul { margin: 0 0 14px; color: var(--text-2); font-size: .9rem; }
.app-modal ul { padding-left: 18px; }
.app-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.app-section-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--mesh-green-dark); padding: 16px 16px 4px; }
.app-fab { position: absolute; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--mesh-green); color: #000; font-size: 1.5rem; box-shadow: 0 2px 6px rgba(0,0,0,.25); }

/* Map markers: node chips (Advanced Markers), coloured per node in googleMaps.js like the Meshtastic Android app. */
.map-node-chip { min-width: 34px; padding: 3px 7px; border-radius: 14px; border: 2px solid #fff; font: 700 12px/1.2 system-ui, sans-serif; text-align: center; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.45); cursor: pointer; transform: translateY(50%); }
.map-node-chip-me { border-color: var(--mesh-green); box-shadow: 0 0 0 3px rgba(103,234,148,.55), 0 1px 4px rgba(0,0,0,.45); }
.map-node-chip-stale { opacity: .55; }
.map-info { font-size: .85rem; line-height: 1.4; color: #202124; }
@media (prefers-color-scheme: dark) { .map-info { color: #e8eaed; } }

/* Conversations view */

/* Nodes + Map views */

/* Settings + Connection views */

/* Map: Street View + 3D */
.map-3d-host .map-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-info-actions { display: flex; gap: 6px; margin-top: 6px; }
.map-3d-card { position: absolute; left: 12px; right: 12px; bottom: 24px; max-width: 360px; background: var(--surface); border-radius: 12px; padding: 12px 36px 12px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.35); z-index: 2; }
.map-3d-card .map-3d-card-close { position: absolute; top: 6px; right: 6px; border: 0; padding: 2px 6px; }
.map-3d-host { z-index: 0; } /* contain the 3D element's internal stacking below our overlays */

/* Map layers panel (KMZ/KML) */
.map-ground-overlay { position: absolute; transform-origin: 50% 50%; pointer-events: none; }
.map-ground-overlay img { width: 100%; height: 100%; display: block; }

/* Node-data overlays */
.map-heat-canvas { position: absolute; pointer-events: none; }
.map-waypoint { font-size: 22px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); cursor: pointer; transform: translateY(50%); }

.app-update-banner { flex: 0 0 auto; border: 0; width: 100%; padding: 8px 16px; background: var(--mesh-green); color: #000; font-size: .9rem; font-weight: 600; text-align: center; }

/* Splash in index.html while the app downloads. Blazor sets --blazor-load-percentage on <html> as files arrive. */
.app-splash { height: 100%; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--app-bg); color: var(--text); }
.app-splash-icon { width: 96px; height: 96px; }
.app-splash-name { font-size: 1.15rem; font-weight: 600; letter-spacing: .02em; }
.app-splash-bar { position: relative; width: 140px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); }
/* A soft light sweeping across the whole bar, over the fill and the empty track alike. */
.app-splash-bar::after { content: ""; position: absolute; inset: 0; border-radius: 2px; pointer-events: none;
    background: linear-gradient(90deg, transparent 0%, rgba(180,255,180,.55) 50%, transparent 100%) no-repeat;
    background-size: 40% 100%; animation: app-splash-sweep 1.6s ease-in-out infinite; }
@keyframes app-splash-sweep { from { background-position: -70% 0; } to { background-position: 170% 0; } }
/* The fill keeps pulsing (with a soft glow) so a slow download never looks frozen; at least a sliver shows from the start. */
.app-splash-bar span { display: block; height: 100%; min-width: 6px; border-radius: 2px; width: var(--blazor-load-percentage, 0%); background: var(--mesh-green); transition: width .2s; animation: app-splash-pulse 1.2s ease-in-out infinite; }
@keyframes app-splash-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 6px 1px rgba(75,224,75,.55); } 50% { opacity: .45; box-shadow: 0 0 0 0 rgba(75,224,75,0); } }
/* Banners above the page (update available, catch-up progress). */
.app-banners { flex: 0 0 auto; display: flex; flex-direction: column; min-width: 0; }
.app-sync { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--text-2); font-size: .82rem; }
.app-sync > i { color: var(--accent); }
.app-sync-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sync-count { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.app-sync-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; overflow: hidden; background: rgba(255,255,255,.08); }
.app-sync-bar > span { display: block; height: 100%; background: var(--mesh-green); transition: width .25s; }
.app-sync-bar.indeterminate > span { width: 30% !important; animation: app-sync-slide 1.4s ease-in-out infinite; }
@keyframes app-sync-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.app-spin { display: inline-block; animation: app-spin 1.1s linear infinite; }
/* Connection icon with a sync progress ring around it (Index.razor ConnGlyph). */
.conn-glyph { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.conn-ring { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; overflow: visible; pointer-events: none; transform: rotate(-90deg); }
.conn-ring circle { fill: none; stroke-width: 3; }
.conn-ring-track { stroke: rgba(75, 224, 75, .22); }
.conn-ring-bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .25s ease; }
.conn-ring.indeterminate { animation: conn-ring-spin 1s linear infinite; }
@keyframes conn-ring-spin { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
/* On the active tab the icon sits on a green pill: draw the ring dark so it still shows. */
.app-tab.active .conn-ring-track { stroke: rgba(0, 0, 0, .2); }
.app-tab.active .conn-ring-bar { stroke: var(--on-accent); }
.app-side .conn-ring { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
@keyframes app-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .app-spin, .app-sync-bar.indeterminate > span, .conn-ring.indeterminate { animation: none; } .conn-ring-bar { transition: none; } }
@media (prefers-reduced-motion: reduce) { .app-splash-bar span, .app-splash-bar::after { animation: none; } .app-splash-bar::after { display: none; } }

/* ---- Sidebar (tablet and desktop, 768 px and up) ----
   Replaces the top bar and bottom tabs. Full width from 1200 px, an icon rail (with tooltips) from 768 to 1199 px;
   .side-collapsed / .side-expanded on .app-shell (the chevron, saved in localStorage nav_sidebar) override the width rule. */
.app-side { display: none; flex-direction: column; width: 264px; height: 100dvh; padding: 12px 0; background: #181818; border-right: 1px solid var(--line); position: relative; z-index: 5; }
.app-side-head { display: flex; align-items: center; gap: 10px; padding: 4px 16px 14px; border-bottom: 1px solid var(--line); }
.app-side-logo { flex: 0 0 36px; width: 36px; height: 36px; padding: 4px; border-radius: 10px; background: var(--surface); }
.app-side-brand { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.app-side-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-side-sub { font-size: .75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Collapse/expand: a round button on the sidebar's right edge, level with the logo. */
.app-side-toggle { position: absolute; top: 22px; right: -14px; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text-2); display: flex; align-items: center; justify-content: center; font-size: .8rem; z-index: 6; }
.app-side-toggle:hover { background: var(--hover); color: var(--text); }
.app-side-toggle i { transition: transform .15s; }
.app-side-section { padding: 16px 24px 6px; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.app-side-item { position: relative; display: flex; align-items: center; gap: 12px; width: calc(100% - 24px); min-height: 44px; margin: 2px 12px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: .92rem; text-align: left; }
.app-side-item:hover { background: var(--hover); }
.app-side-item.active { background: #1f3d24; color: var(--accent); font-weight: 600; }
.app-side-item:focus-visible, .app-side-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-side-icon { position: relative; flex: 0 0 24px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.app-side-label { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-side-meta { font-size: .72rem; font-weight: 400; }
.app-side-badge { flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.app-side-dot { display: none; position: absolute; top: -3px; right: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #181818; }
.app-side .app-tab-ok { color: var(--accent); }
.app-side .app-tab-wait { color: #ffc107; }
.app-side .app-tab-off { color: #ff6b6b; }
.app-side-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.app-side-loc { color: var(--text-2); }
.app-side-loc.ok .app-side-icon { color: var(--accent); }
.app-side-loc.wait .app-side-icon { color: #ffc107; }
.app-side-loc.off .app-side-icon { color: #ff6b6b; }
.app-side-loc.blocked .app-side-icon::after { content: ""; position: absolute; width: 2px; height: 22px; background: currentColor; transform: rotate(45deg); box-shadow: 0 0 0 1px #181818; }
.app-side-me { min-height: 52px; }
.app-side-avatar { flex: 0 0 32px; width: 32px; height: 32px; font-size: .62rem; margin-left: -4px; }
.app-side-me-text { display: flex; flex-direction: column; line-height: 1.25; }
.app-side-me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-page { height: 100%; }

/* Unread badge on the phone's Conversations tab. */
.app-tab { position: relative; }
.app-tab-badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ff6b6b; color: #000; font-size: .66rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

@media (min-width: 768px) {
    .app-shell { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "side banner" "side main"; max-width: none; box-shadow: none; }
    .app-bar, .app-bottom-nav { display: none; }
    .app-side { grid-area: side; display: flex; }
    .app-banners { grid-area: banner; }
    .app-content { grid-area: main; }
    .app-page { max-width: 860px; margin: 0 auto; }
    .app-page.app-page-wide { max-width: 1280px; }
}
/* Icon rail: chosen with the chevron, or by default on tablets. */
.app-shell.side-collapsed .app-side { width: 72px; }
.app-shell.side-collapsed .app-side-head { justify-content: center; padding: 4px 0 14px; }
.app-shell.side-collapsed .app-side-brand { display: none; }
.app-shell.side-collapsed .app-side-toggle i { transform: rotate(180deg); }
.app-shell.side-collapsed .app-side-section { height: 1px; margin: 10px 16px; padding: 0; font-size: 0; background: var(--line); }
.app-shell.side-collapsed .app-side-item { width: 48px; margin: 4px auto; padding: 0; justify-content: center; }
.app-shell.side-collapsed .app-side-label, .app-shell.side-collapsed .app-side-meta, .app-shell.side-collapsed .app-side-badge { display: none; }
.app-shell.side-collapsed .app-side-dot { display: block; }
.app-shell.side-collapsed [data-tip]:hover::after, .app-shell.side-collapsed [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); padding: 4px 8px; border-radius: 4px; background: #000; color: #fff; font-size: .78rem; font-weight: 400; white-space: nowrap; pointer-events: none; z-index: 20; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
@media (min-width: 768px) and (max-width: 1199.98px) {
    .app-shell:not(.side-expanded) .app-side { width: 72px; }
    .app-shell:not(.side-expanded) .app-side-head { justify-content: center; padding: 4px 0 14px; }
    .app-shell:not(.side-expanded) .app-side-brand { display: none; }
    .app-shell:not(.side-expanded) .app-side-toggle i { transform: rotate(180deg); }
    .app-shell:not(.side-expanded) .app-side-section { height: 1px; margin: 10px 16px; padding: 0; font-size: 0; background: var(--line); }
    .app-shell:not(.side-expanded) .app-side-item { width: 48px; margin: 4px auto; padding: 0; justify-content: center; }
    .app-shell:not(.side-expanded) .app-side-label, .app-shell:not(.side-expanded) .app-side-meta, .app-shell:not(.side-expanded) .app-side-badge { display: none; }
    .app-shell:not(.side-expanded) .app-side-dot { display: block; }
    .app-shell:not(.side-expanded) [data-tip]:hover::after, .app-shell:not(.side-expanded) [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); padding: 4px 8px; border-radius: 4px; background: #000; color: #fff; font-size: .78rem; font-weight: 400; white-space: nowrap; pointer-events: none; z-index: 20; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
}
