/* ============================================
   SATELLITE VISION AI - Styles
   Mission Control Aesthetic
   ============================================ */

/* CSS Variables */
:root {
    /* Colors - Deep Space Theme */
    --bg-primary: #0a0f1c;
    --bg-secondary: #0d1424;
    --bg-tertiary: #111a2e;
    --bg-panel: #0f1628;

    /* Accent Colors */
    --accent-cyan: #00d4ff;
    --accent-cyan-dim: #00a8cc;
    --accent-red: #ff3366;
    --accent-green: #00ff88;
    --accent-amber: #ffaa00;

    /* Text Colors */
    --text-primary: #e8f4f8;
    --text-secondary: #8899aa;
    --text-tertiary: #556677;

    /* Border & Lines */
    --border-color: #1a2a42;
    --border-glow: rgba(0, 212, 255, 0.3);

    /* Fonts */
    --font-mono: 'IBM Plex Mono', 'JetBrains Mono', monospace;
    --font-display: 'JetBrains Mono', monospace;

    /* Spacing */
    --sidebar-width: 340px;
    --header-height: 56px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Scanline Effect Overlay */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    animation: scanlineMove 8s linear infinite;
}

@keyframes scanlineMove {
    0% { background-position: 0 0; }
    100% { background-position: 0 100px; }
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.radar-sweep {
    width: 120px;
    height: 120px;
    position: relative;
    margin: 0 auto 30px;
}

.radar-ring {
    position: absolute;
    border: 1px solid var(--accent-cyan);
    border-radius: 50%;
    opacity: 0.3;
}

.radar-ring:nth-child(1) {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.radar-ring:nth-child(2) {
    width: 66%;
    height: 66%;
    top: 17%;
    left: 17%;
}

.radar-ring:nth-child(3) {
    width: 33%;
    height: 33%;
    top: 33.5%;
    left: 33.5%;
}

.radar-beam {
    position: absolute;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-cyan) 0%, transparent 100%);
    top: 50%;
    left: 50%;
    transform-origin: left center;
    animation: radarSweep 2s linear infinite;
    box-shadow: 0 0 20px var(--accent-cyan);
}

@keyframes radarSweep {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--text-primary);
}

.loading-status {
    font-size: 11px;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

/* ============================================
   App Container
   ============================================ */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.app-container.visible {
    opacity: 1;
}

/* ============================================
   Header
   ============================================ */
.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: relative;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--accent-cyan) 20%,
        var(--accent-cyan) 80%,
        transparent
    );
    opacity: 0.5;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-cyan);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 4px var(--accent-cyan)); }
    50% { filter: drop-shadow(0 0 12px var(--accent-cyan)); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-secondary);
}

.logo-accent {
    color: var(--accent-cyan);
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.status-label {
    font-size: 9px;
    color: var(--text-tertiary);
    letter-spacing: 1px;
}

.status-value {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.status-online {
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--accent-green); }
    50% { opacity: 0.5; box-shadow: 0 0 8px var(--accent-green); }
}

.status-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

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

.timestamp {
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 1px;
}

/* ============================================
   Main Content
   ============================================ */
.app-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

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

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

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Panel Styles */
.panel {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.panel-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-tertiary);
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 8px;
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-tab svg {
    width: 20px;
    height: 20px;
}

.mode-tab span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
}

.mode-tab:hover {
    background: var(--bg-panel);
    border-color: var(--accent-cyan-dim);
    color: var(--text-primary);
}

.mode-tab.active {
    background: var(--bg-panel);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.15), inset 0 0 20px rgba(0, 212, 255, 0.05);
}

/* Search Input */
.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-icon svg {
    width: 16px;
    height: 16px;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-suggestions.visible {
    display: block;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    transition: background var(--transition-fast);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--bg-tertiary);
    color: var(--accent-cyan);
}

/* Target Input */
.target-input-group {
    transition: opacity var(--transition-normal);
}

.target-input-group.hidden {
    display: none;
}

.target-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    transition: all var(--transition-fast);
    margin-bottom: 12px;
}

.target-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.quick-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-target {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-target:hover {
    border-color: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

.query-textarea {
    width: 100%;
    height: 100px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    resize: vertical;
    transition: all var(--transition-fast);
}

.query-textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.caption-info {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

/* Basemap Select */
.basemap-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.basemap-select:focus {
    border-color: var(--accent-cyan);
}

.basemap-select option {
    background: var(--bg-panel);
    color: var(--text-primary);
}

/* Buttons */
.action-panel {
    display: flex;
    gap: 10px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    flex: 2;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-cyan-dim) 100%);
    color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.4);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.btn-secondary {
    flex: 1;
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.btn-icon svg {
    width: 14px;
    height: 14px;
}

/* Status Panel */
.status-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-message {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-icon.idle {
    background: var(--text-tertiary);
}

.status-icon.processing {
    background: var(--accent-amber);
    animation: pulse 1s ease-in-out infinite;
}

.status-icon.success {
    background: var(--accent-green);
}

.status-icon.error {
    background: var(--accent-red);
}

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar.hidden {
    display: none;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-cyan);
}

/* Results Panel */
.results-panel.hidden {
    display: none;
}

.result-count {
    padding: 2px 8px;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
}

.results-content {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 6px;
}

.result-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.result-label {
    flex: 1;
    font-size: 11px;
}

.result-bbox {
    font-size: 10px;
    color: var(--text-tertiary);
}

.caption-result {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.query-result {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.query-result .question {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.query-result .answer {
    font-size: 13px;
    color: var(--accent-cyan);
    font-weight: 500;
}

.export-actions {
    display: flex;
    gap: 8px;
}

.btn-export {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.btn-export:hover {
    border-color: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

.btn-export svg {
    width: 14px;
    height: 14px;
}

/* Instructions Panel */
.instructions-panel .panel-header {
    cursor: pointer;
}

.collapse-icon {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.instructions-panel.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.instructions-content {
    transition: all var(--transition-normal);
}

.instructions-panel.collapsed .instructions-content {
    display: none;
}

.instruction-list {
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 11px;
}

.instruction-list li {
    margin-bottom: 8px;
}

.instruction-list li::marker {
    color: var(--accent-cyan);
}

/* ============================================
   Map Container
   ============================================ */
.map-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
}

/* Leaflet customization */
.leaflet-container {
    font-family: var(--font-mono);
    background: var(--bg-primary);
}

.leaflet-control-zoom {
    display: none;
}

.leaflet-control-attribution {
    background: rgba(10, 15, 28, 0.8) !important;
    color: var(--text-tertiary) !important;
    font-size: 9px !important;
    padding: 2px 8px !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Draw control styling */
.leaflet-draw-toolbar a {
    background-color: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.leaflet-draw-toolbar a:hover {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--accent-cyan) !important;
}

.leaflet-draw-actions {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-draw-actions a {
    background: transparent !important;
    color: var(--text-primary) !important;
}

.leaflet-draw-actions a:hover {
    background: var(--bg-tertiary) !important;
    color: var(--accent-cyan) !important;
}

/* Map overlay controls */
.map-overlay-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.map-control-btn:hover {
    border-color: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

.map-control-btn.active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.map-control-btn svg {
    width: 18px;
    height: 18px;
}

.control-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Selection Info Overlay */
.selection-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(15, 22, 40, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    z-index: 1000;
    min-width: 200px;
}

.selection-info.hidden {
    display: none;
}

.selection-coords {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 11px;
}

.coord-label {
    color: var(--text-tertiary);
}

.coord-value {
    color: var(--accent-cyan);
    font-weight: 500;
}

.selection-area {
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.area-value {
    color: var(--accent-green);
    font-size: 12px;
    font-weight: 600;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 40vh;
    }

    .app-main {
        flex-direction: column;
    }

    .map-container {
        height: 60vh;
    }

    .header-center {
        display: none;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel {
    animation: fadeInUp 0.4s ease forwards;
}

.panel:nth-child(1) { animation-delay: 0.1s; }
.panel:nth-child(2) { animation-delay: 0.15s; }
.panel:nth-child(3) { animation-delay: 0.2s; }
.panel:nth-child(4) { animation-delay: 0.25s; }
.panel:nth-child(5) { animation-delay: 0.3s; }
.panel:nth-child(6) { animation-delay: 0.35s; }
.panel:nth-child(7) { animation-delay: 0.4s; }
.panel:nth-child(8) { animation-delay: 0.45s; }

/* Utility Classes */
.hidden {
    display: none !important;
}
