/* ISS Mission Control - Clean Design System */
/* Based on superdesign principles: oklch colors, Inter font, subtle shadows */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Colors - Dark Theme (default) */
    --bg-primary: oklch(0.13 0.02 265);
    --bg-secondary: oklch(0.16 0.02 265);
    --bg-tertiary: oklch(0.20 0.02 265);
    --bg-elevated: oklch(0.18 0.02 265);

    --text-primary: oklch(0.95 0.01 265);
    --text-secondary: oklch(0.70 0.02 265);
    --text-tertiary: oklch(0.50 0.02 265);

    --accent: oklch(0.72 0.15 175);
    --accent-dim: oklch(0.55 0.12 175);
    --accent-glow: oklch(0.80 0.12 175);

    --border: oklch(0.28 0.02 265);
    --border-subtle: oklch(0.22 0.02 265);

    --success: oklch(0.70 0.18 145);
    --warning: oklch(0.78 0.15 85);
    --error: oklch(0.65 0.20 25);

    /* Orbit colors */
    --orbit-past: var(--accent);
    --orbit-future: var(--warning);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, monospace;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    /* Radii */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
    --shadow-md: 0 4px 8px oklch(0 0 0 / 0.25);
    --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.3);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Layout */
    --header-height: 56px;
    --panel-width: 320px;
}

/* Light Theme */
html[data-theme="light"] {
    --bg-primary: oklch(0.98 0.005 265);
    --bg-secondary: oklch(0.95 0.005 265);
    --bg-tertiary: oklch(0.92 0.005 265);
    --bg-elevated: oklch(1 0 0);

    --text-primary: oklch(0.15 0.02 265);
    --text-secondary: oklch(0.40 0.02 265);
    --text-tertiary: oklch(0.60 0.02 265);

    --accent: oklch(0.50 0.18 175);
    --accent-dim: oklch(0.40 0.15 175);
    --accent-glow: oklch(0.60 0.15 175);

    --border: oklch(0.88 0.005 265);
    --border-subtle: oklch(0.92 0.005 265);

    --orbit-past: oklch(0.45 0.18 175);
    --orbit-future: oklch(0.55 0.18 55);

    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.05);
    --shadow-md: 0 4px 8px oklch(0 0 0 / 0.08);
    --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.12);
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════════ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════════ */

.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    z-index: 1000;
    transition: opacity var(--duration-slow) var(--ease-out);
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 48px;
    height: 48px;
}

.loader-icon {
    width: 100%;
    height: 100%;
    color: var(--accent);
    animation: spin 1.5s linear infinite;
}

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

.loading-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════════
   APP CONTAINER
   ═══════════════════════════════════════════════════════════════ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out);
}

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

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border-radius: var(--radius-md);
    color: var(--bg-primary);
}

.logo-icon .icon {
    width: 18px;
    height: 18px;
}

.logo-text {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Navigation */
.nav-controls {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.nav-btn.icon-only {
    padding: var(--space-2);
}

.nav-btn .icon {
    width: 16px;
    height: 16px;
}

.nav-label {
    display: none;
}

@media (min-width: 768px) {
    .nav-label {
        display: inline;
    }
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */

.content {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* Visualization Section */
.viz-section {
    flex: 1.2;
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.map-container,
.globe-container {
    flex: 1;
    position: relative;
}

.globe-container {
    display: none;
}

.globe-container.active {
    display: block;
}

.map-container.hidden {
    display: none;
}

#map,
#globe-container {
    width: 100%;
    height: 100%;
}

/* Telemetry Bar */
.telemetry-bar {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.telemetry-group {
    display: flex;
    gap: var(--space-5);
}

.telemetry-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.telemetry-label {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.telemetry-value {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.telemetry-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.telemetry-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.telemetry-status .status-icon {
    width: 14px;
    height: 14px;
    color: var(--warning);
}

.telemetry-status.night .status-icon {
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   STREAM SECTION
   ═══════════════════════════════════════════════════════════════ */

.stream-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-subtle);
}

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

.stream-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.stream-badge {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

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

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stream Controls */
.stream-controls {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.stream-controls select {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: border-color var(--duration-fast);
}

.stream-controls select:hover,
.stream-controls select:focus {
    border-color: var(--accent);
    outline: none;
}

.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast);
}

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

.help-btn .icon {
    width: 16px;
    height: 16px;
}

/* Stream Fallback */
.stream-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.stream-fallback.visible {
    display: flex;
}

.fallback-content {
    text-align: center;
    max-width: 280px;
}

.fallback-icon {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: var(--space-4);
}

.fallback-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.fallback-content p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.fallback-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.fallback-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--duration-fast);
}

.fallback-link:hover {
    border-color: var(--accent);
}

.fallback-link.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.fallback-link.primary:hover {
    background: var(--accent-glow);
}

.fallback-link .icon {
    width: 14px;
    height: 14px;
}

.fallback-tip {
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.fallback-tip code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   SIDE PANEL
   ═══════════════════════════════════════════════════════════════ */

.side-panel {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--panel-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast);
}

.panel-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.panel-close .icon {
    width: 16px;
    height: 16px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.panel-section {
    margin-bottom: var(--space-6);
}

.panel-section h3 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: var(--space-3);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

/* Crew List */
.crew-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.crew-placeholder {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.crew-member {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.crew-avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crew-avatar .icon {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.crew-info {
    flex: 1;
    min-width: 0;
}

.crew-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crew-agency {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

/* Location Form */
.location-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.input-group {
    display: flex;
    gap: var(--space-2);
}

.input-group input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
}

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

.input-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-primary);
    cursor: pointer;
    transition: background var(--duration-fast);
}

.input-btn:hover {
    background: var(--accent-glow);
}

.input-btn .icon {
    width: 16px;
    height: 16px;
}

.location-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--duration-fast);
}

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

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

.location-status {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Pass List */
.pass-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pass-item {
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.pass-time {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.pass-details {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

.pass-quality {
    display: inline-block;
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.pass-quality.excellent { color: var(--success); }
.pass-quality.good { color: var(--accent); }
.pass-quality.fair { color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: var(--space-4);
}

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

.modal {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-close .icon {
    width: 16px;
    height: 16px;
}

.modal-text {
    padding: var(--space-4);
    padding-bottom: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-body {
    padding: var(--space-4);
}

.modal-body p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.modal-body ul {
    list-style: none;
    margin-bottom: var(--space-3);
}

.modal-body li {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-body li:last-child {
    border-bottom: none;
}

.modal-body strong {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.modal-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--duration-fast);
}

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

.modal-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.modal-btn.primary:hover {
    background: var(--accent-glow);
}

.modal-btn .icon {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   ISS MARKER (Leaflet)
   ═══════════════════════════════════════════════════════════════ */

.iss-icon {
    background: transparent !important;
    border: none !important;
}

.iss-marker-container {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iss-marker-pulse {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.3;
    animation: marker-pulse 2s ease-out infinite;
}

@keyframes marker-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0.4;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.iss-marker-dot {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .content {
        flex-direction: column;
    }

    .viz-section {
        flex: 1;
    }

    .stream-section {
        flex: 0.8;
        border-left: none;
        border-top: 1px solid var(--border-subtle);
    }

    .telemetry-bar {
        left: var(--space-3);
        right: var(--space-3);
        transform: none;
        gap: var(--space-3);
        padding: var(--space-2) var(--space-3);
    }

    .telemetry-group {
        gap: var(--space-3);
    }
}

/* ═══════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════ */

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.hidden {
    display: none !important;
}

/* Leaflet overrides */
.leaflet-control-attribution {
    font-size: 10px;
    background: var(--bg-secondary) !important;
    color: var(--text-tertiary) !important;
}

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

.leaflet-control-zoom {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-tertiary) !important;
}
