/* Shadow Fleet Observatory — Strait of Hormuz */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0e17;
    color: #e0e6ed;
    overflow: hidden;
    height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────── */

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 420px;
    min-width: 420px;
    background: #0f1420;
    border-right: 1px solid #1e2a3a;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow-y: auto;
}

#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* ── Header ─────────────────────────────────────────────────────── */

.header {
    padding: 20px;
    border-bottom: 1px solid #1e2a3a;
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
    color: #f0f4f8;
    letter-spacing: -0.3px;
}

.header .subtitle {
    font-size: 12px;
    color: #6b7a8d;
    margin-top: 4px;
}

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

.controls {
    padding: 12px 20px;
    border-bottom: 1px solid #1e2a3a;
}

.control-group {
    margin-bottom: 8px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #6b7a8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

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

.control-row input[type="date"] {
    flex: 1;
    background: #1a2232;
    border: 1px solid #2a3a4e;
    color: #c8d0da;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
}

select {
    width: 100%;
    background: #1a2232;
    border: 1px solid #2a3a4e;
    color: #c8d0da;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
}

button.btn-fetch {
    width: 100%;
    padding: 8px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s;
}

button.btn-fetch:hover {
    background: #1d4ed8;
}

button.btn-fetch:disabled {
    background: #1a2232;
    color: #4a5568;
    cursor: not-allowed;
}

/* ── Layer toggles ──────────────────────────────────────────────── */

.layers {
    padding: 10px 20px;
    border-bottom: 1px solid #1e2a3a;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 13px;
}

.layer-toggle input[type="checkbox"] {
    display: none;
}

.layer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.layer-dot.encounters { background: #f59e0b; }
.layer-dot.gaps { background: #ef4444; }
.layer-dot.loitering { background: #8b5cf6; }

.layer-toggle .count {
    margin-left: auto;
    font-size: 12px;
    color: #6b7a8d;
    font-variant-numeric: tabular-nums;
}

.layer-toggle.inactive {
    opacity: 0.4;
}

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

.stats {
    padding: 10px 20px;
    border-bottom: 1px solid #1e2a3a;
}

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

.stat-card {
    background: #1a2232;
    border-radius: 6px;
    padding: 12px;
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #f0f4f8;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    font-size: 11px;
    color: #6b7a8d;
    margin-top: 2px;
}

/* ── Event detail panel ─────────────────────────────────────────── */

.detail-panel {
    padding: 12px 20px;
    flex: 1;
    overflow-y: auto;
}

.detail-panel h3 {
    font-size: 14px;
    font-weight: 600;
    color: #f0f4f8;
    margin-bottom: 12px;
}

.detail-panel .empty {
    color: #4a5568;
    font-size: 13px;
    font-style: italic;
}

.event-card {
    background: #1a2232;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}

.event-card:hover {
    background: #1e2a3e;
}

.event-card.encounter { border-left-color: #f59e0b; }
.event-card.gap { border-left-color: #ef4444; }
.event-card.loitering { border-left-color: #8b5cf6; }

.event-card .vessel-name {
    font-size: 13px;
    font-weight: 600;
    color: #f0f4f8;
}

.event-card .vessel-flag {
    font-size: 12px;
    color: #6b7a8d;
    margin-left: 6px;
}

.event-card .event-meta {
    font-size: 12px;
    color: #8a95a5;
    margin-top: 4px;
}

.event-card .encounter-with {
    font-size: 12px;
    color: #f59e0b;
    margin-top: 4px;
}

.event-card .sanctioned-badge {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
}

/* ── Map overlay controls ───────────────────────────────────────── */

.map-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
}

.map-overlay .region-label {
    background: rgba(15, 20, 32, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid #1e2a3a;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12px;
    color: #8a95a5;
}

/* ── Map popup ──────────────────────────────────────────────────── */

.maplibregl-popup-content {
    background: #1a2232 !important;
    color: #e0e6ed !important;
    border: 1px solid #2a3a4e !important;
    border-radius: 6px !important;
    padding: 12px !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
    font-size: 13px !important;
    max-width: 280px !important;
}

.maplibregl-popup-tip {
    border-top-color: #2a3a4e !important;
}

.popup-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 12px;
}

.popup-row .label {
    color: #6b7a8d;
}

/* ── Loading indicator ──────────────────────────────────────────── */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    display: none;
}

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

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #1e2a3a;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

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

#sidebar::-webkit-scrollbar-thumb {
    background: #2a3a4e;
    border-radius: 3px;
}
