
/* ========================================
   SKYPANEL RADAR LAB
   Main Stylesheet
======================================== */

:root {
    --background: #0b1120;
    --panel: #141e30;
    --panel-light: #1b2940;
    --border: #263750;
    --text: #e8eef7;
    --muted: #8798ad;
    --accent: #36a8f5;
    --success: #35d49a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* TOP HEADER */

.topbar {
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background: #101a2b;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #153b5c;
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 27px;
}

.brand h1 {
    font-size: 18px;
    letter-spacing: 2px;
}

.brand span {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 1.5px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--success);
}

/* STATUS LIGHT */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    box-shadow: 0 0 10px var(--success);
}

/* MAIN DASHBOARD */

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
    padding: 25px;
    max-width: 1800px;
    margin: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.section-header h2 {
    font-size: 22px;
}

.section-header p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 5px;
}

.radar-provider label {
    display: block;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1px;
    margin-bottom: 7px;
}

/* FORM CONTROLS */

select,
button {
    background: var(--panel-light);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 7px;
    font-size: 12px;
}

button {
    cursor: pointer;
    font-weight: 600;
    letter-spacing: .5px;
}

button:hover {
    border-color: var(--accent);
    background: #203651;
}

/* RADAR DISPLAY */

.radar-display {
    position: relative;
    width: 100%;
    height: min(68vh, 680px);
    min-height: 400px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background:
        radial-gradient(circle at center, #162e42 0%, #0b1728 65%, #080e19 100%);
}

.radar-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    position: relative;
}

.radar-rings {
    position: absolute;
    width: min(55%, 500px);
    aspect-ratio: 1;
    border: 1px solid #28506b;
    border-radius: 50%;
    opacity: .6;
    background:
        radial-gradient(circle, transparent 19%, #28506b 19.2%, transparent 19.6%),
        radial-gradient(circle, transparent 39%, #28506b 39.2%, transparent 39.6%),
        radial-gradient(circle, transparent 59%, #28506b 59.2%, transparent 59.6%),
        radial-gradient(circle, transparent 79%, #28506b 79.2%, transparent 79.6%);
}

.radar-rings::before,
.radar-rings::after {
    content: "";
    position: absolute;
    background: #28506b;
    opacity: .7;
}

.radar-rings::before {
    width: 1px;
    height: 100%;
    left: 50%;
}

.radar-rings::after {
    height: 1px;
    width: 100%;
    top: 50%;
}

.radar-crosshair {
    position: absolute;
    inset: 0;
    border: 1px dashed #28506b;
    border-radius: 50%;
}

.radar-center {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px var(--accent);
}

.radar-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        transparent 300deg,
        rgba(54, 168, 245, .02) 320deg,
        rgba(54, 168, 245, .3) 360deg
    );
    animation: radarSweep 5s linear infinite;
}

@keyframes radarSweep {
    to {
        transform: rotate(360deg);
    }
}

.radar-message {
    position: absolute;
    text-align: center;
    margin-top: 180px;
}

.radar-message h3 {
    font-size: 13px;
    letter-spacing: 2px;
    color: var(--muted);
}

.radar-message p {
    font-size: 11px;
    color: #647a91;
    margin-top: 8px;
}

.map-label {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--muted);
}

/* PLAYBACK CONTROLS */

.radar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    margin-top: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.timeline {
    flex: 1;
    display: flex;
    align-items: center;
}

.timeline input {
    width: 100%;
    accent-color: var(--accent);
}

.frame-count {
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}

/* SIDEBAR PANELS */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 58px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
}

.panel h3 {
    font-size: 11px;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 17px;
}

.status-row,
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 12px;
}

.status-row span,
.setting-row label {
    color: var(--muted);
}

.status-row strong {
    font-size: 11px;
}

.status-row .muted {
    color: #d49a52;
}

.setting-row select {
    max-width: 115px;
}

.diagnostic-message {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 11px;
    margin-bottom: 14px;
}

.diagnostic-message .status-dot {
    background: #d49a52;
    box-shadow: 0 0 8px #d49a52;
}

.diagnostic-log {
    background: #0b1422;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    color: #8da2b9;
    font-family: monospace;
    font-size: 10px;
    line-height: 1.8;
}

/* FOOTER */

footer {
    text-align: center;
    padding: 20px;
    color: #64758a;
    font-size: 10px;
    letter-spacing: 1.5px;
}

footer span {
    color: var(--accent);
    margin: 0 6px;
}

/* SMALLER SCREENS */

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-top: 0;
    }

    .radar-display {
        height: 55vh;
    }
}

@media (max-width: 550px) {
    .topbar {
        padding: 0 15px;
    }

    .brand span {
        font-size: 8px;
    }

    .system-status {
        font-size: 9px;
    }

    .dashboard {
        padding: 15px;
    }

    .radar-controls {
        flex-wrap: wrap;
    }

    .timeline {
        flex-basis: 100%;
        order: 3;
    }
}

/* LOCATION SEARCH BAR */

.location-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 15px;
    margin-bottom: 15px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.location-input {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 260px;
}

.location-input label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 1px;
}

.location-input input {
    width: 100%;
    padding: 11px 13px;
    background: #0b1422;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 12px;
    outline: none;
}

.location-input input:focus {
    border-color: var(--accent);
}

.location-input input::placeholder {
    color: #64758a;
}

#searchLocation {
    background: #153b5c;
    border-color: #24577e;
    color: #65bdff;
    padding: 12px 18px;
}

.current-location {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    padding: 11px 5px;
    color: var(--muted);
    font-size: 11px;
}

/* LOCATION BAR - SMALL SCREENS */

@media (max-width: 700px) {
    .location-bar {
        flex-wrap: wrap;
    }

    .location-input {
        width: 100%;
    }

    .current-location {
        margin-left: 0;
    }
}

/* LOCATION SEARCH RESULTS */

.location-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    background: #17263a;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    z-index: 100;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}

.location-input {
    position: relative;
}

.location-result {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.location-result:last-child {
    border-bottom: none;
}

.location-result:hover {
    background: #203b59;
}

.location-result strong {
    display: block;
    font-size: 12px;
}

.location-result span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.location-results[hidden] {
    display: none;
}

/* MAPLIBRE RADAR MAP */

#radarMap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

/* ========================================
   RADAR LOOP OVERLAYS (both modes)
======================================== */

.radar-time {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 3;
    padding: 6px 12px;
    border-radius: 9px;
    background: rgba(11, 17, 32, .82);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .3px;
    pointer-events: none;
}

.radar-time.is-latest {
    border-color: rgba(53, 212, 154, .55);
}

.radar-time.is-stale {
    border-color: #d49a52;
    color: #f1c48e;
}

.radar-credit {
    position: absolute;
    right: 10px;
    bottom: 32px;
    z-index: 3;
    font-size: 10px;
    color: var(--muted);
    text-shadow: 0 0 4px #000;
    pointer-events: none;
}

.error-box {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 4;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(90, 20, 20, .9);
    color: #ffd0c7;
    font-size: 12px;
}

.error-box[hidden] {
    display: none;
}

/* Status colors: data-state = ok | warn | error */

.system-status[data-state="warn"],
.system-status[data-state="error"] {
    color: #d49a52;
}

.system-status[data-state="warn"] .status-dot,
.system-status[data-state="error"] .status-dot,
.diagnostic-message .status-dot[data-state="warn"],
.diagnostic-message .status-dot[data-state="error"] {
    background: #d49a52;
    box-shadow: 0 0 8px #d49a52;
}

.diagnostic-message .status-dot[data-state="ok"] {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.diagnostic-log {
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* ========================================
   EMBED MODE (?embed=1)
   Just the radar, filling SkyPanel's radar window.
======================================== */

html.embed body {
    min-height: 0;
    height: 100vh;
    overflow: hidden;
    background: transparent;
}

html.embed .lab-only {
    display: none !important;
}

html.embed .dashboard {
    display: block;
    padding: 0;
    max-width: none;
    height: 100%;
}

html.embed .radar-section,
html.embed .radar-display {
    height: 100%;
}

html.embed .radar-display {
    min-height: 0;
    border: 0;
    border-radius: 0;
}

html.embed #radarMap {
    border-radius: 0;
}

html.embed .radar-time {
    font-size: 15px;
}
