/* ===== CSS Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --bg-primary: #0a0e14;
    --bg-secondary: #111820;
    --bg-tertiary: #1a2332;
    --bg-panel: rgba(10, 14, 20, 0.95);
    
    --accent-cyan: #00d4ff;
    --accent-green: #00ff88;
    --accent-orange: #ff9500;
    --accent-red: #ff3355;
    --accent-purple: #9966ff;
    --accent-gold: #ffd700;
    
    --zone-lancaster: #00aaff;
    --zone-barrow: #00ff99;
    --zone-amundsen: #ff6600;
    
    --text-primary: #e8f4f8;
    --text-secondary: #8899aa;
    --text-dim: #556677;
    
    /* Sizing */
    --header-height: 60px;
    --sidebar-width: 280px;
    
    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    cursor: crosshair; /* Laser-like pointer */
}

/* Force crosshair cursor on clickable elements to replace the hand */
a, button, .btn, .clickable, .leaflet-container, .leaflet-interactive {
    cursor: crosshair !important;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ===== Header HUD ===== */
.hud-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(180deg, rgba(10, 14, 20, 0.98) 0%, rgba(10, 14, 20, 0.9) 100%);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 500;
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent-cyan);
    animation: pulse-glow 2s ease-in-out infinite;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    padding-left: 12px;
    border-left: 1px solid var(--text-dim);
}

/* Header Badges */
.header-badges {
    display: flex;
    gap: 16px;
}

.badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.badge-icon {
    font-size: 12px;
}

.badge.stanag .badge-icon { color: var(--accent-gold); }
.badge.datalink .badge-icon { color: var(--accent-cyan); }
.badge.threat .badge-icon { color: var(--accent-orange); }

.badge-label {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.badge-status {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1px;
}

.badge-status.online { color: var(--accent-green); }
.badge-status.warning { color: var(--accent-orange); }
.badge-status.critical { color: var(--accent-red); }

.system-status {
    display: flex;
    gap: 32px;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.status-item .label {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.status-item .value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.status-item .value.online {
    color: var(--accent-green);
}

.status-item.clock .value {
    font-family: var(--font-display);
    letter-spacing: 2px;
}

/* Reset Map Button */
.btn-reset-map {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 212, 255, 0.05));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 4px;
    color: var(--accent-cyan);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-reset-map:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 212, 255, 0.1));
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
    transform: translateY(-1px);
}

.btn-reset-map .reset-icon {
    font-size: 16px;
    animation: rotate-hint 3s ease-in-out infinite;
}

.btn-reset-map:hover .reset-icon {
    animation: rotate-active 0.6s ease-in-out;
}

@keyframes rotate-hint {
    0%, 90%, 100% { transform: rotate(0deg); }
    92%, 96% { transform: rotate(-15deg); }
    94%, 98% { transform: rotate(15deg); }
}

@keyframes rotate-active {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* ===== C4I Sidebar ===== */
.c4i-sidebar {
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100% - var(--header-height));
    background: var(--bg-panel);
    border-right: 1px solid rgba(0, 212, 255, 0.2);
    z-index: 400;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.c4i-sidebar.collapsed {
    transform: translateX(calc(-100% + 40px));
}

.c4i-sidebar.collapsed .sidebar-tabs,
.c4i-sidebar.collapsed .tab-panel {
    opacity: 0;
    pointer-events: none;
}

/* Drag Handle */
.sidebar-drag-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 212, 255, 0.1) 70%, rgba(0, 212, 255, 0.3) 100%);
    border-right: 4px solid rgba(0, 212, 255, 0.6);
    cursor: ew-resize;
    z-index: 401;
    transition: background 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-drag-handle:hover,
.sidebar-drag-handle.dragging {
    background: linear-gradient(90deg, transparent 0%, rgba(0, 212, 255, 0.15) 60%, rgba(0, 212, 255, 0.4) 100%);
    border-right-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.sidebar-drag-handle::before {
    content: '⋮⋮';
    position: absolute;
    font-size: 16px;
    color: rgba(0, 212, 255, 0.6);
    letter-spacing: -2px;
    transition: color 0.2s ease;
}

.sidebar-drag-handle:hover::before,
.sidebar-drag-handle.dragging::before {
    color: var(--accent-cyan);
}

.c4i-sidebar.collapsed .sidebar-drag-handle::after {
    content: '▶';
    position: absolute;
    font-size: 14px;
    color: var(--accent-cyan);
    animation: pulse-arrow 2s ease-in-out infinite;
}

@keyframes pulse-arrow {
    0%, 100% { opacity: 0.6; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(3px); }
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: transparent;
    border: none;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: rgba(0, 212, 255, 0.1);
}

.tab-btn.active {
    background: rgba(0, 212, 255, 0.15);
    border-bottom: 2px solid var(--accent-cyan);
}

.tab-icon {
    font-size: 16px;
    color: var(--text-secondary);
}

.tab-btn.active .tab-icon {
    color: var(--accent-cyan);
}

.tab-label {
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.tab-btn.active .tab-label {
    color: var(--accent-cyan);
}

/* Tab Panels */
.tab-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.tab-panel.active {
    display: block;
}

.panel-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-section:last-child {
    border-bottom: none;
}

.section-title {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-cyan);
    margin-bottom: 12px;
}

/* Toggle Groups */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: crosshair;
}

.toggle-item input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--text-dim);
    border-radius: 2px;
    background: var(--bg-tertiary);
    cursor: crosshair;
    position: relative;
}

.toggle-item input[type="checkbox"]:checked {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.toggle-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 2px;
    font-size: 10px;
    color: var(--bg-primary);
}

.toggle-label {
    font-size: 11px;
    color: var(--text-primary);
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent-cyan), #0088bb);
    border: none;
    border-radius: 4px;
    color: var(--bg-primary);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-dim);
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    color: var(--accent-cyan);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(0, 212, 255, 0.1);
}

/* Telemetry Grid */
.telemetry-grid {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 10px;
}

.telemetry-placeholder {
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    padding: 20px 0;
}

.telemetry-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.telemetry-row:last-child {
    border-bottom: none;
}

.telemetry-label {
    font-size: 9px;
    color: var(--text-secondary);
}

.telemetry-value {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-primary);
}

.telemetry-value.good { color: var(--accent-green); }
.telemetry-value.warning { color: var(--accent-orange); }
.telemetry-value.critical { color: var(--accent-red); }

/* HAUV List */
.hauv-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.hauv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-cyan);
    cursor: crosshair;
    transition: all 0.2s ease;
}

.hauv-item:hover {
    background: rgba(0, 212, 255, 0.1);
}

.hauv-item.selected {
    border-left-color: var(--accent-green);
    background: rgba(0, 255, 136, 0.1);
}

.hauv-id {
    font-size: 10px;
    font-weight: 500;
}

.hauv-phase {
    font-size: 9px;
    color: var(--text-secondary);
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.hauv-phase.patrol { color: var(--accent-cyan); }
.hauv-phase.homing { color: var(--accent-orange); }
.hauv-phase.charging { color: var(--accent-green); }
.hauv-phase.inspection { color: var(--accent-purple); }

/* Energy Budget */
.energy-budget {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.budget-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 10px;
}

.budget-row span:first-child {
    color: var(--text-secondary);
}

.budget-status {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1px;
}

.budget-status.valid {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.budget-status.invalid {
    background: rgba(255, 51, 85, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

/* Teleoperation */
.teleop-status {
    margin-bottom: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 10px;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.status-indicator.online .indicator-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.status-indicator.offline .indicator-dot {
    background: var(--accent-red);
}

/* Joystick */
.joystick-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.joystick-stick {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), #0088bb);
    cursor: grab;
    transition: transform 0.1s ease;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
}

.joystick-stick:active {
    cursor: grabbing;
}

.joystick-labels {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.joystick-labels span {
    position: absolute;
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.label-up { top: 0; left: 50%; transform: translateX(-50%); }
.label-down { bottom: 0; left: 50%; transform: translateX(-50%); }
.label-left { left: 0; top: 50%; transform: translateY(-50%); }
.label-right { right: 0; top: 50%; transform: translateY(-50%); }

/* Depth Control */
.depth-control {
    margin-top: 16px;
}

.depth-control > label {
    display: block;
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

.depth-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-depth {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    color: var(--accent-cyan);
    font-size: 9px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-depth:hover {
    background: rgba(0, 212, 255, 0.1);
}

#current-depth {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-cyan);
    min-width: 60px;
    text-align: center;
}

/* Sensor Feed */
.sensor-feed {
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.feed-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.feed-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 9px;
    letter-spacing: 1px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.feed-tab.active {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-cyan);
}

.feed-display {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.feed-placeholder {
    text-align: center;
    color: var(--text-dim);
}

.feed-placeholder span {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
}

.feed-placeholder p {
    font-size: 9px;
}

.feed-info {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 9px;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Military Panel */
.interop-badges {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.interop-badge {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--text-dim);
    opacity: 0.6;
}

.interop-badge.active {
    border-left-color: var(--accent-green);
    opacity: 1;
}

.badge-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
}

.badge-desc {
    font-size: 9px;
    color: var(--text-secondary);
}

.atr-status {
    margin-bottom: 12px;
}

.atr-indicator, .fusion-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 10px;
}

.atr-indicator .indicator-dot,
.fusion-indicator .fusion-value.online::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

/* Contact List */
.contact-list {
    max-height: 150px;
    overflow-y: auto;
}

.contact-placeholder {
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    padding: 20px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 6px;
    border-left: 3px solid var(--accent-red);
}

.contact-item.biological {
    border-left-color: var(--accent-green);
}

.contact-item.unknown {
    border-left-color: var(--accent-orange);
}

.contact-id {
    font-size: 10px;
    font-weight: 500;
}

.contact-class {
    font-size: 9px;
    color: var(--text-secondary);
}

.contact-confidence {
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

/* Data Fusion */
.fusion-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fusion-source {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.source-icon {
    color: var(--accent-cyan);
}

.source-name {
    flex: 1;
    font-size: 10px;
}

.source-status {
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(0, 255, 136, 0.1);
    border-radius: 2px;
}

.source-status.online {
    color: var(--accent-green);
}

.fusion-indicator {
    margin-top: 8px;
    justify-content: space-between;
}

.fusion-label {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.fusion-value {
    font-size: 10px;
    font-weight: 500;
}

.fusion-value.online {
    color: var(--accent-green);
}

/* Sensor-to-Shooter */
.sts-log {
    margin-top: 12px;
    max-height: 100px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 8px;
}

.log-entry {
    font-size: 9px;
    color: var(--text-secondary);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.alert {
    color: var(--accent-orange);
}

.log-entry.action {
    color: var(--accent-cyan);
}

/* ===== Map Container ===== */
#map {
    position: absolute;
    top: var(--header-height);
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: calc(100% - var(--header-height));
    z-index: 1;
    transition: left 0.3s ease, width 0.3s ease;
}

#map.sidebar-collapsed {
    left: 40px;
    width: calc(100% - 40px);
}

/* ===== Radar Canvas Overlay ===== */
#radar-canvas {
    position: absolute;
    top: var(--header-height);
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: calc(100% - var(--header-height));
    pointer-events: none;
    z-index: 450;
    transition: left 0.3s ease, width 0.3s ease;
}

#radar-canvas.sidebar-collapsed {
    left: 40px;
    width: calc(100% - 40px);
}

/* ===== Tooltip ===== */
.tooltip {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    padding: 12px 16px;
    min-width: 220px;
    z-index: 600;
    pointer-events: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 212, 255, 0.1);
}

.tooltip.hidden {
    display: none;
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-icon {
    font-size: 16px;
}

.tooltip-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-cyan);
    flex: 1;
}

.tooltip-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: crosshair;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
    margin-left: 8px;
}

.tooltip-close-btn:hover {
    background: rgba(255, 51, 85, 0.2);
    color: var(--accent-red);
}

.tooltip-content {
    font-size: 11px;
    line-height: 1.6;
}

.tooltip-content .row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.tooltip-content .row .label {
    color: var(--text-secondary);
}

.tooltip-content .row .value {
    color: var(--text-primary);
    font-weight: 500;
}

.tooltip-content .row .value.good {
    color: var(--accent-green);
}

.tooltip-content .row .value.warning {
    color: var(--accent-orange);
}

.tooltip-content .row .value.critical {
    color: var(--accent-red);
}

/* ===== Zone Legend ===== */
.zone-legend {
    position: absolute;
    bottom: 80px;
    left: calc(var(--sidebar-width) + 24px);
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 16px;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.zone-legend h3 {
    font-family: var(--font-display);
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.legend-item .zone-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-item.lancaster .zone-color {
    background: var(--zone-lancaster);
    box-shadow: 0 0 8px var(--zone-lancaster);
}

.legend-item.barrow .zone-color {
    background: var(--zone-barrow);
    box-shadow: 0 0 8px var(--zone-barrow);
}

.legend-item.amundsen .zone-color {
    background: var(--zone-amundsen);
    box-shadow: 0 0 8px var(--zone-amundsen);
}

.legend-item .zone-name {
    font-size: 11px;
    color: var(--text-primary);
}

/* ===== Selection Panel ===== */
.selection-panel {
    position: absolute;
    bottom: 80px;
    right: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    min-width: 280px;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 212, 255, 0.15);
}

.selection-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 212, 255, 0.1);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.panel-icon {
    color: var(--accent-cyan);
    font-size: 16px;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-cyan);
    flex: 1;
}

.panel-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px; /* Increased from 20px */
    cursor: crosshair;
    padding: 8px; /* Increased hit area */
    width: 40px; /* Increased from 24px */
    height: 40px; /* Increased from 24px */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    z-index: 10; /* Ensure it's on top */
    margin-right: -8px; /* Offset padding */
}

.panel-close-btn:hover {
    color: var(--accent-red);
    transform: scale(1.1);
}

.panel-content {
    padding: 16px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.info-row .info-label {
    width: 60px;
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.info-row .info-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-fill.health {
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
}

.progress-fill.battery {
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-green));
}

.panel-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.panel-footer .instruction {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-secondary);
    animation: blink 1.5s ease-in-out infinite;
}

/* ===== Alert Overlay ===== */
.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.alert-content {
    background: var(--bg-panel);
    border: 2px solid var(--accent-orange);
    border-radius: 8px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 149, 0, 0.3);
    animation: alert-pulse 0.5s ease-in-out infinite alternate;
}

.alert-icon {
    font-size: 48px;
    color: var(--accent-orange);
    display: block;
    margin-bottom: 16px;
}

.alert-message {
    font-size: 14px;
    color: var(--text-primary);
    display: block;
    margin-bottom: 20px;
}

.btn-alert-dismiss {
    padding: 10px 24px;
    background: var(--accent-orange);
    border: none;
    border-radius: 4px;
    color: var(--bg-primary);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-alert-dismiss:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.3);
}

.alert-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-proceed-anyway {
    padding: 10px 24px;
    background: transparent;
    border: 2px solid var(--accent-red);
    border-radius: 4px;
    color: var(--accent-red);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: crosshair;
    transition: all 0.2s ease;
}

.btn-proceed-anyway:hover {
    background: rgba(255, 51, 85, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 51, 85, 0.3);
}

.btn-proceed-anyway.hidden {
    display: none;
}

/* ===== Instructions ===== */
.instructions {
    position: absolute;
    bottom: 24px;
    left: calc(var(--sidebar-width) + 50%);
    transform: translateX(-50%);
    display: flex;
    gap: 32px;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 10px 24px;
    z-index: 100;
}

.instructions span {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* ===== Animations ===== */
@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px var(--accent-cyan);
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 20px var(--accent-cyan), 0 0 40px var(--accent-cyan);
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes alert-pulse {
    from {
        box-shadow: 0 0 30px rgba(255, 149, 0, 0.3);
    }
    to {
        box-shadow: 0 0 60px rgba(255, 149, 0, 0.5);
    }
}

@keyframes threat-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

/* Environmental overlays (applied to map) */
.env-layer-ice {
    background: repeating-linear-gradient(
        45deg,
        rgba(200, 230, 255, 0.1),
        rgba(200, 230, 255, 0.1) 10px,
        rgba(180, 220, 255, 0.15) 10px,
        rgba(180, 220, 255, 0.15) 20px
    );
}

/* Leaflet map adjustments */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--accent-cyan) !important;
    border: 1px solid rgba(0, 212, 255, 0.3) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(0, 212, 255, 0.1) !important;
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: rgba(10, 14, 20, 0.98);
    border: 1px solid var(--accent-cyan);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 212, 255, 0.2);
    z-index: 10000;
    min-width: 200px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: crosshair;
    font-size: 12px;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.context-menu-item:hover {
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-cyan);
}

.context-menu-icon {
    font-size: 14px;
}

.context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Patrol item with radius field */
.context-menu-item.patrol-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.context-menu-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-menu-field {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 24px;
    font-size: 11px;
}

.context-menu-field label {
    color: var(--text-secondary);
}

.context-menu-field input {
    width: 50px;
    padding: 4px 6px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: center;
}

.context-menu-field input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.context-menu-field span {
    color: var(--text-secondary);
}

/* ===== Drone Selection Modal ===== */
.drone-select-modal {
    position: fixed;
    background: rgba(10, 14, 20, 0.98);
    border: 1px solid var(--accent-cyan);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 212, 255, 0.15);
    z-index: 10001;
    min-width: 280px;
    max-height: 400px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.drone-select-modal.hidden {
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 212, 255, 0.1);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-cyan);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: crosshair;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--accent-red);
}

.modal-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.drone-select-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-cyan);
    cursor: crosshair;
    transition: all 0.15s ease;
}

.drone-select-item:hover {
    background: rgba(0, 212, 255, 0.15);
    border-left-color: var(--accent-green);
}

.drone-select-item:last-child {
    margin-bottom: 0;
}

.drone-select-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.drone-select-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.drone-select-phase {
    font-size: 9px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.drone-select-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.drone-select-battery {
    font-size: 11px;
    font-weight: 500;
}

.drone-select-battery.good { color: var(--accent-green); }
.drone-select-battery.warning { color: var(--accent-orange); }
.drone-select-battery.critical { color: var(--accent-red); }

.drone-select-distance {
    font-size: 10px;
    color: var(--accent-cyan);
    font-weight: 500;
}

/* ===== Power Station Marker ===== */
.power-station-marker {
    pointer-events: auto;
}

/* ===== Hamburger Menu Button ===== */
.hamburger-menu {
    display: none;
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    cursor: crosshair;
    z-index: 501;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    transition: all 0.2s ease;
}

.hamburger-menu:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent-green);
}

.hamburger-menu span {
    width: 18px;
    height: 2px;
    background: var(--accent-cyan);
    border-radius: 1px;
    transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ===== Mobile Overlay ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 399;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    display: block;
}

/* ===== RESPONSIVE DESIGN ===== */
@media screen and (max-width: 768px) {
    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
    }


    /* Adjust header for mobile */
    .hud-header {
        padding: 0 12px 0 52px;
        height: 50px;
    }

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

    .logo .subtitle {
        display: none;
    }

    /* Hide or simplify header badges on small screens */
    .header-badges {
        display: none;
    }

    .system-status {
        gap: 12px;
    }

    .status-item .label {
        font-size: 8px;
    }

    .status-item .value {
        font-size: 11px;
    }

    /* Sidebar becomes overlay on mobile */
    .c4i-sidebar {
        position: fixed;
        top: 50px;
        left: -280px;
        width: 280px;
        height: calc(100% - 50px);
        z-index: 400;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .c4i-sidebar.active {
        left: 0;
    }
    
    /* Make drag handle more touch-friendly on mobile */
    .sidebar-drag-handle {
        width: 12px;
        right: -12px;
    }
    
    .sidebar-drag-handle:hover,
    .sidebar-drag-handle.dragging {
        width: 16px;
    }

    /* Map takes full width on mobile */
    #map {
        left: 0;
        width: 100%;
        top: 50px;
        height: calc(100% - 50px);
    }

    #radar-canvas {
        left: 0;
        width: 100%;
        top: 50px;
        height: calc(100% - 50px);
    }

    /* Adjust zone legend position */
    .zone-legend {
        left: 12px;
        bottom: 60px;
        padding: 10px 12px;
    }

    .zone-legend h3 {
        font-size: 9px;
        margin-bottom: 8px;
    }

    .legend-item {
        margin: 4px 0;
    }

    .legend-item .zone-name {
        font-size: 10px;
    }

    /* Adjust selection panel */
    .selection-panel {
        right: 12px;
        bottom: 60px;
        min-width: auto;
        max-width: calc(100% - 24px);
    }

    .panel-content {
        padding: 12px;
    }

    /* Hide instructions on mobile - not relevant for touch */
    .instructions {
        display: none;
    }
    
    /* Adjust Reset Map button for mobile - icon only */
    .btn-reset-map .reset-label {
        display: none;
    }

    /* Tooltip sizing */
    .tooltip {
        min-width: 180px;
        padding: 10px 12px;
    }

    .tooltip-title {
        font-size: 11px;
    }

    .tooltip-content {
        font-size: 10px;
    }

    /* Sidebar tabs - make more compact */
    .tab-btn {
        padding: 10px 6px;
    }

    .tab-icon {
        font-size: 14px;
    }

    .tab-label {
        font-size: 7px;
    }

    /* Panel sections - reduce spacing */
    .panel-section {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .section-title {
        font-size: 9px;
        margin-bottom: 10px;
    }

    /* Form elements - touch friendly */
    .form-group select,
    .form-group input {
        padding: 10px 12px;
        font-size: 12px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 16px;
        font-size: 11px;
    }

    /* Alert overlay */
    .alert-content {
        padding: 20px 24px;
        margin: 0 16px;
    }

    .alert-message {
        font-size: 13px;
    }
}

/* Extra small devices (phones in portrait mode) */
@media screen and (max-width: 480px) {
    .logo h1 {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .system-status {
        gap: 8px;
    }

    .status-item {
        gap: 1px;
    }

    .status-item .label {
        font-size: 7px;
    }

    .status-item .value {
        font-size: 10px;
    }

    /* Further reduce sidebar width for very small screens */
    .c4i-sidebar {
        width: 260px;
        left: -260px;
    }

    /* Hide some less critical instructions */
    .instructions span:nth-child(n+3) {
        display: none;
    }

    .zone-legend {
        font-size: 9px;
    }

    .legend-item .zone-color {
        width: 10px;
        height: 10px;
    }

    .legend-item .zone-name {
        font-size: 9px;
    }
}

/* Tablet landscape - intermediate sizing */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .header-badges .badge {
        padding: 4px 10px;
    }

    .badge-label {
        font-size: 8px;
    }

    .badge-status {
        font-size: 9px;
    }
}
/* Slider Toggle Styles */
.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-cyan);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-cyan);
}

input:checked + .slider:before {
    transform: translateX(14px);
}

/* Drone Marker Hitbox Improvement */
.drone-marker {
    pointer-events: auto !important;
    cursor: pointer;
    z-index: 1000;
}

/* Increase hit area without changing visual size */
.drone-marker::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: transparent;
    border-radius: 50%;
}
