/* ═══════════════════════════════════════════════════════════════════════════
   SKYWATCH 3D AIRSPACE VIEW — Styles v3.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tab Panel ─────────────────────────────────────────────────────────── */

#tab-3d {
    display: none;
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: #06091a;
}

#tab-3d.active {
    display: flex;
    flex-direction: column;
}

/* 3D mode grid: match LIVE layout — [canvas flex] [stats 340px] */
#main.mode-3d {
    grid-template-columns: 1fr 340px;
}

#main.mode-3d #tab-3d {
    grid-column: 1;
    grid-row: 1;
}

#main.mode-3d #stats-panel {
    grid-column: 2;
    grid-row: 1;
}

#sw3d-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#sw3d-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── HUD Overlay ───────────────────────────────────────────────────────── */

#sw3d-hud {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.sw3d-hud-tl {
    position: absolute;
    top: 12px;
    left: 14px;
}

.sw3d-hud-title {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 3px;
    color: #ff9900;
    text-transform: uppercase;
}

.sw3d-hud-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #3a6a8a;
    margin-top: 2px;
}

.sw3d-hud-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-family: 'Courier New', monospace;
    font-size: 9px;
}

.sw3d-live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 4px #00ff88;
    animation: sw3d-pulse-dot 1.5s ease-in-out infinite;
}

.sw3d-live-dot.stale { background: #ff4444; box-shadow: 0 0 4px #ff4444; animation: none; }

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

.sw3d-live-text { color: #00ff88; }
.sw3d-live-text.stale { color: #ff4444; }

/* ── HUD Top Right ────────────────────────────────────────────────────── */

.sw3d-hud-tr {
    position: absolute;
    top: 12px; right: 14px;
    text-align: right;
}

.sw3d-ac-count {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #ff9900;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.sw3d-legend { display: flex; flex-direction: column; gap: 2px; }

.sw3d-legend-item {
    display: flex; align-items: center; justify-content: flex-end; gap: 5px;
    font-family: 'Courier New', monospace; font-size: 8px; color: #5a7a9a;
}

.sw3d-legend-swatch { width: 10px; height: 3px; border-radius: 1px; }

/* ── HUD Bottom Left ──────────────────────────────────────────────────── */

.sw3d-hud-bl {
    position: absolute;
    bottom: 8px; left: 14px;
    display: none;
}

.sw3d-hud-bl.visible { display: block; }

.sw3d-sel-callsign {
    font-family: 'Courier New', monospace;
    font-size: 13px; color: #ff9900; letter-spacing: 1px;
}

.sw3d-sel-info {
    font-family: 'Courier New', monospace;
    font-size: 10px; color: #a0c8f0; margin-top: 2px;
}

.sw3d-sel-info .sw3d-watching { color: #00e5ff; }

/* ── HUD Bottom Center ────────────────────────────────────────────────── */

.sw3d-hud-bc {
    position: absolute;
    bottom: 8px; left: 50%; transform: translateX(-50%);
    font-family: 'Courier New', monospace;
    font-size: 9px; color: #1a3040;
    letter-spacing: 1px; transition: opacity 1s; white-space: nowrap;
}

.sw3d-hud-bc.hidden { opacity: 0; }

/* ── CSS Labels ────────────────────────────────────────────────────────── */

#sw3d-labels {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 5; overflow: hidden;
}

.sw3d-label {
    position: absolute;
    font-family: 'Courier New', monospace;
    font-size: 9px;
    background: rgba(6, 9, 26, 0.85);
    border-left: 2px solid #888;
    padding: 2px 5px;
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.3;
    display: none;
    transform: translate(8px, -50%);
}

.sw3d-label.visible { display: block; }
.sw3d-label.selected { font-size: 11px; border-left-color: #ff9900; }

.sw3d-label-cs { display: block; }

.sw3d-label-alt {
    display: block;
    color: #5a7a9a;
    font-size: 8px;
}

.sw3d-label.selected .sw3d-label-alt { font-size: 9px; }

/* ── Selected Aircraft Bubble ──────────────────────────────────────────── */

.sw3d-sel-bubble {
    position: absolute;
    z-index: 15;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -24px;
    background: rgba(6, 9, 26, 0.95);
    border-left: 2px solid #ff9900;
    border-radius: 3px;
    padding: 6px 10px;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #a0c8f0;
    white-space: nowrap;
    line-height: 1.5;
}

/* Leader line from bubble to aircraft */
.sw3d-sel-bubble::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -24px;
    width: 1px;
    height: 24px;
    background: rgba(255, 153, 0, 0.4);
}

.sb-line { display: block; }

.sb-line:first-child {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.sb-cs {
    color: #ff9900;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 1px;
}

.sb-cat {
    font-size: 8px;
    letter-spacing: 1px;
    color: #3a6a8a;
    text-transform: uppercase;
    padding: 1px 5px;
    border: 1px solid #1a3050;
    border-radius: 2px;
}

/* ── Compass Rose ──────────────────────────────────────────────────────── */

#sw3d-compass {
    position: absolute;
    bottom: 12px; right: 12px;
    width: 64px; height: 64px;
    z-index: 12;
    pointer-events: none;
}

/* ── World Cardinal Labels ─────────────────────────────────────────────── */

.sw3d-cardinal {
    position: absolute;
    display: none;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #1a3050;
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 6;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 4px rgba(6, 9, 26, 0.9);
}

/* ── Control Bar ───────────────────────────────────────────────────────── */

#sw3d-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 12px;
    background: #0d1117;
    border-top: 1px solid #1a3050;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #5a7a9a;
    overflow-x: auto;
    flex-shrink: 0;
}

.sw3d-ctrl-group { display: flex; align-items: center; gap: 4px; }

.sw3d-ctrl-sep { width: 1px; height: 22px; background: #1a3050; margin: 0 4px; }

.sw3d-ctrl-label {
    font-size: 8px; letter-spacing: 1px; text-transform: uppercase;
    color: #3a5a7a; margin-right: 4px; white-space: nowrap;
}

.sw3d-cat-btn {
    font-family: 'Courier New', monospace;
    font-size: 9px; letter-spacing: 0.5px;
    padding: 3px 8px;
    border: 1px solid #1a3050; border-radius: 10px;
    background: transparent; color: #3a5a7a;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}

.sw3d-cat-btn.active {
    border-color: var(--btn-color, #888);
    color: var(--btn-color, #888);
    background: rgba(255, 255, 255, 0.04);
}

.sw3d-cat-btn:hover { border-color: #3a5a7a; color: #8ab; }

.sw3d-feat-btn {
    font-family: 'Courier New', monospace;
    font-size: 9px; letter-spacing: 0.5px;
    padding: 3px 8px;
    border: 1px solid #1a3050; border-radius: 3px;
    background: transparent; color: #3a5a7a;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}

.sw3d-feat-btn.active {
    border-color: #ff9900; color: #ff9900;
    background: rgba(255, 153, 0, 0.06);
}

.sw3d-feat-btn:hover { border-color: #5a7a9a; color: #8ab; }

.sw3d-view-btn {
    font-family: 'Courier New', monospace;
    font-size: 9px; letter-spacing: 0.5px;
    padding: 3px 10px;
    border: 1px solid #1a3050; border-radius: 3px;
    background: transparent; color: #3a5a7a;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}

.sw3d-view-btn.active {
    border-color: #ff9900; color: #ff9900;
    background: rgba(255, 153, 0, 0.06);
}

.sw3d-view-btn:hover { border-color: #5a7a9a; color: #8ab; }

/* Altitude slider group */
.sw3d-alt-slider-group { display: flex; align-items: center; gap: 6px; }

.sw3d-alt-value {
    font-size: 9px; color: #5a7a9a;
    min-width: 80px; text-align: center; white-space: nowrap;
}

.sw3d-alt-range {
    -webkit-appearance: none; appearance: none;
    width: 80px; height: 4px;
    background: #1a3050; border-radius: 2px; outline: none;
}

.sw3d-alt-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 10px; height: 14px;
    background: #ff9900; border-radius: 2px; cursor: pointer;
}

.sw3d-alt-range::-moz-range-thumb {
    width: 10px; height: 14px;
    background: #ff9900; border: none; border-radius: 2px; cursor: pointer;
}

.sw3d-ctrl-spacer { flex: 1; }

/* ── Terrain Controls ──────────────────────────────────────────────────── */

.terrain-controls { display: none; align-items: center; }
.terrain-controls.visible { display: flex; }
#sw3d-controls .sw3d-ctrl-sep.terrain-controls { width: 1px; }

.terrain-slider {
    -webkit-appearance: none; appearance: none;
    width: 70px; height: 4px;
    background: #1a3050; border-radius: 2px; outline: none;
    margin: 0 2px;
}

.terrain-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 10px; height: 14px;
    background: #00ff88; border-radius: 2px; cursor: pointer;
}

.terrain-slider::-moz-range-thumb {
    width: 10px; height: 14px;
    background: #00ff88; border: none; border-radius: 2px; cursor: pointer;
}

.terrain-slider-label {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #00ff88;
    min-width: 28px;
    text-align: left;
    white-space: nowrap;
}

/* TERRAIN button uses Skywatch green when active */
.sw3d-feat-btn[data-feat="terrain"].active,
.sw3d-feat-btn[data-feat="places"].active {
    border-color: #00ff88; color: #00ff88;
    background: rgba(0, 255, 136, 0.06);
}

/* Map style cycle button */
.sw3d-style-btn {
    border-color: #00ff88 !important;
    color: #00ff88 !important;
    background: rgba(0, 255, 136, 0.06);
    min-width: 56px;
    text-align: center;
}

.sw3d-style-btn.loading {
    border-color: #5a7a9a !important;
    color: #5a7a9a !important;
    background: transparent;
    animation: sw3d-loading-pulse 1.0s ease-in-out infinite;
}

/* When inside terrain-controls and terrain is off, hide */
.sw3d-style-btn.terrain-controls { display: none; }
.sw3d-style-btn.terrain-controls.visible { display: inline-block; }

/* ── Loading Indicator ─────────────────────────────────────────────────── */

.sw3d-terrain-loading {
    margin-top: 6px;
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #00ff88;
    letter-spacing: 1.5px;
    animation: sw3d-loading-pulse 1.2s ease-in-out infinite;
}

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

/* ── Freelook HUD ──────────────────────────────────────────────────────── */

.sw3d-freelook-hud {
    margin-top: 6px;
    font-family: 'Courier New', monospace;
    font-size: 9px;
}

.sw3d-freelook-mode {
    color: #ffcc00;
    font-weight: bold;
    letter-spacing: 2px;
    font-size: 10px;
    text-shadow: 0 0 4px rgba(255, 204, 0, 0.4);
}

.sw3d-fl-stats {
    display: flex;
    gap: 12px;
    color: #a0c8f0;
    margin-top: 2px;
}

.sw3d-fl-hint {
    color: #3a5a7a;
    margin-top: 2px;
    font-size: 8px;
    letter-spacing: 1px;
}

/* FREELOOK preset button — gold accent so it's visually distinct from orbit presets */
.sw3d-freelook-btn.active {
    border-color: #ffcc00 !important;
    color: #ffcc00 !important;
    background: rgba(255, 204, 0, 0.08) !important;
}
