/* ==========================================================================
   BUREAU OF XENOLOGICAL SAFETY & ATMOSPHERIC DEFENSE (BXSG)
   CLASSIFIED GEOSPATIAL TERMINAL // STYLESHEET
   ========================================================================== */

:root {
    --color-bg: #06080c;
    --color-surface: #0c1017;
    --color-surface-elevated: #131a24;
    --color-border: #222d3d;
    --color-border-glow: rgba(212, 175, 55, 0.4);
    
    --color-gold: #d4af37;
    --color-gold-bright: #ffd700;
    --color-gold-dim: #997a15;
    --color-crimson: #8b152b;
    --color-crimson-glow: #e6194b;
    --color-amber: #ffaa00;
    --color-green: #00e676;
    
    --color-text: #e6edf3;
    --color-text-dim: #8b9bb4;
    --color-text-muted: #53637a;

    --font-heading: 'Cinzel', serif;
    --font-ui: 'Syne', sans-serif;
    --font-mono: 'Courier Prime', monospace;

    --header-height: 60px;
    --ticker-height: 44px;
}

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

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Background Stardust & Grid */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

/* Optional CRT Scanlines */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 900;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 3px, 6px 100%;
    opacity: 0.8;
}

.crt-overlay.disabled {
    display: none;
}

/* --------------------------------------------------------------------------
   TOP CLASSIFICATION HEADER
   -------------------------------------------------------------------------- */
.terminal-header {
    position: relative;
    z-index: 20;
    height: var(--header-height);
    background: rgba(12, 16, 23, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.seal-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px var(--color-gold));
}

.header-title-group h1 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--color-gold);
    text-transform: uppercase;
}

.header-subtitle {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-text-dim);
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.classification-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    background: rgba(139, 21, 43, 0.3);
    border: 1px solid var(--color-crimson);
    color: var(--color-crimson-glow);
    border-radius: 4px;
    letter-spacing: 1px;
}

.header-btn {
    background: rgba(19, 26, 36, 0.8);
    border: 1px solid var(--color-border);
    color: var(--color-text-dim);
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
}

.back-link {
    color: var(--color-text-dim);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--color-gold);
}

/* --------------------------------------------------------------------------
   MAIN LAYOUT CONTAINER
   -------------------------------------------------------------------------- */
.app-container {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
    margin-bottom: var(--ticker-height);
}

/* --------------------------------------------------------------------------
   SEARCH & GPS GEODETIC CONTROL BAR
   -------------------------------------------------------------------------- */
.control-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    position: relative;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 1rem;
}

.search-input {
    width: 100%;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 12px 16px 12px 42px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0f151f;
    border: 1px solid var(--color-gold-dim);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--color-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.15s;
}

.autocomplete-item:hover {
    background: rgba(212, 175, 55, 0.15);
    color: var(--color-gold-bright);
}

/* Action Buttons in Control Bar */
.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid var(--color-border);
}

.gps-btn {
    background: rgba(19, 26, 36, 0.9);
    color: var(--color-gold);
    border-color: var(--color-gold-dim);
}

.gps-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--color-gold-bright);
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.3);
}

.search-submit-btn {
    background: var(--color-crimson);
    color: #ffffff;
    border-color: #a81c37;
}

.search-submit-btn:hover {
    background: #a81c37;
    box-shadow: 0 0 14px rgba(230, 25, 75, 0.4);
}

/* --------------------------------------------------------------------------
   GRID LAYOUT: RADAR MAP + TELEMETRY HUD
   -------------------------------------------------------------------------- */
.workspace-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
    flex: 1;
    min-height: 600px;
}

@media (max-width: 1080px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* Map Panel Container */
.map-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.panel-header {
    background: rgba(19, 26, 36, 0.95);
    border-bottom: 1px solid var(--color-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 1.5px;
    color: var(--color-gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--color-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--color-green);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* Map Wrapper */
.map-wrapper {
    position: relative;
    flex: 1;
    min-height: 520px;
    height: 540px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 520px;
    background: #06080c;
    z-index: 10;
}

/* Custom Interactive UAP Incident Tag Badges on OpenStreetMap */
.uap-map-tag-container {
    background: none !important;
    border: none !important;
}

.uap-map-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(8, 12, 19, 0.94);
    border: 1.5px solid var(--tag-color, var(--color-gold));
    padding: 2px 7px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.85), 0 0 10px var(--tag-glow, rgba(212, 175, 55, 0.4));
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.uap-map-tag:hover {
    background: rgba(18, 24, 38, 0.98);
    border-color: #ffd700;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.9), 0 4px 20px rgba(0, 0, 0, 0.95);
    transform: translate(-50%, -55%) scale(1.18);
    z-index: 1000 !important;
}

.uap-tag-icon {
    font-size: 0.86rem;
    line-height: 1;
    display: inline-block;
}

.uap-tag-year {
    color: var(--tag-color, #ffd700);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Custom Target Pin for Selected Location */
.target-pin-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.target-pin {
    width: 26px;
    height: 26px;
    border: 3px solid #ffd700;
    border-radius: 50%;
    background: rgba(230, 25, 75, 0.4);
    box-shadow: 0 0 20px #ffd700, 0 0 30px rgba(230, 25, 75, 0.8), inset 0 0 10px #ffd700;
    position: relative;
    animation: target-pulse 1.8s infinite ease-in-out;
}

@keyframes target-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 28px #ffd700, 0 0 40px rgba(230, 25, 75, 1); }
}

.target-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px #ffffff;
}

/* Leaflet Custom Layer Switcher and Zoom Controls */
.leaflet-control-layers {
    background: rgba(12, 16, 23, 0.94) !important;
    border: 1px solid var(--color-gold) !important;
    border-radius: 6px !important;
    color: #ffd700 !important;
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    padding: 6px 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8) !important;
}

.leaflet-control-layers-expanded {
    background: rgba(12, 16, 23, 0.96) !important;
    padding: 10px 14px !important;
}

.leaflet-control-layers label {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 4px 0 !important;
    cursor: pointer !important;
    color: #e6edf3 !important;
}

.leaflet-control-layers label:hover {
    color: var(--color-gold-bright) !important;
}

.leaflet-control-zoom a {
    background: rgba(12, 16, 23, 0.92) !important;
    color: #ffd700 !important;
    border: 1px solid var(--color-border) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(212, 175, 55, 0.2) !important;
    color: #ffffff !important;
}

/* Target Crosshair Overlay */
.target-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    pointer-events: none;
    z-index: 450;
}

.target-crosshair::before,
.target-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(212, 175, 55, 0.6);
}

.target-crosshair::before {
    top: 0; left: 29px; width: 2px; height: 60px;
}

.target-crosshair::after {
    top: 29px; left: 0; width: 60px; height: 2px;
}

.crosshair-circle {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--color-gold);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

/* Map Footer Telemetry Coordinates */
.map-footer {
    background: rgba(12, 16, 23, 0.95);
    border-top: 1px solid var(--color-border);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-text-dim);
}

/* --------------------------------------------------------------------------
   TELEMETRY ASSESSMENT HUD (RIGHT PANEL)
   -------------------------------------------------------------------------- */
.hud-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
    overflow-y: auto;
}

/* Primary Hazard Rating Display */
.hazard-score-card {
    background: linear-gradient(135deg, rgba(25, 2, 7, 0.8), rgba(12, 16, 23, 0.95));
    border: 1px solid var(--color-gold-dim);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.hazard-card-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--color-text-dim);
    margin-bottom: 8px;
}

.score-display-group {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.score-number {
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    color: var(--color-crimson-glow);
    text-shadow: 0 0 24px rgba(230, 25, 75, 0.6);
}

.score-total {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--color-text-muted);
}

.classification-badge {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 6px 16px;
    border-radius: 4px;
    background: rgba(139, 21, 43, 0.35);
    border: 1px solid var(--color-crimson);
    color: #ff8097;
    margin-bottom: 12px;
}

.hazard-summary-text {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--color-text-dim);
    line-height: 1.4;
}

/* Sub-Metrics Section */
.metrics-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-row {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 14px;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.metric-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text);
}

.metric-val {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--color-gold);
}

.metric-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.metric-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-gold), var(--color-crimson));
    border-radius: 3px;
    transition: width 0.6s ease;
}

.metric-desc {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

/* Nearest Sighting Briefing Card */
.sighting-dossier-card {
    background: rgba(19, 26, 36, 0.6);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-gold);
    border-radius: 4px;
    padding: 12px 14px;
}

.dossier-header {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-gold);
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.dossier-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.dossier-body {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-dim);
}

/* Primary Issue Certificate Action Button */
.issue-certificate-btn {
    background: linear-gradient(135deg, #a81c37, #660d1d);
    border: 1px solid var(--color-gold);
    color: #ffffff;
    padding: 14px 20px;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(168, 28, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.25s ease;
}

.issue-certificate-btn:hover {
    background: linear-gradient(135deg, #c42343, #851227);
    box-shadow: 0 0 24px rgba(212, 175, 55, 0.5);
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   CERTIFICATE MODAL & PREVIEW
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-window {
    background: #0f141d;
    border: 1px solid var(--color-gold);
    border-radius: 10px;
    max-width: 1050px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9), 0 0 30px rgba(212, 175, 55, 0.2);
    overflow: hidden;
}

.modal-header {
    background: #141c28;
    border-bottom: 1px solid var(--color-border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--color-gold);
    letter-spacing: 1.5px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #ff4d4d;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.certificate-canvas-wrapper {
    width: 100%;
    max-width: 920px;
    border: 2px solid var(--color-gold);
    box-shadow: 0 8px 36px rgba(0, 0, 0, 0.9), 0 0 20px rgba(212, 175, 55, 0.2);
    border-radius: 6px;
    overflow: hidden;
    background: #020305;
    display: flex;
    justify-content: center;
}

#certificate-canvas {
    width: 100%;
    height: auto;
    max-height: 68vh;
    aspect-ratio: 2970 / 2100;
    object-fit: contain;
    display: block;
}

.modal-actions {
    display: flex;
    gap: 16px;
    width: 100%;
    justify-content: center;
}

.modal-download-btn {
    background: var(--color-gold);
    color: #1a0f00;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 28px;
    border-radius: 6px;
    border: 1px solid #ffd700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.modal-download-btn:hover {
    background: var(--color-gold-bright);
    box-shadow: 0 0 24px rgba(212, 175, 55, 0.8);
}

/* --------------------------------------------------------------------------
   LIVE UAP NEWS WIRE TICKER (DOCKED AT BOTTOM)
   -------------------------------------------------------------------------- */
.uap-news-ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: var(--ticker-height);
    background: rgba(10, 13, 18, 0.95);
    border-top: 1px solid var(--color-border);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 16px;
    overflow: hidden;
}

.ticker-prefix {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 16px;
    border-right: 1px solid var(--color-border);
    white-space: nowrap;
    z-index: 2;
    background: rgba(10, 13, 18, 0.95);
}

.ticker-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-gold);
    letter-spacing: 1px;
}

.ticker-track-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.ticker-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: ticker-scroll 45s linear infinite;
}

.ticker-track:hover {
    animation-play-state: paused;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--color-text);
    transition: color 0.2s;
}

.ticker-item:hover {
    color: var(--color-gold);
}

.ticker-badge {
    color: var(--color-gold);
    font-weight: 700;
}

.ticker-date {
    color: var(--color-green);
    font-weight: 700;
    font-size: 0.74rem;
    margin-right: 4px;
    letter-spacing: 0.5px;
}

.ticker-time {
    color: var(--color-text-muted);
}

.ticker-sep {
    color: var(--color-crimson);
    margin-left: 12px;
}
