/* ── OSINT Explorer — Dark Theme ── */

:root {
    --bg-primary: #0a0e17;
    --bg-panel: #0d1320;
    --bg-card: #131b2e;
    --bg-card-hover: #1a2540;
    --bg-card-active: #162044;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-active: #3b82f6;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-muted: rgba(59, 130, 246, 0.6);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius: 8px;
    --transition: 200ms ease;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

#app {
    display: grid;
    grid-template-columns: 1fr 60px;
    height: 100vh;
    width: 100vw;
}

#globeContainer {
    position: relative;
    overflow: hidden;
    cursor: grab;
}

#globeContainer:active {
    cursor: grabbing;
}

#globeContainer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── MapLibre Overlay ── */

/* MapLibre container positioning is set via inline styles in map-bridge.js
   to override MapLibre's own CSS. Only supplementary styles here. */

/* Hide MapLibre's own attribution (we have our own) */
#maplibreContainer .maplibregl-ctrl-attrib {
    display: none;
}

/* Darken MapLibre navigation controls to match theme */
#maplibreContainer .maplibregl-ctrl-group {
    display: none; /* we use our own controls */
}

/* User location marker on MapLibre map */
.maplibre-user-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    border: 3px solid #93c5fd;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.6),
                0 0 12px rgba(37, 99, 235, 0.3);
    cursor: default;
    animation: markerPulse 4s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(37, 99, 235, 0.6), 0 0 12px rgba(37, 99, 235, 0.3); }
    50% { box-shadow: 0 0 8px rgba(37, 99, 235, 0.7), 0 0 16px rgba(37, 99, 235, 0.4); }
}

/* Globe-only controls hidden when map is active */
.map-controls.map-mode .rotate-btn,
.map-controls.map-mode .autorotate-toggle,
.map-controls.map-mode .stars-toggle,
.map-controls.map-mode .compass-btn {
    display: none;
}

/* ── Layer Panel ── */

#layerPanel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    overflow: hidden;
    z-index: 10;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 0 6px;
}

.panel-logo {
    color: var(--accent);
    flex-shrink: 0;
}

.panel-title {
    display: none;
}

.panel-subtitle {
    display: none;
}

/* ── Layer List ── */

.layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.layer-list::-webkit-scrollbar {
    width: 4px;
}

.layer-list::-webkit-scrollbar-track {
    background: transparent;
}

.layer-list::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

/* ── Layer Card ── */

.layer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 56px;
    gap: 2px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    user-select: none;
    position: relative;
}

.layer-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-subtle);
}

.layer-card.active {
    background: var(--bg-card-active);
    border-color: var(--border-active);
    box-shadow: 0 0 20px var(--accent-glow), inset 0 0 20px var(--accent-glow);
}

.layer-card-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition), background var(--transition);
}

.layer-card.active .layer-card-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.layer-card:hover .layer-card-icon {
    color: var(--text-secondary);
}

.layer-card-icon svg {
    width: 20px;
    height: 20px;
}

.layer-card-label {
    font-size: 7px;
    color: #ffffff;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44px;
    letter-spacing: 0.02em;
}

/* ── Panel Footer ── */

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
}

.status-text {
    display: none;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition), box-shadow var(--transition);
}

.status-dot.active {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

/* ── Loading overlay ── */

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 100;
    transition: opacity 0.8s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

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

/* ── Satellite Tooltip ── */

.sat-tooltip {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    background: rgba(13, 19, 32, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 14px;
    min-width: 190px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 12px var(--accent-glow);
    font-size: 12px;
}

.sat-tooltip-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.sat-tooltip-header svg {
    color: var(--accent);
    flex-shrink: 0;
}

.sat-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sat-tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.sat-tooltip-row span:first-child {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.sat-tooltip-row span:last-child {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    color: var(--text-primary);
    font-size: 12px;
}

.sat-tooltip-hint {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.03em;
}

/* ── Responsive ── */

/* Tablet */
@media (max-width: 1024px) {
    .map-controls {
        bottom: 12px;
        right: 12px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    #app {
        grid-template-columns: 1fr;
    }

    /* Pull panel out of grid flow, fix to bottom of visible viewport */
    #layerPanel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        flex-direction: row;
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        background: var(--bg-panel);
        overflow: hidden;
        z-index: 200;
    }

    .panel-header,
    .panel-subtitle,
    .panel-footer {
        display: none !important;
    }

    .layer-list {
        flex-direction: row;
        flex: none;
        width: 100%;
        height: 100%;
        overflow-y: hidden;
        overflow-x: auto;
        padding: 6px 8px;
        gap: 6px;
        align-items: center;
        justify-content: flex-start;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .layer-list::-webkit-scrollbar {
        display: none;
    }

    .layer-card {
        flex-shrink: 0;
        width: calc((100vw - 16px - 24px) / 5);
        max-width: 52px;
        height: 44px;
    }

    .bottom-bar {
        bottom: 56px;
    }

    .map-controls {
        bottom: 80px;
        right: 12px;
    }
}

/* ── Bottom Bar (attribution + contact) ── */

.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #000 !important;
    padding: 5px 12px;
    z-index: 100;
    pointer-events: auto;
    font-size: 11px;
    color: #fff !important;
}

.map-attribution,
.map-attribution a,
.contact-link {
    color: #fff !important;
    background: none !important;
    opacity: 1 !important;
}

.map-attribution a,
.contact-link {
    text-decoration: none;
}

.map-attribution a:hover,
.contact-link:hover {
    text-decoration: underline;
}

.contact-link {
    font-size: 11px;
    white-space: nowrap;
    margin-left: 12px;
}

/* Hide MapLibre's built-in attribution (we show it in our bottom bar) */
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-logo {
    display: none !important;
}

/* ── Map Controls ── */

.map-controls {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 50;
}

.control-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.control-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
    border-color: var(--accent-muted);
}

.control-btn:active {
    background: var(--bg-card-active);
}

.compass-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    margin-bottom: 4px;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform 0.3s ease;
}

.compass-north {
    fill: #ef4444;
}

.zoom-level {
    width: 38px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    letter-spacing: 0.02em;
    user-select: none;
}

.control-toggle {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    margin-top: 4px;
}

.control-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
    border-color: var(--accent-muted);
}

.control-toggle input {
    display: none;
}

.control-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ff6b6b, #ef4444 50%, #dc2626);
    box-shadow:
        0 0 3px 1px rgba(239, 68, 68, 0.7),
        0 0 6px 2px rgba(239, 68, 68, 0.3);
    animation: statusPulseRed 2.5s ease-in-out infinite;
    z-index: 1;
    pointer-events: none;
}

.control-toggle:has(input:checked)::after {
    background: radial-gradient(circle at 35% 35%, #6ee7a0, #22c55e 50%, #16a34a);
    box-shadow:
        0 0 3px 1px rgba(34, 197, 94, 0.7),
        0 0 6px 2px rgba(34, 197, 94, 0.3);
    animation: statusPulseGreen 2.5s ease-in-out infinite;
}

@keyframes statusPulseRed {
    0%, 100% {
        box-shadow:
            0 0 3px 1px rgba(239, 68, 68, 0.7),
            0 0 6px 2px rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow:
            0 0 4px 1px rgba(239, 68, 68, 0.9),
            0 0 10px 3px rgba(239, 68, 68, 0.4);
    }
}

@keyframes statusPulseGreen {
    0%, 100% {
        box-shadow:
            0 0 3px 1px rgba(34, 197, 94, 0.7),
            0 0 6px 2px rgba(34, 197, 94, 0.3);
    }
    50% {
        box-shadow:
            0 0 4px 1px rgba(34, 197, 94, 0.9),
            0 0 10px 3px rgba(34, 197, 94, 0.4);
    }
}

/* ── Satellite Loading Spinner ── */

.sat-loading {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: satLoadIn 0.3s ease-out;
    transition: opacity 0.5s ease;
}

.sat-loading--fade {
    opacity: 0;
    pointer-events: none;
}

.sat-loading__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.sat-loading__text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

@keyframes satLoadIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Satellite Legend ── */

.sat-legend {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    pointer-events: auto;
    animation: legendSlideIn 0.35s ease-out;
}

@keyframes legendSlideIn {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}

.sat-legend-inner {
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* ── Legend rows ── */

.sat-legend-row {
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.sat-legend-row--top {
    height: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sat-legend-row--items {
    height: 36px;
    gap: 12px;
}

/* ── Title section ── */

.sat-legend-title {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    flex-shrink: 0;
}

.sat-legend-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.sat-legend-title > span:first-of-type {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.sat-legend-total {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 2px;
}

/* ── Hint (right-aligned on top row) ── */

.sat-legend-hint {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    margin-left: auto;
    opacity: 0.6;
    letter-spacing: 0.01em;
}

/* ── Category items row ── */

.sat-legend-cats {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sat-legend-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sat-legend-special {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

/* ── Individual legend item ── */

.sat-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.sat-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sat-legend-ring {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid #fbbf24;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sat-legend-label {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.sat-legend-count {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 10px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1.4;
}

/* ── ISS & live badge ── */

.sat-legend-iss .sat-legend-label {
    font-weight: 600;
    color: #22c55e;
}

.sat-legend-count--live {
    color: #22c55e !important;
    background: rgba(34, 197, 94, 0.12) !important;
    border-color: rgba(34, 197, 94, 0.25) !important;
    font-weight: 600;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ── Satellite Legend — Tablet ── */

@media (max-width: 1024px) {
    .sat-legend-row { padding: 0 12px; }
    .sat-legend-row--top { height: 28px; }
    .sat-legend-row--items { height: 32px; gap: 8px; overflow-x: auto; scrollbar-width: none; }
    .sat-legend-row--items::-webkit-scrollbar { display: none; }
    .sat-legend-cats { gap: 10px; }
    .sat-legend-special { gap: 10px; }
    .sat-legend-hint { display: none; }
}

/* ── Satellite Legend — Mobile: hidden ── */

@media (max-width: 768px) {
    .sat-legend {
        display: none;
    }
}

/* ── Satellite Detail Popup ── */

.sat-popup {
    position: fixed;
    z-index: 900;
    display: flex;
    flex-direction: column;
    background: rgba(10, 14, 23, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
    animation: satPopupIn 0.25s ease-out;
    min-width: 340px;
    min-height: 200px;
    transition: left 0s, top 0s, width 0.25s ease, height 0.25s ease;
}

.sat-popup--closing {
    animation: satPopupOut 0.2s ease-in forwards;
}

.sat-popup--dragging {
    opacity: 0.92;
    transition: none;
}

.sat-popup--maximized {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
    transition: all 0.25s ease;
}

.sat-popup--minimized .sat-popup__body {
    display: none;
}

.sat-popup--minimized {
    height: auto !important;
    min-height: 0;
}

@keyframes satPopupIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes satPopupOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95) translateY(8px); }
}

/* ── Titlebar ── */

.sat-popup__titlebar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.sat-popup--dragging .sat-popup__titlebar {
    cursor: grabbing;
}

.sat-popup--maximized .sat-popup__titlebar {
    cursor: default;
}

.sat-popup__titlebar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    order: 2;
    width: 100%;
}

.sat-popup__color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.sat-popup__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sat-popup__badge {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.sat-popup__badge--type {
    background: rgba(167, 139, 250, 0.1);
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.2);
}

/* ── Window buttons ── */

.sat-popup__titlebar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    order: 1;
    margin-left: auto;
    margin-bottom: 4px;
}

.sat-popup__btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 150ms ease;
}

.sat-popup__btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.sat-popup__btn--close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ── Body ── */

.sat-popup__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.sat-popup__body::-webkit-scrollbar { width: 5px; }
.sat-popup__body::-webkit-scrollbar-track { background: transparent; }
.sat-popup__body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }

/* ── Category Badge ── */

.sat-popup__category-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    float: right;
    margin: 8px 10px 0 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid;
    background: rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.sat-popup__category-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Sections ── */

.sat-popup__section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sat-popup__section:last-child {
    border-bottom: none;
}

.sat-popup__section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 16px 8px;
}

/* ── Live State Grid ── */

.sat-popup__state-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 0 16px 14px;
}

.sat-popup__state-item {
    padding: 6px 0;
}

.sat-popup__state-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.sat-popup__state-value {
    font-size: 16px;
    font-weight: 600;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.sat-popup__state-value.flash {
    color: var(--accent);
}

/* ── Tables ── */

.sat-popup__table {
    width: 100%;
    border-collapse: collapse;
}

.sat-popup__table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sat-popup__table tr:last-child {
    border-bottom: none;
}

.sat-popup__table td {
    padding: 8px 16px;
    font-size: 12px;
    vertical-align: top;
}

.sat-popup__table td:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    width: 140px;
    white-space: nowrap;
}

.sat-popup__table td:last-child {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    color: var(--text-primary);
    word-break: break-all;
}

/* ── Hero (image + description from catalog) ── */

.sat-popup__hero {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.015);
}

.sat-popup__hero-image {
    width: 90px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sat-popup__hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sat-popup__hero-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.sat-popup__hero-desc {
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sat-popup__hero-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.sat-popup__hero-country {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sat-popup__hero-flag {
    font-size: 24px;
    line-height: 1;
}

.sat-popup__hero-country-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* ── Source attribution ── */

.sat-popup__source {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 10px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    opacity: 0.7;
}

.sat-popup__source-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    flex-shrink: 0;
    cursor: help;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .sat-popup {
        left: 50% !important;
        top: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        width: 100% !important;
        max-width: min(400px, 100vw);
        height: 100% !important;
        max-height: 600px;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }
    .sat-popup__body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .sat-popup__state-value { font-size: 14px; }
    .sat-popup__badge--type { display: none; }
    .sat-popup__hero-image { width: 70px; height: 70px; }
}

/* ══════════════════════════════════════════════════════════════════════
   CCTV MARKER & CLUSTER STYLES
   ══════════════════════════════════════════════════════════════════════ */

.cctv-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 40;
    overflow: hidden;
}

.cctv-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10, 14, 23, 0.85);
    border: 2px solid #38bdf8;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.cctv-marker:hover {
    transform: translate(-50%, -50%) scale(1.25);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.cctv-cluster {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    background: rgba(56, 189, 248, 0.18);
    border: 2px solid rgba(56, 189, 248, 0.6);
    border-radius: 50%;
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 8px rgba(56, 189, 248, 0.15);
}
.cctv-cluster:hover {
    transform: translate(-50%, -50%) scale(1.15);
    background: rgba(56, 189, 248, 0.3);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

/* ══════════════════════════════════════════════════════════════════════
   CCTV POPUP STYLES
   ══════════════════════════════════════════════════════════════════════ */

.cctv-popup {
    position: fixed; z-index: 900; display: flex; flex-direction: column;
    background: rgba(10, 14, 23, 0.96); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden; animation: satPopupIn 0.25s ease-out; min-width: 340px; min-height: 200px;
    transition: left 0s, top 0s, width 0.25s ease, height 0.25s ease;
}
.cctv-popup--dragging { opacity: 0.92; transition: none; }
.cctv-popup--maximized { left: 0!important; top: 0!important; width: 100vw!important; height: 100vh!important; border-radius: 0; transition: all 0.25s ease; }
.cctv-popup--minimized .cctv-popup__body { display: none; }
.cctv-popup--minimized { height: auto!important; min-height: 0; }

.cctv-popup__titlebar {
    display: flex; align-items: center; justify-content: space-between; padding: 0 12px; height: 40px;
    background: rgba(255,255,255,0.03); border-bottom: 1px solid rgba(255,255,255,0.06);
    cursor: grab; user-select: none; flex-shrink: 0;
}
.cctv-popup--dragging .cctv-popup__titlebar { cursor: grabbing; }
.cctv-popup--maximized .cctv-popup__titlebar { cursor: default; }

.cctv-popup__titlebar-left { display: flex; align-items: center; gap: 8px; overflow: hidden; flex: 1; min-width: 0; }
.cctv-popup__color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cctv-popup__flag { font-size: 16px; flex-shrink: 0; }
.cctv-popup__name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cctv-popup__badge { font-size: 10px; font-weight: 500; color: #38bdf8; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.2); border-radius: 4px; padding: 2px 6px; white-space: nowrap; flex-shrink: 0; }

.cctv-popup__titlebar-actions { display: flex; align-items: center; gap: 2px; margin-left: 8px; flex-shrink: 0; }
.cctv-popup__btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; background: transparent; color: var(--text-muted); border-radius: 6px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.cctv-popup__btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.cctv-popup__btn--close:hover { background: rgba(239,68,68,0.2); color: #ef4444; }

.cctv-popup__body { flex: 1; overflow-y: auto; padding: 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
.cctv-popup__body::-webkit-scrollbar { width: 5px; }
.cctv-popup__body::-webkit-scrollbar-track { background: transparent; }
.cctv-popup__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.cctv-popup__feed { width: 100%; height: 240px; margin-bottom: 12px; border-radius: 6px; overflow: hidden; background: #000; }
.cctv-popup__feed--placeholder { display: flex; align-items: center; justify-content: center; }
.cctv-popup__feed-msg { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.cctv-popup__feed-link { color: #38bdf8; text-decoration: none; font-size: 12px; }
.cctv-popup__feed-link:hover { text-decoration: underline; }

.cctv-popup__section { margin-bottom: 16px; }
.cctv-popup__section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #38bdf8; margin-bottom: 8px; }

.cctv-popup__table { width: 100%; border-collapse: collapse; }
.cctv-popup__table tr { border-bottom: 1px solid rgba(255,255,255,0.04); }
.cctv-popup__table tr:last-child { border-bottom: none; }
.cctv-popup__table td { padding: 5px 0; font-size: 12px; vertical-align: top; }
.cctv-popup__table td:first-child { color: var(--text-muted); font-size: 11px; white-space: nowrap; padding-right: 16px; width: 35%; }
.cctv-popup__table td:last-child { color: var(--text-primary); font-family: 'SF Mono','Cascadia Code','Fira Code',Consolas,monospace; font-size: 12px; text-align: right; }

.cctv-popup__source { display: flex; align-items: center; gap: 5px; padding: 8px 0 4px; border-top: 1px solid rgba(255,255,255,0.04); font-size: 10px; color: var(--text-muted); }
.cctv-popup__source-icon { display: flex; cursor: help; color: var(--text-muted); }

@media (max-width: 768px) {
    .cctv-popup { left: 4px!important; right: 4px!important; top: auto!important; bottom: 0!important; width: auto!important; height: 55vh!important; min-width: 0; border-radius: 16px 16px 0 0; }
    .cctv-popup--maximized { border-radius: 0; }
    .cctv-popup__body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .cctv-popup__feed { height: 180px; }
}
