:root {
    --bg-color: #0c0c0c;
    --bg-secondary: #141414;
    --bg-elevated: #1a1a1a;
    --text-color: #ffffff;
    --text-muted: #888888;
    --accent-color: #bb86fc;
    /* Restored vibrant purple */
    --accent-secondary: #03dac6;
    /* Restored vibrant teal */
    --border-color: #222222;
    --font-primary: 'Inter', 'Roboto Mono', monospace;
    --radius: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
}

/* HEADER */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.logo-area h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.logo-area h1 span {
    color: var(--accent-color);
}

.logo-area p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-stats {
    display: flex;
    gap: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* MAIN LAYOUT */
main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

.sidebar h3 {
    padding: 16px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.filter-group {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.filter-group label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 14px;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: var(--border-color);
    border-color: var(--accent-color);
}

.filter-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #000;
}

.flight-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* FLIGHT CARD */
.flight-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flight-card:hover {
    background: var(--border-color);
    transform: translateX(4px);
}

.flight-card.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}

.flight-card.active .flight-meta {
    color: rgba(0, 0, 0, 0.7);
}

.flight-card h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flight-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.flight-card {
    position: relative;
}

.delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}

.delete-btn:hover {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
}

.delete-btn svg {
    opacity: 0.7;
}

.delete-btn:hover svg {
    opacity: 1;
}

.admin-mode .delete-btn {
    display: flex;
}

/* SCROLLBARS */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* DETAILS PANEL */
.details-panel {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: var(--bg-color);
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
}

.empty-state h2 {
    font-weight: 500;
    margin-bottom: 8px;
}

.detail-header {
    margin-bottom: 30px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.detail-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.badge {
    background: var(--accent-color);
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: 10px;
}

/* GRID STATS */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-card .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

/* MEDIA */
.media-section {
    margin-bottom: 30px;
}

.media-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.media-section h3::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.media-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s ease;
}

.media-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.media-item img,
.media-item video {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.media-item p {
    padding: 12px 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.zoomable {
    cursor: zoom-in;
}

.zoomable:hover {
    opacity: 0.9;
}

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
    box-shadow: 0 0 40px rgba(187, 134, 252, 0.2);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 2.5rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.close-btn:hover {
    opacity: 1;
    color: var(--accent-color);
}

/* Manage Data Button - Sidebar Footer Style */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    /* Pushes to bottom if parent is flex-col */
}

.manage-btn {
    width: 100%;
    background: transparent;
    border: 1px dotted rgba(255, 255, 255, 0.3);
    color: #888;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.manage-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-color: #666;
}

.manage-btn .icon {
    font-size: 1.1em;
    filter: grayscale(100%);
}

/* Admin Modal Styles - Nothing OS Style */
.admin-modal {
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.admin-modal.show {
    display: flex !important;
}

.modal-card {
    background: #000;
    border: 1px solid #333;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    border-radius: 0;
    /* Boxy look */
    outline: 1px solid #222;
    /* Double border effect */
    outline-offset: -5px;
}

.modal-header {
    border-bottom: 2px dashed #333;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.modal-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.8em;
    font-family: 'Roboto Mono', monospace;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: -1px;
}

.modal-header p {
    color: #666;
    margin: 0;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8em;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.action-card {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 0;
    padding: 30px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    border-color: #fff;
    background: #111;
}

.action-icon {
    font-size: 2em;
    margin-bottom: 20px;
    opacity: 0.8;
}

.action-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.action-card p {
    color: #888;
    font-size: 0.85em;
    line-height: 1.5;
    margin: 0 0 20px 0;
    flex-grow: 1;
}

.action-btn {
    background: transparent;
    color: #fff;
    border: 1px solid #fff;
    padding: 10px 24px;
    border-radius: 30px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8em;
    text-transform: uppercase;
    font-weight: bold;
    cursor: pointer;
    margin-top: auto;
    transition: all 0.2s;
    align-self: flex-start;
}

.action-card:hover .action-btn {
    background: #fff;
    color: #000;
}

.highlight {
    background: #000;
    border: 1px dashed #444;
    cursor: default;
}

.highlight:hover {
    border-color: #666;
    background: #000;
}

.code-block {
    background: #111;
    padding: 12px 16px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    color: #0f0;
    border: 1px solid #333;
    margin: 15px 0;
    font-size: 0.9em;
    user-select: all;
    width: 100%;
    box-sizing: border-box;
}

.small-text {
    font-size: 0.7em !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #555 !important;
}

/* Hidden Flights List */
.hidden-list {
    margin-top: 20px;
    border: 1px solid #222;
    max-height: 200px;
    overflow-y: auto;
}

.hidden-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #222;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
}

.hidden-item:last-child {
    border-bottom: none;
}

.restore-btn {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 4px 10px;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
}

.restore-btn:hover {
    background: #fff;
    color: #000;
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
        /* Enable body scroll */
        overflow-x: hidden;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        /* Let body handle scrolling */
    }

    /* Stack Header */
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .header-stats {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    /* Stack Main Layout */
    main {
        flex-direction: column;
        overflow: visible;
        /* Let page scroll */
    }

    /* Sidebar adjustments */
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 400px;
        /* Limit height so it doesn't dominate */
    }

    .flight-list {
        max-height: 250px;
        /* Scrollable list inside stacked sidebar */
    }

    .sidebar-footer {
        padding: 10px;
    }

    /* Detail View adjustments */
    .details-panel {
        padding: 15px;
        overflow: visible;
    }

    .detail-header {
        padding: 15px;
    }

    .detail-header h2 {
        font-size: 1.2rem;
    }

    /* Stats Grid to 2 columns on mobile */
    .grid-stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Media Grid */
    .media-grid {
        grid-template-columns: 1fr;
        /* 1 column for media */
    }

    .media-item img,
    .media-item video {
        height: 200px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }

    .manage-btn {
        margin-right: 0;
    }

    .manage-btn span {
        display: inline;
        /* Show icon again since we have space in footer */
    }
}

/* Login Overlay */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-card {
    background-color: var(--card-bg);
    padding: 3rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    width: 90%;
}

.login-card h1 {
    margin-bottom: 1rem;
    font-size: 2rem;
}

.login-card h1 span {
    font-weight: 300;
    color: var(--accent-color);
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: white;
    color: #333;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 2rem;
    width: 100%;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: #f1f1f1;
}

.login-btn img {
    width: 20px;
    height: 20px;
}

.error-text {
    color: #ff6b6b;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2em;
}

/* Visibility classes */
.app-container {
    transition: opacity 0.3s ease;
}

.app-container.hidden {
    display: none;
}

.login-container.hidden {
    display: none;
}

/* Logout Button */
.logout-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    margin-bottom: 1rem;
    width: 100%;
    text-align: left;
}


.logout-btn:hover {
    border-color: var(--text-color);
    color: var(--text-color);
}

/* --- Plotting & Analysis UI --- */
.tab-viewport {
    position: relative;
    min-height: 600px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.tab-pane {
    display: none;
    padding: 2rem;
}

.tab-pane.active {
    display: block;
}

.analysis-controls {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-group label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

#msg-type-select {
    background: #000;
    color: #fff;
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    outline: none;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    transition: all 0.2s;
}

.checkbox-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #444;
}

.checkbox-item input {
    accent-color: #fff;
}

#plot-area {
    width: 100%;
    height: 450px;
    background: rgba(0, 0, 0, 0.2);
}

.analysis-placeholder {
    text-align: center;
    padding: 5rem;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
}

/* Tabs Refinement */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: #fff;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* SUMMARY INFO */
.summary-info {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
}

.muted {
    color: var(--text-muted);
}

.unit {
    font-size: 0.7em;
    color: var(--text-muted);
    margin-left: 2px;
}