@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMu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) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* ===================== fp-core-command UI ===================== */
.muted { color: #6b7280; font-size: 0.85rem; }

.page-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head-actions { display: flex; align-items: center; gap: 0.75rem; }

/* Top row status + logout */
.broker-status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.broker-status .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.broker-status.ok { color: #1a7f37; } .broker-status.ok .dot { background: #1a7f37; }
.broker-status.down { color: #b32121; } .broker-status.down .dot { background: #b32121; }
.logout-form { margin: 0 0 0 auto; }
.logout-btn { background: none; border: none; color: #0071c1; cursor: pointer; font-size: 0.85rem; }
.logout-btn:hover { text-decoration: underline; }

/* Buttons */
.btn { cursor: pointer; border-radius: 6px; padding: 0.35rem 0.8rem; border: 1px solid transparent; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #eef1f5; border-color: #d0d7de; color: #24292f; }
.btn-link { background: none; border: none; color: #0071c1; padding: 0.2rem 0.4rem; }
.btn-link:hover { text-decoration: underline; }

/* Empty state */
.empty { padding: 2rem; background: #f6f8fa; border: 1px dashed #d0d7de; border-radius: 8px; text-align: center; }
.empty p { margin: 0.3rem 0; }

/* Device grid (Overview) */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.device-card { border: 1px solid #d0d7de; border-radius: 10px; padding: 1rem; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04); border-left: 4px solid #d0d7de; }
.device-card.online { border-left-color: #1a7f37; }
.device-card.offline { border-left-color: #b32121; opacity: 0.85; }
.device-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.device-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; font-weight: 600; }
.device-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 0.6rem; }
.in-view { color: #1a7f37; font-size: 0.75rem; }

.badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 600; text-transform: uppercase; }
.badge-online { background: #dafbe1; color: #1a7f37; }
.badge-offline { background: #ffebe9; color: #b32121; }

.telemetry { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0; }
.telemetry dt { color: #6b7280; font-size: 0.8rem; }
.telemetry dd { margin: 0; font-size: 0.85rem; text-align: right; font-variant-numeric: tabular-nums; }

/* Panels (OTA) */
.panel { border: 1px solid #d0d7de; border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; background: #fff; }
.panel h2 { font-size: 1.05rem; margin-top: 0; }
.fw-upload { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.fw-select-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.fw-select-row select { padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid #d0d7de; min-width: 240px; }

.ota-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.ota-toolbar h2 { margin: 0; }
.ota-toolbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.device-table { width: 100%; border-collapse: collapse; }
.device-table th, .device-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #eaeef2; font-size: 0.88rem; }
.device-table th { color: #6b7280; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.ota-status { font-size: 0.82rem; font-weight: 500; }
.ota-pending { color: #6b7280; }
.ota-sending, .ota-installing { color: #9a6700; }
.ota-success { color: #1a7f37; }
.ota-failed, .ota-timedout { color: #b32121; }
.ota-skipped { color: #6b7280; }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #0d1117; padding: 1rem; position: relative; overflow: hidden; }
.plane-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.login-card { position: relative; z-index: 1; background: #fff; border-radius: 12px;
    padding: 2.25rem 2rem; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.45); }
.login-title { font-size: 1.4rem; margin: 0 0 0.2rem; text-align: center; }
.login-sub { color: #6b7280; font-size: 0.85rem; text-align: center; margin: 0 0 1.5rem; }
.login-label { display: block; font-size: 0.8rem; color: #374151; margin-bottom: 0.3rem; }
.login-input { width: 100%; padding: 0.55rem 0.7rem; border: 1px solid #d0d7de; border-radius: 7px;
    margin-bottom: 1rem; font-size: 0.95rem; box-sizing: border-box; }
.login-button { width: 100%; padding: 0.6rem; background: #1b6ec2; color: #fff; border: none;
    border-radius: 7px; font-size: 0.95rem; cursor: pointer; }
.login-button:hover { background: #155a9c; }
.login-error { background: #ffebe9; color: #b32121; padding: 0.5rem 0.75rem; border-radius: 6px;
    font-size: 0.85rem; margin-bottom: 1rem; }

/* Overview overflow table */
.overflow-head { display: flex; align-items: baseline; gap: 0.6rem; margin: 1.5rem 0 0.5rem; }
.overflow-head h2 { font-size: 1rem; margin: 0; }

/* Overview msg-rate sparkline (replaces uptime/last-state in the tile) */
.sparkline { margin-top: 0.6rem; min-height: 46px; display: flex; flex-direction: column; justify-content: flex-end; }
.spark-svg { width: 100%; height: 32px; display: block; }
.spark-svg polyline { fill: none; stroke: #1b6ec2; stroke-width: 1.5; vector-effect: non-scaling-stroke;
    stroke-linejoin: round; stroke-linecap: round; }
.spark-cap { display: flex; justify-content: space-between; font-size: 0.7rem; color: #6b7280; margin-top: 3px; }
.spark-empty { font-size: 0.75rem; height: 32px; display: flex; align-items: center; }

/* Search box */
.search-input { padding: 0.35rem 0.6rem; border: 1px solid #d0d7de; border-radius: 6px; font-size: 0.9rem; min-width: 220px; }

/* Device name / id in tile + table */
.device-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.device-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-id-sub { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; color: #6b7280; }

/* Settings modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; }
.modal-card { position: fixed; z-index: 1001; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: #fff; border-radius: 12px; padding: 1.5rem; width: min(420px, calc(100vw - 1.5rem));
    box-shadow: 0 12px 48px rgba(0,0,0,0.3); max-height: 90vh; overflow: auto; }
.modal-card h2 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.9rem; font-size: 0.85rem; }
.field span { color: #374151; }
.field input { padding: 0.45rem 0.6rem; border: 1px solid #d0d7de; border-radius: 7px; font-size: 0.92rem; }
.field-check { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem; font-size: 0.9rem; }
.gain-fields { border: 1px solid #e5e7eb; border-radius: 9px; padding: 0.4rem 0.9rem 1rem; margin-top: 1.1rem; }
.gain-fields legend { font-size: 0.8rem; color: #6b7280; padding: 0 0.4rem; }
.gain-field { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; font-size: 0.85rem; }
.gain-field label { flex: 0 0 88px; color: #374151; }
.gain-field input { width: 5rem; padding: 0.4rem 0.5rem; border: 1px solid #d0d7de; border-radius: 7px;
    font-size: 0.92rem; }
.range-hint { color: #9ca3af; font-size: 0.75rem; }

/* Horizontal-scroll wrapper for wide tables (keeps them from blowing out the page) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===================== Mobile (phones / narrow) ===================== */
@media (max-width: 640.98px) {
    /* roomier tap targets, less wasted side padding */
    article.content { padding-left: 1rem !important; padding-right: 1rem !important; }

    /* page header stacks; search + actions go full width */
    .page-head { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .page-head-actions { width: 100%; flex-wrap: wrap; gap: 0.6rem; }
    .search-input { flex: 1 1 100%; min-width: 0; }
    .page-head-actions .btn { flex: 0 0 auto; }

    /* one card per row */
    .device-grid { grid-template-columns: 1fr; }

    /* tables scroll sideways instead of squishing; cells don't wrap */
    .device-table { white-space: nowrap; }

    /* OTA: firmware picker + toolbar stack full width */
    .fw-upload { gap: 0.5rem; }
    .fw-select-row { flex-direction: column; align-items: stretch; }
    .fw-select-row select { width: 100%; min-width: 0; }
    .ota-toolbar { flex-direction: column; align-items: stretch; }
    .ota-toolbar-actions { flex-wrap: wrap; }
    .ota-toolbar-actions .btn-primary { flex: 1 1 100%; }

    /* tighten panels a touch */
    .panel { padding: 1rem; }

    /* top bar: keep status + sign-out on one line, comfortably */
    .broker-status { font-size: 0.8rem; }
}

/* Live Map page — flex column fills the area below the chrome exactly (no magic-number overflow).
   Subtracts only the fixed chrome: mobile = sidebar brand bar (3.5) + top bar (3.5) + content pad (1.1);
   desktop (sidebar is to the side) = top bar (3.5) + content pad (1.1). The map-wrap flexes to fill. */
.map-page { display: flex; flex-direction: column; height: calc(100vh - 8.1rem); min-height: 320px; }
@media (min-width: 641px) { .map-page { height: calc(100vh - 4.6rem); } }
.map-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; flex-wrap: wrap; flex: 0 0 auto; }
.map-head h1 { margin: 0; }
.map-wrap { flex: 1 1 auto; min-height: 0; border: 1px solid #d0d7de; border-radius: 10px; overflow: hidden; }
#adsb-map { width: 100%; height: 100%; background: #0d1117; }
.ac-divicon { background: none; border: none; }
.ac-marker { width: 96px; text-align: center; }
.ac-icon { width: 28px; height: 28px; margin: 0 auto; transition: transform 0.4s linear; }
.ac-label { line-height: 1.05; margin-top: 1px; pointer-events: none; white-space: nowrap; }
.ac-cs { font-size: 10px; font-weight: 600; color: #eef2f7; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.ac-ty { font-size: 9px; color: #aeb7c2; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
