/* Skipper — mobile-first chart plotter UI */

:root {
    --navy: #0d2137;
    --navy-2: #14304d;
    --accent: #29b6f6;
    --accent-dim: #1a7bb0;
    --text: #eaf2f8;
    --text-dim: #9fb3c4;
    --danger: #e53935;
    --ok: #43a047;
    --hud-bg: rgba(13, 33, 55, 0.88);
    --sheet-bg: #10283f;
    --bottom-nav-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--navy);
    color: var(--text);
    overscroll-behavior: none;
    touch-action: manipulation;
}

#app { height: 100dvh; }

/* ---------- boot screen ---------- */
.boot-screen {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--navy);
}
.boot-logo { font-size: 64px; }
.boot-title { font-size: 28px; font-weight: 700; letter-spacing: 2px; }
.loading-progress-text { color: var(--text-dim); font-size: 14px; }
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading…"); }
.boot-error {
    color: #ff8a80;
    font-size: 13px;
    max-width: 340px;
    text-align: center;
    line-height: 1.5;
    padding: 0 16px;
}

/* ---------- app shell ---------- */
.app-shell {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.page-scroll {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
}

/* ---------- bottom navigation ---------- */
.bottom-nav {
    display: flex;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--navy-2);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    z-index: 30;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 10px;
}
.bottom-nav a .nav-ico { font-size: 20px; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }

/* ---------- chart page ---------- */
.map-wrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

.night-canvas canvas {
    filter: invert(0.92) hue-rotate(180deg) sepia(0.35) saturate(0.65) brightness(0.75);
}

/* HUD readout strip */
.hud {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 10;
    pointer-events: none;
}
.hud-cell {
    flex: 1;
    background: var(--hud-bg);
    border-radius: 10px;
    padding: 6px 8px;
    text-align: center;
    backdrop-filter: blur(4px);
    min-width: 0;
}
.hud-label { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }
.hud-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-unit { font-size: 11px; color: var(--text-dim); margin-left: 2px; }
.hud-pos { font-size: 12px; font-weight: 600; line-height: 1.35; font-variant-numeric: tabular-nums; }

/* floating round buttons on the chart */
.map-fabs {
    position: absolute;
    right: 10px;
    bottom: calc(18px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
}
.fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--hud-bg);
    color: var(--text);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}
.fab.active { background: var(--accent-dim); color: #fff; }
.fab.danger { background: var(--danger); color: #fff; }

.gps-banner {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(18px + var(--safe-bottom));
    background: var(--hud-bg);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    z-index: 10;
    max-width: 80%;
    text-align: center;
}
.gps-banner.error { background: rgba(183, 28, 28, 0.92); }

/* ---------- generic UI bits ---------- */
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }

.card {
    background: var(--sheet-bg);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-dim);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn.secondary { background: var(--navy-2); color: var(--text); border: 1px solid rgba(255,255,255,0.15); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--text-dim); font-size: 13px; }

input[type="text"], input[type="number"], select {
    background: var(--navy);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 15px;
    width: 100%;
}
label { font-size: 13px; color: var(--text-dim); display: block; margin: 10px 0 4px; }

.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0;
    background: var(--navy);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 13px;
    transition: 0.15s;
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    width: 20px; height: 20px;
    left: 2px; top: 2px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: 0.15s;
}
.switch input:checked + .slider { background: var(--accent-dim); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* ---------- chart sheets / panels ---------- */
.backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 18;
}

.sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--sheet-bg);
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + var(--safe-bottom));
    z-index: 20;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
    max-height: 70%;
    overflow-y: auto;
}

.ctx-menu {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    background: var(--sheet-bg);
    border-radius: 14px;
    padding: 14px;
    z-index: 20;
    min-width: 260px;
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.5);
}
.ctx-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    padding: 12px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
}
.ctx-item:last-child { border-bottom: none; }
.ctx-item:active { background: rgba(255, 255, 255, 0.06); }

.tool-panel {
    position: absolute;
    left: 8px; right: 8px;
    bottom: calc(12px + var(--safe-bottom));
    background: var(--hud-bg);
    border-radius: 12px;
    padding: 12px;
    z-index: 12;
    backdrop-filter: blur(4px);
}

.nav-panel {
    position: absolute;
    top: 66px;
    left: 8px; right: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(20, 60, 30, 0.9);
    border-radius: 12px;
    padding: 8px 12px;
    z-index: 11;
    font-size: 14px;
}
.nav-panel.alarm { background: rgba(160, 30, 30, 0.92); animation: pulse-bg 1s infinite alternate; }
.nav-panel .nav-cells { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.nav-panel .nav-target { font-weight: 700; white-space: nowrap; }
@keyframes pulse-bg { from { filter: brightness(1); } to { filter: brightness(1.35); } }

.fab.recording {
    background: var(--danger);
    color: #fff;
    animation: pulse-bg 0.9s infinite alternate;
}

.progress-outer {
    height: 8px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}
.progress-inner {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

.color-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
}
.color-dot.selected { border-color: #fff; }

/* ---------- alarm banner ---------- */
.alarm-banner {
    position: absolute;
    top: 66px;
    left: 8px; right: 8px;
    background: rgba(183, 28, 28, 0.95);
    color: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    z-index: 25;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    animation: pulse-bg 0.8s infinite alternate;
    cursor: pointer;
}

.fab.danger { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }

/* ---------- weather table ---------- */
.wx-table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.wx-table th, .wx-table td { padding: 4px 7px; text-align: center; }
.wx-table td:first-child { text-align: left; white-space: nowrap; }
.wx-table .wx-warn { color: #ffb300; font-weight: 700; }
.wx-table .wx-danger { color: #ff5252; font-weight: 700; }

/* ---------- night mode (whole UI) ---------- */
.night .bottom-nav, .night .hud-cell, .night .fab, .night .card, .night .gps-banner {
    background: #1a0000;
    color: #ff5252;
}
.night { --text: #ff8a80; --text-dim: #b71c1c; --accent: #ff5252; }

/* ---------- blazor error bar ---------- */
#blazor-error-ui {
    background: #b71c1c;
    color: #fff;
    bottom: 0; left: 0;
    display: none;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
#blazor-error-ui .reload { color: #fff; }
