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

:root {
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --accent-blue: #3182ce;
    --map-height: 120vh;
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);

    /* Card Colors */
    --card-green: #e6fffa;
    --card-green-text: #2c7a7b;
    --card-yellow: #fffff0;
    --card-yellow-text: #b7791f;
    --card-orange: #fffaf0;
    --card-orange-text: #c05621;
    --card-purple: #faf5ff;
    --card-purple-text: #6b46c1;
    --card-teal: #e6fffa;
    --card-teal-text: #285e61;
}

body {
    margin: 0;
    font-family: 'Inter', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* Map Section */
.map-section {
    position: relative;
    height: var(--map-height);
    min-height: 500px;
    width: 100%;
    background: #e6f7ff;
    /* Fallback/Loading color */
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

.map-header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(4px);
}

.map-header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    background: #48bb78;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Stats Strip */
.stats-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    padding: 15px 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    z-index: 10;
    border-bottom: 1px solid #e2e8f0;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 30px;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-divider {
    width: 1px;
    height: 30px;
    background: #e2e8f0;
}

.filter-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 30px;
}

#year-filter {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    cursor: pointer;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 320px;
    /* Fixed height for consistency */
    border: 1px solid #edf2f7;
}

/* Card Coloring based on ID */
#top-routes {
    border-top: 4px solid #48bb78;
}

#top-airlines {
    border-top: 4px solid #ed8936;
}

#top-aircraft {
    border-top: 4px solid #ecc94b;
}

#top-airports {
    border-top: 4px solid #805ad5;
}

#top-registrations {
    border-top: 4px solid #38b2ac;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f7fafc;
}

.card-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.view-more {
    font-size: 0.75rem;
    color: var(--accent-blue);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.view-more:hover {
    text-decoration: underline;
}

.list-content {
    flex: 1;
    overflow-y: auto;
}

/* List Item Styles */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #f7fafc;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.list-item:hover {
    background-color: #f7fafc;
}

.item-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.item-metric {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 4px;
}

.item-bar-bg {
    height: 4px;
    background: #edf2f7;
    border-radius: 2px;
    margin-top: 4px;
    width: 60px;
}

.item-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent-blue);
}

/* Chart Section */
.chart-section {
    padding: 0 20px 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    width: 100%;
}

.full-width {
    width: 100%;
    height: 150px;
    grid-column: 1 / -1;
}

.chart-container {
    width: 100%;
    height: 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        height: auto;
        overflow-y: visible;
    }

    .map-section {
        height: 75vh;
    }

    .stats-strip {
        flex-wrap: wrap;
        gap: 15px;
    }

    .stat-divider {
        display: none;
    }
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-toggle {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.metric-toggle:hover {
    background: #edf2f7;
    color: var(--text-primary);
}

.metric-toggle.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}


/* Flights Table Section */
.flights-table-section {
    padding: 0 20px 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    width: 100%;
}

.flights-table-section .card.full-width {
    height: auto;
    max-height: 500px;
    padding: 0;
    overflow: hidden;
}

.flights-table-section .card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 450px;
}

#flights-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

#flights-table th {
    background: #f7fafc;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

#flights-table td {
    padding: 12px 20px;
    border-bottom: 1px solid #f7fafc;
    color: var(--text-primary);
}

#flights-table tbody tr:hover {
    background-color: #f7fafc;
}

#flights-table tbody tr:last-child td {
    border-bottom: none;
}
