/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f2f5;
    color: #222;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
header {
    background: #1a2744;
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== HAMBURGER ===== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 4px;
    background: none;
    border: none;
    color: white;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    transition: all 0.3s;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    flex: 1;
    align-items: flex-start;
}

/* ===== SIDEBAR ===== */
nav.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #dde;
    padding: 16px 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}

nav.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav.sidebar ul li a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #444;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

nav.sidebar ul li a:hover {
    background: #f0f4ff;
    color: #1a2744;
    border-left-color: #3d7ef5;
}

nav.sidebar ul li a.active {
    background: #eef2ff;
    color: #1a2744;
    font-weight: 600;
    border-left-color: #3d7ef5;
}

/* ===== MOBILE OVERLAY ===== */
.overlay {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(0,0,0,0.4);
    z-index: 98;
}

.overlay.open { display: block; }

/* ===== TIME FILTER ===== */
.time-filter {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #dde;
    flex-wrap: wrap;
    align-items: center;
}

.time-filter span {
    font-size: 0.8rem;
    color: #666;
    margin-right: 4px;
}

.time-filter button {
    padding: 4px 12px;
    border: 1px solid #ccd;
    background: #fff;
    border-radius: 14px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #444;
    transition: all 0.15s;
}

.time-filter button:hover {
    background: #f0f4ff;
    border-color: #3d7ef5;
    color: #3d7ef5;
}

.time-filter button.active {
    background: #3d7ef5;
    border-color: #3d7ef5;
    color: #fff;
    font-weight: 600;
}

/* ===== CONTENT AREA ===== */
.content-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    padding: 20px;
    transition: opacity 0.15s;
}

/* ===== LOADING SPINNER ===== */
#page-loader {
    display: none;
    padding: 40px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

#page-loader::after {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #dde;
    border-top-color: #3d7ef5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

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

/* ===== STAT CARDS ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-top: 3px solid #3d7ef5;
}

.stat-card.military { border-top-color: #e05a2b; }
.stat-card.airports { border-top-color: #2b9e50; }
.stat-card.countries { border-top-color: #9b5de5; }
.stat-card.routes    { border-top-color: #f5a623; }

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: #1a2744;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-card .label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== SECTION HEADINGS ===== */
.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a2744;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid #eee;
}

/* ===== TABLES ===== */
.table-wrap {
    overflow-x: auto;
    width: 100%;
    margin-bottom: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.88rem;
}

th {
    background: #1a2744;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9ff; }

/* ===== SORT ARROWS ===== */
.arrow-container { display: inline-block; }
.arrow { display: inline-block; padding: 0 3px; font-size: 0.9em; }
.arrow-link { text-decoration: none; color: #7a8aaa; }
.arrow-link.active { color: #7eb3ff; }

/* ===== CHARTS ===== */
.chart-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.highcharts-figure,
.highcharts-data-table table {
    min-width: 310px;
    max-width: 100%;
    margin: 0;
}

#container { height: 320px; }

/* ===== MAPS ===== */
.map-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.map-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    color: #1a2744;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-card iframe {
    width: 100%;
    height: 60vh;
    min-height: 300px;
    border: none;
    border-radius: 4px;
    display: block;
}

/* ===== AIRCRAFT PHOTOS ===== */
td img {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 3px;
    background: #eee;
    display: block;
}

/* ===== SEARCH FORM ===== */
.search-form {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.search-form label {
    font-size: 0.8rem;
    color: #666;
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.search-form input {
    padding: 8px 12px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 180px;
}

.search-form button {
    padding: 8px 20px;
    background: #3d7ef5;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.search-form button:hover { background: #2d6ee0; }

/* ===== TODAY SNAPSHOT BAR ===== */
.snapshot-bar {
    background: #1a2744;
    color: #c8d8f8;
    border-radius: 8px;
    padding: 10px 18px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
}

.snap-label {
    font-weight: 700;
    color: #7eb3ff;
    white-space: nowrap;
}

.snap-sep { color: #445; }

.snap-item strong { color: #ffffff; }

/* ===== CLICKABLE TABLE ROWS ===== */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: #eef3fb !important; }

/* ===== ROUTE DETAIL TWO-COL GRID ===== */
@media (max-width: 700px) {
    .route-two-col { grid-template-columns: 1fr !important; }
}

/* ===== LIVE OVERHEAD PANEL ===== */
.live-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 16px;
}

.live-header {
    background: #1a2744;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: livepulse 2s ease-in-out infinite;
}

.live-dot.offline { background: #ef4444; animation: none; }

@keyframes livepulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { opacity: 0.85; box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

.live-title {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.live-count {
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 600;
}

.live-count.offline { background: rgba(239,68,68,0.25); }

.live-updated {
    margin-left: auto;
    font-size: 0.75rem;
    color: #8899bb;
}

.live-body { padding: 0; }

.live-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.live-loading {
    padding: 20px;
    text-align: center;
    color: #aaa;
    font-size: 0.9rem;
}

.live-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.live-table thead th {
    background: #f5f7fa;
    color: #555;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e9f0;
}

.live-table tbody tr {
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.1s;
}

.live-table tbody tr:last-child { border-bottom: none; }
.live-table tbody tr:hover { background: #f7f9fc; }

.live-table td {
    padding: 8px 12px;
    vertical-align: middle;
}

.live-callsign {
    font-weight: 700;
    color: #1a2744;
    white-space: nowrap;
}

.live-type {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    background: #e8eef8;
    color: #4466aa;
    border-radius: 3px;
    padding: 1px 5px;
    vertical-align: middle;
}

.track-arrow { color: #1a6eb5; font-size: 0.9em; }

.vs-up  { color: #16a34a; font-weight: 700; }
.vs-dn  { color: #dc2626; font-weight: 700; }
.vs-lvl { color: #888; }

/* ===== PEAK CHARTS ROW ===== */
.peak-charts {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.chart-card.half {
    flex: 1 1 320px;
    min-width: 0;
}

.chart-card h3 {
    margin: 0 0 8px 0;
    font-size: 0.82rem;
    color: #1a2744;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ===== RECORDS ===== */
.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.record-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-left: 4px solid #3d7ef5;
}

.record-card.speed   { border-left-color: #e05a2b; }
.record-card.alt     { border-left-color: #9b5de5; }
.record-card.dist    { border-left-color: #2b9e50; }
.record-card.popular { border-left-color: #f5a623; }
.record-card.seen    { border-left-color: #1a2744; }
.record-card.first   { border-left-color: #0097a7; }

.record-card .rec-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 6px;
}

.record-card .rec-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a2744;
    line-height: 1.1;
}

.record-card .rec-sub {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

/* ===== INFINITE SCROLL LOADER ===== */
#loading {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 0.9rem;
}

/* ===== FOOTER ===== */
footer {
    background: #1a2744;
    color: #8899bb;
    text-align: center;
    padding: 16px;
    font-size: 0.82rem;
    margin-top: auto;
}

footer a { color: #8899bb; text-decoration: none; }
footer a:hover { color: #aabbdd; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .hamburger { display: flex; }

    nav.sidebar {
        position: fixed;
        left: -220px;
        top: 56px;
        height: calc(100vh - 56px);
        z-index: 99;
        transition: left 0.3s;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15);
        width: 200px;
    }

    nav.sidebar.open { left: 0; }

    .content { padding: 12px; }

    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 10px; }
    .stat-card .value { font-size: 1.5rem; }

    .time-filter { padding: 8px 12px; }

    table { font-size: 0.82rem; }
    td, th { padding: 6px 8px; }

    td img { width: 60px; height: 38px; }

    .map-card iframe { height: 45vh; }

    .search-form input { width: 140px; }
}

@media (max-width: 480px) {
    header h1 { font-size: 1rem; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
