/* ═══════════════════════════════════════════════════════════════════════
   DroneAI — Crowd Analytics Stylesheet
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --bg-dark: #0a0e17;
    --bg-panel: #111827;
    --bg-card: #1e2740;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border: #1e293b;
    --radius: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ── Mode Toggle ──────────────────────────────────────────────────────── */

.mode-toggle {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: rgba(17, 24, 39, 0.9);
    padding: 4px;
    border-radius: 10px;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
}

.mode-btn.active {
    background: var(--accent-blue);
    color: white;
}

.mode-btn .icon {
    margin-right: 4px;
}

.map-btn-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: var(--accent-red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    animation: pulseBadge 1.5s infinite;
}
.map-btn-badge.hidden {
    display: none;
}
@keyframes pulseBadge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ── App Container ────────────────────────────────────────────────────── */

.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    transition: all 0.3s ease;
}

/* Dashboard mode: video fills everything */
.app.dashboard-mode .video-container {
    width: 100%;
}

.app.dashboard-mode .analysis-panel {
    display: none;
}

.app.dashboard-mode .dashboard-overlay {
    display: flex;
}

/* Analysis mode: video + side panel */
.app.analysis-mode .video-container {
    width: calc(100% - 420px);
}

.app.analysis-mode .analysis-panel {
    display: flex;
}

.app.analysis-mode .dashboard-overlay {
    display: none;
}

.app.analysis-mode .pip-map-container {
    display: none;
}

/* Map mode: hide video, show map fullscreen */
.app.map-mode .video-container,
.app.map-mode .analysis-panel {
    display: none;
}

.app.map-mode .map-view {
    display: flex;
}

.map-view {
    display: none;
    width: 100vw;
    height: 100vh;
}

/* ── Video Container ──────────────────────────────────────────────────── */

.video-container {
    position: relative;
    height: 100vh;
    background: #000;
    overflow: hidden;
}

#video-feed {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ── Dashboard Overlay Stats ──────────────────────────────────────────── */

.dashboard-overlay {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: none; /* shown in dashboard mode */
    gap: 16px;
    z-index: 10;
}

.stat-card {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    min-width: 120px;
    transition: all 0.3s;
}

.stat-card.primary {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.stat-card.alert {
    border-color: var(--accent-red);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    animation: pulse-alert 1s ease-in-out infinite;
}

@keyframes pulse-alert {
    0%, 100% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 35px rgba(239, 68, 68, 0.6); }
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-card.primary .stat-value {
    color: var(--accent-cyan);
}

/* ── Alert Banner ─────────────────────────────────────────────────────── */

.alert-banner {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slide-down 0.3s ease-out;
    max-width: 80%;
}

.alert-banner.hidden {
    display: none;
}

@keyframes slide-down {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.alert-icon {
    font-size: 18px;
}

/* ── Connection Status ────────────────────────────────────────────────── */

.connection-status {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(17, 24, 39, 0.8);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.connection-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
}

.connection-status.connected .dot {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

/* ── Analysis Panel ───────────────────────────────────────────────────── */

.analysis-panel {
    width: 420px;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: none; /* shown in analysis mode */
    flex-direction: column;
    padding: 20px;
    gap: 4px;
}

.analysis-panel h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent-cyan);
}

.panel-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.panel-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── Source & Playback Controls ───────────────────────────────────────── */

.source-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.source-status {
    width: 100%;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.playback-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ── RTSP Dialog ────────────────────────────────────────────────────────── */

.btn-rtsp {
    background: rgba(168, 85, 247, 0.15) !important;
    border-color: rgba(168, 85, 247, 0.4) !important;
    color: #c084fc !important;
}
.btn-rtsp:hover {
    background: rgba(168, 85, 247, 0.3) !important;
}

.rtsp-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-top: 10px;
}
.rtsp-dialog.hidden {
    display: none;
}
.rtsp-dialog h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--text-primary);
}
.rtsp-field {
    margin-bottom: 8px;
}
.rtsp-field label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}
.rtsp-field input {
    width: 100%;
    padding: 7px 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    box-sizing: border-box;
}
.rtsp-field input:focus {
    border-color: var(--accent-blue);
    outline: none;
}
.rtsp-field input::placeholder {
    color: var(--text-muted);
}
.rtsp-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.btn-primary {
    background: rgba(59, 130, 246, 0.3) !important;
    border-color: rgba(59, 130, 246, 0.5) !important;
    color: #93c5fd !important;
}
.btn-primary:hover {
    background: rgba(59, 130, 246, 0.45) !important;
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: wait;
}
.rtsp-status {
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}
.rtsp-status.connecting {
    color: var(--accent-yellow);
}
.rtsp-status.error {
    color: var(--accent-red);
}

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-blue);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Settings ─────────────────────────────────────────────────────────── */

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.setting-row label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 110px;
}

.setting-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent-blue);
    height: 4px;
}

.setting-row span {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--accent-cyan);
    min-width: 32px;
    text-align: right;
}

/* ── Stats Grid ───────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mini-stat {
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    padding: 10px 12px;
}

.mini-stat .label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.mini-stat .value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* ── Timeline Chart ───────────────────────────────────────────────────── */

#timeline-chart {
    width: 100%;
    height: 120px;
    border-radius: 6px;
    background: rgba(0,0,0,0.2);
}

/* ── Anomaly Log ──────────────────────────────────────────────────────── */

.anomaly-log {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.log-empty {
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.log-entry .severity {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.log-entry .severity.high { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.log-entry .severity.medium { background: var(--accent-yellow); }
.log-entry .severity.low { background: var(--accent-blue); }

.log-entry .message {
    color: var(--text-secondary);
    line-height: 1.4;
}

.log-entry .time {
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 2px;
}

/* ── Toggle Rows ──────────────────────────────────────────────────────── */

.toggle-row {
    margin-bottom: 6px;
}

.toggle-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-row input[type="checkbox"] {
    accent-color: var(--accent-blue);
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ── Model Selector ───────────────────────────────────────────────────── */

.model-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.model-option:hover {
    background: rgba(59,130,246,0.1);
    border-color: rgba(59,130,246,0.3);
}

.model-option.active {
    background: rgba(59,130,246,0.15);
    border-color: var(--accent-blue);
}

.model-option.loading {
    opacity: 0.5;
    pointer-events: none;
}

.model-option .model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-option .model-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.model-option .model-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.model-option .model-size {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.model-status {
    font-size: 11px;
    color: var(--accent-cyan);
    margin-top: 8px;
    min-height: 16px;
}

.model-loading {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    padding: 8px;
}

/* ── Mini stat highlight ──────────────────────────────────────────────── */

.mini-stat.highlight {
    border: 1px solid rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.08);
}

.mini-stat.highlight .value {
    color: var(--accent-cyan);
}

/* ── Legend ────────────────────────────────────────────────────────────── */

.legend {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    background: rgba(10, 14, 23, 0.75);
    backdrop-filter: blur(8px);
    padding: 6px 16px;
    border-radius: 20px;
    z-index: 10;
    font-size: 11px;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.detected {
    background: #00ff66;
    box-shadow: 0 0 6px #ff00ff;
}

.legend-dot.estimated {
    background: rgba(255, 170, 0, 0.9);
}

/* ── Brand Badge (TV-station style, top-right) ────────────────────────── */

.brand-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(10, 14, 23, 0.75);
    backdrop-filter: blur(12px);
    padding: 8px 16px 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    z-index: 15;
    user-select: none;
}

.brand-logo {
    height: 22px;
    opacity: 0.9;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.brand-live {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-red);
    animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Dashboard settings gear ──────────────────────────────────────────── */

.dashboard-gear {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(8px);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.2s;
}

.dashboard-gear:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.15);
}

.dashboard-gear.active {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* ── Dashboard settings panel ─────────────────────────────────────────── */

.dashboard-settings {
    position: absolute;
    bottom: 150px;
    right: 20px;
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 16px 18px;
    z-index: 15;
    min-width: 200px;
    animation: fade-in 0.2s ease;
}

.dashboard-settings.hidden {
    display: none;
}

.dashboard-settings h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.dashboard-settings label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px 0;
}

.dashboard-settings label:hover {
    color: var(--text-primary);
}

.dashboard-settings input[type="checkbox"] {
    accent-color: var(--accent-blue);
}

/* ── Analysis panel brand ─────────────────────────────────────────────── */

.panel-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.panel-brand h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 0;
}

/* Hide brand badge and gear in analysis mode (panel has its own branding) */
.app.analysis-mode .brand-badge {
    display: none;
}

.app.analysis-mode .dashboard-gear,
.app.analysis-mode .dashboard-settings {
    display: none;
}

/* ── Fullscreen adjustments ───────────────────────────────────────────── */

body:-webkit-full-screen .mode-toggle {
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
}

body:-webkit-full-screen .brand-badge {
    top: 24px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Drone Map — Full View
   ═══════════════════════════════════════════════════════════════════════ */

.leaflet-map-full {
    flex: 1;
    height: 100vh;
    background: #1a2230;
}

.map-sidebar {
    width: 380px;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.map-brand-logo {
    height: 28px;
    opacity: 0.9;
}

.map-sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.map-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.map-summary {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.map-stat {
    flex: 1;
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid transparent;
}

.map-stat.known {
    border-color: rgba(16, 185, 129, 0.3);
}

.map-stat.unknown {
    border-color: rgba(239, 68, 68, 0.3);
}

.map-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.map-stat.known .map-stat-value { color: var(--accent-green); }
.map-stat.unknown .map-stat-value { color: var(--accent-red); }

.map-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
}

.map-list-header {
    padding: 16px 20px 8px;
}

.map-list-header h3 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.drone-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}

.drone-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.drone-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-red);
    border-radius: 7px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    transition: all 0.2s;
}

.drone-card.known {
    border-left-color: var(--accent-green);
}

.drone-card.inactive {
    opacity: 0.5;
}

.drone-card.selected {
    outline: 2px solid var(--accent-blue);
}

.drone-card.focused {
    outline: 2px solid #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35),
                0 0 14px rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.08);
}

.drone-card {
    cursor: pointer;
}

.focus-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.5);
    border-radius: 6px;
    color: #e0f2fe;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.focus-banner:hover {
    background: rgba(56, 189, 248, 0.22);
}

.focus-banner-btn {
    background: #0284c7;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.focus-banner-btn:hover {
    background: #0369a1;
}

.drone-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.drone-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
    flex-shrink: 0;
}
.drone-card.known .drone-status-dot {
    background: var(--accent-green);
}
.drone-card.inactive .drone-status-dot {
    background: var(--text-muted);
}

.drone-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
    min-width: 0;
    outline: none;
}
.drone-name:hover, .drone-name:focus {
    background: rgba(255,255,255,0.05);
}

.drone-id {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
}

.drone-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.drone-card-body .label {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.5px;
}

.drone-card-body .value {
    color: var(--text-primary);
    font-weight: 500;
}

.drone-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.drone-btn {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 5px;
    cursor: pointer;
}
.drone-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}
.drone-btn.known-btn.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--accent-green);
}
.drone-btn.danger {
    color: var(--accent-red);
}

.map-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-muted);
}
.map-footer-label {
    margin-bottom: 3px;
}
.map-footer-code {
    color: var(--accent-cyan);
    font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Tile mode toggle (map / satellite)
   ═══════════════════════════════════════════════════════════════════════ */

.tile-mode-toggle {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}

.btn-tile-mode {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-tile-mode:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
.btn-tile-mode.active {
    background: var(--accent-cyan);
    color: #062733;
    border-color: var(--accent-cyan);
}
.btn-tile-mode .tile-icon {
    font-size: 14px;
}

/* Satellite mode: darker loading background for a cleaner look */
.leaflet-map-full.satellite-mode {
    background: #0b1320;
}

/* ═══════════════════════════════════════════════════════════════════════
   History / Replay panel
   ═══════════════════════════════════════════════════════════════════════ */

.history-panel {
    padding: 14px 20px 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.6);
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.history-mode-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--accent-green);
    color: #052e1b;
    letter-spacing: 0.5px;
}
.history-mode-badge.history {
    background: #f59e0b;
    color: #3d2600;
}

.history-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}
.history-field label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.history-field select,
.history-field input {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
}
.history-field select:focus,
.history-field input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.history-field-row {
    display: flex;
    gap: 8px;
}

.history-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.btn-history-load {
    flex: 1;
    background: var(--accent-cyan);
    color: #062733;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-history-load:hover {
    background: #22d3ee;
}

.history-status {
    font-size: 11px;
    color: var(--text-muted);
    min-height: 14px;
    padding-top: 2px;
}
.history-status.error {
    color: var(--accent-red);
}

/* Playback controls */
.history-playback {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.history-playback-time {
    text-align: center;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 20px;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 8px;
}

.history-scrubber {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    outline: none;
    margin: 4px 0;
}
.history-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
    border: 2px solid #0f172a;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}
.history-scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
    border: 2px solid #0f172a;
}

.history-playback-range {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Menlo', monospace;
    margin-bottom: 10px;
}

.history-playback-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-playback {
    background: var(--accent-cyan);
    color: #062733;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}
.btn-playback:hover {
    background: #22d3ee;
    transform: scale(1.02);
}

.history-speed-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
}
.history-speed-group label {
    margin-right: 4px;
}
.btn-speed {
    flex: 1;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-speed:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}
.btn-speed.active {
    background: var(--accent-cyan);
    color: #062733;
    border-color: var(--accent-cyan);
}

.btn-live {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-live:hover {
    color: var(--accent-green);
    border-color: var(--accent-green);
}

/* ═══════════════════════════════════════════════════════════════════════
   Dashboard PIP Map (drone radar)
   ═══════════════════════════════════════════════════════════════════════ */

.pip-map-container {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 240px;
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    overflow: hidden;
    z-index: 20;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: all 0.3s;
}

.pip-map-container.alert {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5),
                0 0 30px rgba(239, 68, 68, 0.4),
                0 8px 32px rgba(0,0,0,0.4);
    animation: pipPulse 2s infinite;
}

@keyframes pipPulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5),
                    0 0 20px rgba(239, 68, 68, 0.3),
                    0 8px 32px rgba(0,0,0,0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.7),
                    0 0 40px rgba(239, 68, 68, 0.6),
                    0 8px 32px rgba(0,0,0,0.4);
    }
}

.pip-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.pip-map-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.pip-map-icon {
    font-size: 14px;
}

.pip-map-status {
    font-size: 10px;
    color: var(--text-secondary);
}

.pip-map-container.alert .pip-map-status {
    color: var(--accent-red);
    font-weight: 700;
}

.pip-map {
    height: 160px;
    background: #1a2230;
}

.pip-map-alert {
    padding: 6px 12px;
    background: var(--accent-red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    animation: alertBlink 1s infinite;
}
.pip-map-alert.hidden {
    display: none;
}
@keyframes alertBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Hide PIP when no drones at all, keep hidden in non-dashboard modes */
.app:not(.dashboard-mode) .pip-map-container {
    display: none;
}

/* Leaflet dark theme tweaks */
.leaflet-container {
    background: #1a2230 !important;
    font-family: inherit !important;
}
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4) !important;
}
.leaflet-popup-tip {
    background: var(--bg-card) !important;
}
.leaflet-popup-content {
    font-size: 12px !important;
    margin: 10px 14px !important;
}
.leaflet-control-zoom a {
    background: rgba(17, 24, 39, 0.9) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
}

/* Custom drone marker styles */
.drone-marker {
    background: transparent;
    border: none;
}

.drone-icon-known {
    color: var(--accent-green);
}
.drone-icon-unknown {
    color: var(--accent-red);
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.7));
}

.home-icon {
    color: var(--accent-yellow);
}

/* ── Public mode (TELEMETRY_ONLY backend) ───────────────────────── */
/* When serving the drone-only public dashboard, hide everything
   related to the local video / analyse pipeline. The map view + drone
   sidebar (history, list, summary) stay visible; that IS the public UI. */

body.public-mode #mode-toggle #btn-dashboard,
body.public-mode #mode-toggle #btn-analysis {
    display: none !important;
}

/* Only the map button remains — center it, make it obvious. */
body.public-mode #mode-toggle {
    /* With only one button, compress the toggle so it looks intentional
       rather than a lonely orphan button. */
    padding: 2px;
}

/* The dashboard's video container (MJPEG feed + overlay canvas + stats
   cards + brand badge + gear + dashboard PIP) is all video-dependent.
   Force the app into map-mode visuals regardless of which class the JS
   last set. */
body.public-mode .video-container,
body.public-mode #analysis-panel {
    display: none !important;
}

/* Force #app into map-mode layout: map is the default view. The JS
   boot sequence also calls setMode('map'), but this is belt-and-braces
   so the UI renders correctly even if JS races. */
body.public-mode #app {
    display: block;
}
body.public-mode #map-view {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* Hide the footer hint about the telemetry POST endpoint — not useful
   to end users on the public dashboard. */
body.public-mode .map-footer {
    display: none;
}
