/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* SpaceX Color Palette - Pure Black & White */
    --primary: #000000;
    --secondary: #ffffff;
    --accent: #005288;
    --success: #00ff00;
    --warning: #ffcc00;
    --danger: #ff0000;
    --dark-bg: #000000;
    --card-bg: #000000;
    --border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --shadow: rgba(0, 0, 0, 0.5);
    --hover-bg: rgba(255, 255, 255, 0.05);
}

body {
    font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #000000;
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== ANIMATED BACKGROUND ===== */
.stars, .twinkling {
    display: none; /* SpaceX style - pure black */
}

/* ===== HEADER ===== */
.header {
    background: #000000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo svg {
    stroke: #ffffff;
}

.nav-link {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 0;
    transition: opacity 0.2s;
    position: relative;
}

.nav-link::before {
    display: none;
}

.nav-link:hover,
.nav-link.active {
    opacity: 0.6;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 0;
    background: var(--warning);
}

.status-dot.connected {
    background: #00ff00;
}

/* ===== MISSION BANNER ===== */
.mission-banner {
    padding: 60px 0 40px;
    background: #000000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mission-banner .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mission-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 6px;
    margin-bottom: 12px;
    color: #ffffff;
    text-transform: uppercase;
}

.mission-subtitle {
    font-size: 14px;
    color: #a0a0a0;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 300;
}

.mission-time {
    display: flex;
    gap: 30px;
}

.time-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.time-label {
    font-size: 10px;
    color: #808080;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
    font-weight: 400;
}

.time-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 2px;
}

/* ===== DASHBOARD ===== */
.dashboard {
    padding: 30px 0 60px;
}

/* ===== STATUS PANEL ===== */
.status-panel {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 30px;
    margin-bottom: 30px;
}

.status-panel::before {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    letter-spacing: 3px;
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge {
    padding: 8px 20px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    background: transparent;
    color: #00ff00;
    border: 1px solid #00ff00;
    text-transform: uppercase;
}

.status-badge.warning {
    background: transparent;
    color: #ffcc00;
    border-color: #ffcc00;
}

.status-badge.danger {
    background: transparent;
    color: #ff0000;
    border-color: #ff0000;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.status-card {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all 0.2s;
}

.status-card:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

.status-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    border: none;
}

.status-icon svg {
    color: #ffffff;
    filter: none;
}

.status-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.status-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #ffffff;
}

.status-value.abnormal {
    color: #ff0000;
}

.status-value.warning {
    color: #ffcc00;
}

/* ===== TELEMETRY GRID ===== */
.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.telemetry-card {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 30px;
    box-shadow: none;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.telemetry-card::before {
    display: none;
}

.telemetry-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
    transform: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.card-header::after {
    display: none;
}

.card-header h3 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    letter-spacing: 2.5px;
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
}

.card-badge {
    font-size: 10px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

/* ===== SENSOR READINGS ===== */
.sensor-readings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.reading-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reading-label {
    font-size: 12px;
    color: #808080;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 400;
}

.reading-unit {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.reading-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 36px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: none;
    letter-spacing: 0;
}

.reading-bar {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0;
    overflow: hidden;
    position: relative;
}

.reading-bar::before {
    display: none;
}

.bar-fill {
    height: 100%;
    background: #ffffff;
    transition: width 0.6s ease;
    border-radius: 0;
    box-shadow: none;
    position: relative;
}

.bar-fill.warning {
    background: #ffcc00;
}

.bar-fill.danger {
    background: #ff0000;
}

/* ===== AI CARD ===== */
.ai-card {
    grid-column: span 2;
}

.ai-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-model {
    padding: 15px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.model-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 10px;
}

.model-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}

.result-value.abnormal {
    color: var(--danger);
}

.confidence {
    font-size: 14px;
    color: var(--text-secondary);
}

.windows-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.window-item {
    padding: 12px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.window-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.window-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

/* ===== ALERTS PANEL ===== */
.alerts-panel {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 30px;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.alerts-panel::before {
    display: none;
}

.clear-btn {
    padding: 8px 18px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.alert-item {
    padding: 18px 20px;
    border-left: 2px solid #ffffff;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.3s ease;
    transition: all 0.2s;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.alert-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-left-color: #ffffff;
    transform: none;
}

.alert-item.warning {
    border-left-color: #ffcc00;
}

.alert-item.danger {
    border-left-color: #ff0000;
}

.alert-item.success {
    border-left-color: #00ff00;
}

.alert-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    flex-shrink: 0;
}

.alert-icon svg {
    color: #ffffff;
}

.alert-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-title {
    font-size: 13px;
    font-weight: 400;
    color: #ffffff;
}

.alert-time {
    font-size: 11px;
    color: #808080;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 1px;
}

/* ===== FOOTER ===== */
.footer {
    background: #000000;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px 0;
    text-align: center;
}

.footer p {
    font-size: 11px;
    color: #808080;
    margin: 6px 0;
    letter-spacing: 1px;
}

/* ===== PERFORMANCE STATS SECTION ===== */
.stats-section {
    padding: 60px 0;
    background: #000000;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    letter-spacing: 4px;
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 40px;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.stat-card {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px 20px;
    text-align: center;
    transition: all 0.2s;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-label {
    font-size: 11px;
    color: #808080;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    font-weight: 400;
}

.stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 42px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
    line-height: 1;
}

.stat-value.success {
    color: #00ff00;
}

.stat-value.warning {
    color: #ffcc00;
}

.stat-value.danger {
    color: #ff0000;
}

.stat-change {
    font-size: 10px;
    color: #606060;
    letter-spacing: 1px;
}

/* ===== CHART SECTION ===== */
.chart-section {
    padding: 60px 0;
    background: #000000;
}

.chart-card {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px;
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.chart-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #808080;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.chart-btn:hover,
.chart-btn.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ffffff;
    color: #ffffff;
}

/* Constrain chart height via wrapper so Chart.js respects it */
.chart-canvas {
    position: relative;
    height: 220px; /* Fixed height container for the chart */
    margin: 30px 0;
}

#dataChart {
    width: 100% !important;
    height: 100% !important; /* Fill the wrapper height */
    display: block;
}

canvas {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chart-legend {
    text-align: center;
    font-size: 10px;
    color: #606060;
    letter-spacing: 1px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===== LOG SECTION ===== */
.log-section {
    padding: 60px 0 80px;
    background: #000000;
}

.log-card {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px;
}

.log-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.log-filter {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #808080;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.log-filter:hover,
.log-filter.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ffffff;
    color: #ffffff;
}

.export-btn {
    padding: 8px 20px;
    background: #ffffff;
    border: none;
    color: #000000;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-left: auto;
}

.export-btn:hover {
    background: #cccccc;
}

.log-table-wrapper {
    margin-top: 30px;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    /* Enable hardware acceleration */
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table thead {
    position: sticky;
    top: 0;
    background: #000000;
    z-index: 10;
}

.log-table th {
    padding: 15px 12px;
    text-align: left;
    font-size: 10px;
    font-weight: 600;
    color: #808080;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.log-table td {
    padding: 15px 12px;
    font-size: 12px;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-table tbody tr {
    transition: all 0.2s;
}

.log-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-table .event-badge {
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: inline-block;
}

.log-table .event-badge.normal {
    color: #00ff00;
    border-color: #00ff00;
}

.log-table .event-badge.anomaly {
    color: #ff0000;
    border-color: #ff0000;
}

.log-table .event-badge.alert {
    color: #ffcc00;
    border-color: #ffcc00;
}

.log-table .status-indicator {
    width: 8px;
    height: 8px;
    display: inline-block;
    margin-right: 8px;
}

.log-table .status-indicator.ok {
    background: #00ff00;
}

.log-table .status-indicator.warning {
    background: #ffcc00;
}

.log-table .status-indicator.critical {
    background: #ff0000;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #000000;
}

::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .ai-card {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .mission-banner .container {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .mission-time {
        flex-direction: column;
        gap: 15px;
    }
    
    .time-block {
        align-items: center;
    }
    
    .nav {
        display: none;
    }
    
    .telemetry-grid {
        grid-template-columns: 1fr;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-canvas { height: 180px; } /* Further reduced for mobile */
}

/* Small phones */
@media (max-width: 480px) {
    .container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .header { padding: 12px 0; }
    .mission-banner { padding: 36px 0 24px; }

    .mission-title {
        font-size: 28px;
        letter-spacing: 3px;
    }
    .mission-subtitle { font-size: 12px; letter-spacing: 2px; }
    .time-value { font-size: 22px; }

    .status-panel,
    .telemetry-card,
    .chart-card,
    .log-card,
    .alerts-panel { padding: 16px; }

    .status-card { padding: 16px; gap: 12px; }
    .status-icon { width: 36px; height: 36px; }
    .status-value { font-size: 18px; }
    .status-label { font-size: 11px; }
    .panel-header h2 { font-size: 14px; }

    .card-header { margin-bottom: 16px; padding-bottom: 12px; }
    .card-badge { font-size: 9px; padding: 3px 8px; }

    .sensor-readings { gap: 14px; }
    .reading-value { font-size: 28px; }

    .stats-section { padding: 36px 0; }
    .stat-card { padding: 16px 12px; }
    .stat-label { font-size: 10px; }
    .stat-value { font-size: 28px; }
    .stat-change { font-size: 9px; }

    .chart-controls, .log-controls { gap: 8px; }
    .chart-btn, .log-filter { padding: 6px 12px; font-size: 10px; }
    .export-btn { padding: 6px 12px; font-size: 10px; }

    .alert-item { padding: 12px 14px; }
    .alert-title { font-size: 12px; }
    .alert-time { font-size: 10px; }
}

/* Very small phones */
@media (max-width: 360px) {
    .mission-title { font-size: 24px; }
    .reading-value { font-size: 24px; }
    .stat-value { font-size: 24px; }
    .chart-canvas { height: 160px; }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimize paint and composite layers */
.telemetry-card,
.status-card,
.stat-card {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Optimize chart rendering */
.chart-section {
    contain: layout style paint;
}
