/* ==========================================================================
   AFA Studio | OSINT Transportation & Global Vector Globe Stylesheet
   Tactical Open Source Intelligence (OSINT) Interface & Geopolitical HUD
   ========================================================================== */

:root {
    --bg-dark: #020617;
    --card-bg: rgba(11, 19, 43, 0.82);
    --border-color: rgba(56, 189, 248, 0.2);
    --border-hover: rgba(56, 189, 248, 0.5);
    --accent-cyan: #38bdf8;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-crimson: #ef4444;
    --accent-purple: #c084fc;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --hud-dock-top: 10.5rem;
}

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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

#webgl-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Glassmorphic Base HUD */
.hud-header,
.hud-telemetry,
.target-inspector,
.hud-bottom-bar {
    position: absolute;
    z-index: 10;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
    border-radius: 12px;
}

/* Top Header */
.hud-header {
    top: 1.15rem;
    left: 1.5rem;
    right: 1.5rem;
    padding: 0.85rem 1.35rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    z-index: 30;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    letter-spacing: 0.12em;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s ease;
}

.brand-badge:hover {
    color: #ffffff;
}

.hud-live-tag {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 0.1rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
}

.hud-header h1 {
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Header Center Search Bar */
.header-center-search {
    flex: 1;
    max-width: 380px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 2.2rem 0.55rem 0.85rem;
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.search-input::placeholder {
    color: #64748b;
    font-family: var(--font-main);
}

.search-btn {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--accent-cyan);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
}

/* Header Controls & Filter Pills */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hud-btn {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.42rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.hud-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    color: #ffffff;
    border-color: var(--accent-cyan);
}

.hud-btn.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.hud-btn-link {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 0.42rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.hud-btn-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.live-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--accent-emerald);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    animation: radar-pulse 2s infinite ease-in-out;
}

@keyframes radar-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

/* Category Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-pill {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 0.28rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

.filter-pill.active {
    background: rgba(56, 189, 248, 0.22);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    font-weight: 700;
}

.filter-pill.active-anomaly {
    background: rgba(239, 68, 68, 0.22);
    border-color: var(--accent-crimson);
    color: var(--accent-crimson);
}

/* Right Side Telemetry Glass Panel */
.hud-telemetry {
    top: var(--hud-dock-top, 10.5rem);
    right: 1.5rem;
    width: 360px;
    max-height: calc(100vh - var(--hud-dock-top, 10.5rem) - 1.5rem);
    z-index: 15;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.hud-telemetry.collapsed .telemetry-body {
    display: none;
}

.panel-ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.panel-ctrl-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #ffffff;
    border-color: var(--accent-cyan);
}

.telemetry-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
    user-select: none;
}

.telemetry-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.telemetry-body {
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Telemetry Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.metric-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.metric-card.full-width {
    grid-column: 1 / -1;
}

.metric-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-family: var(--font-mono);
}

.metric-value {
    font-size: 1.05rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #ffffff;
}

.val-cyan { color: var(--accent-cyan); }
.val-emerald { color: var(--accent-emerald); }
.val-amber { color: var(--accent-amber); }
.val-crimson { color: var(--accent-crimson); }

/* Chokepoints Interactive List */
.chokepoints-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-family: var(--font-mono);
    display: flex;
    justify-content: space-between;
}

.chokepoints-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.chokepoint-item {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chokepoint-item:hover {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--accent-cyan);
    transform: translateX(2px);
}

.chokepoint-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.cp-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f1f5f9;
}

.cp-risk-badge {
    font-size: 0.62rem;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.cp-risk-critical {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.cp-risk-high {
    background: rgba(245, 158, 11, 0.2);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.cp-risk-elevated {
    background: rgba(234, 179, 8, 0.2);
    color: #fef08a;
    border: 1px solid rgba(234, 179, 8, 0.4);
}

.cp-risk-low {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.cp-meta {
    font-size: 0.68rem;
    color: #94a3b8;
    line-height: 1.35;
}

/* Floating Target Inspector Card */
.target-inspector {
    bottom: 2rem;
    left: 1.5rem;
    width: 360px;
    padding: 1rem;
    display: none;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.inspector-title-col {
    display: flex;
    flex-direction: column;
}

.inspector-callsign {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    font-family: var(--font-mono);
}

.inspector-sub {
    font-size: 0.72rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
}

.inspector-badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.badge-normal {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-anomaly {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
    animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: rgba(239, 68, 68, 0.5); }
    50% { border-color: rgba(239, 68, 68, 1.0); }
}

.inspector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.inspector-row {
    display: flex;
    flex-direction: column;
}

.insp-label {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    font-family: var(--font-mono);
}

.insp-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f1f5f9;
    font-family: var(--font-mono);
}

.inspector-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.inspector-close-btn:hover {
    color: #ffffff;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-content {
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 760px;
    max-height: 85vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    color: var(--accent-cyan);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #cbd5e1;
}

.modal-body h3 {
    color: #ffffff;
    margin: 1.2rem 0 0.5rem 0;
    font-size: 1.05rem;
}

.modal-body p {
    margin-bottom: 0.85rem;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
}
::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.6);
}

/* Responsive Rules */
@media (max-width: 1024px) {
    .hud-header {
        left: 1rem;
        right: 1rem;
        top: 1rem;
        padding: 0.75rem 1rem;
    }
    .header-center-search {
        order: 3;
        max-width: 100%;
        width: 100%;
    }
    .hud-telemetry {
        display: none; /* Can be toggled on mobile */
    }
    .target-inspector {
        left: 1rem;
        right: 1rem;
        width: auto;
        bottom: 1rem;
    }
}
