/* ============================================================
   Flykort Map Page — Full-screen layout
   ============================================================ */

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

:root {
    --bg:       #070b13;
    --bg2:      #0d1424;
    --bg-panel: #0c1322;
    --accent:   #3b82f6;
    --accent2:  #22d3ee;
    --text:     #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim:   #64748b;
    --border:   rgba(59, 130, 246, 0.15);
    --nav-h:    48px;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }

/* ---- Nav bar --------------------------------------------- */

.map-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: rgba(7, 11, 19, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.map-nav__back {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: color 0.18s;
    white-space: nowrap;
}
.map-nav__back:hover { color: var(--text); }

.map-nav__logo {
    font-size: 1rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.map-nav__airport {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: nowrap;
}

/* ---- Shell ----------------------------------------------- */

.map-shell {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0; bottom: 0;
}

/* ---- Sidebar --------------------------------------------- */

.map-sidebar {
    width: 270px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.map-controls {
    position: absolute;
    top: 1rem;
    left: calc(1rem + 40px);
    z-index: 450;
    width: 300px;
    max-height: calc(100% - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(12, 19, 34, 0.94);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

.map-sidebar__header {
    position: relative;
    padding: 1.1rem 1.1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.map-sidebar__icao {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.06em;
    margin: 0;
    padding: 0;
}

.map-controls__toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
}

.map-controls__toggle:hover {
    color: var(--text);
    border-color: rgba(59, 130, 246, 0.35);
}

.map-controls.is-collapsed {
    width: auto;
    min-width: 120px;
    max-height: none;
    overflow: visible;
}

.map-controls.is-collapsed .map-sidebar__header {
    padding: 0.75rem 3rem 0.75rem 0.9rem;
    border-bottom: 0;
}

.map-controls.is-collapsed .map-sidebar__icao {
    font-size: 1.25rem;
}

.map-controls.is-collapsed .map-sidebar__name,
.map-controls.is-collapsed .map-sidebar__section,
.map-controls.is-collapsed .map-flight-info,
.map-controls.is-collapsed .map-sidebar__spacer {
    display: none;
}

.map-controls.is-collapsed .map-controls__toggle {
    top: 0.65rem;
    right: 0.65rem;
}

.map-sidebar__name {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    line-height: 1.35;
}

.map-sidebar__section {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

.map-sidebar__label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
}

/* Selects */
.map-select {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.82rem;
    padding: 0.5rem 0.7rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 0.5rem;
}

.map-select:focus { border-color: var(--accent); }
.map-select option { background: #0d1424; }

/* Checkbox */
.map-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
}

.map-check input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Departures table */
.map-departures {
    position: absolute;
    top: var(--departures-top, 5rem);
    left: calc(1rem + 40px);
    right: auto;
    bottom: auto;
    z-index: 450;
    width: 440px;
    max-width: calc(100% - 2rem);
    padding: 0.85rem 1rem 1rem;
    background: rgba(12, 19, 34, 0.94);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

.map-departures__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.7rem;
}

.map-departures__airport {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.map-departures__actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.map-departures__count {
    min-width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent2);
    background: rgba(34, 211, 238, 0.08);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.72rem;
    font-weight: 700;
}

.map-departures__toggle {
    width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
}

.map-departures__toggle:hover {
    color: var(--text);
    border-color: rgba(59, 130, 246, 0.35);
}

.map-departures__list {
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.map-departures__flight {
    display: grid;
    grid-template-columns: 5.4rem 7.8rem minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
}

.map-departures__flight:last-child {
    border-bottom: 0;
}

.map-departures__primary {
    display: block;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 800;
}

.map-departures__secondary {
    display: block;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-departures__pilot {
    align-self: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-departures__mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.map-departures__empty {
    color: var(--text-dim);
    text-align: center;
}

.map-departures.is-minimized {
    width: min(320px, calc(100% - 2rem));
    padding-bottom: 0.85rem;
}

.map-departures.is-minimized .map-departures__header {
    margin-bottom: 0;
}

.map-departures.is-minimized .map-departures__list {
    display: none;
}

/* Flight info panel */
.map-flight-info {
    display: none;
    padding: 1.1rem;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.map-flight-info.visible { display: flex; }

.map-flight-callsign {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.map-flight-row {
    display: flex;
    gap: 0.4rem;
    font-size: 0.8rem;
    line-height: 1.45;
}

.map-flight-row strong {
    color: var(--text-dim);
    font-weight: 600;
    min-width: 62px;
    flex-shrink: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 0.1rem;
}

.map-flight-row span { color: var(--text-muted); }

.map-flight-route {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
    word-break: break-all;
    line-height: 1.5;
}

.map-flight-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    align-self: flex-end;
    margin-bottom: -0.25rem;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.map-flight-close:hover { color: var(--text); }

/* Spacer to push things to bottom */
.map-sidebar__spacer { flex: 1; }

/* ---- Map container --------------------------------------- */

.map-main {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

#leaflet-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.leaflet-tile {
    filter: brightness(0.88) contrast(1.15) saturate(0.75);
}

/* ---- Airplane icons (unchanged from original) ------------ */

.airplane-leaflet {
    background-color: transparent;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.airplane-bg {
    background-color: transparent;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: flex;
    opacity: 0.5;
    justify-content: center;
    align-items: center;
}

.airplane-icon-wrapper {
    text-align: center;
    color: white;
    font-size: 11px;
    pointer-events: none;
    user-select: none;
}

.airplane-wrapper {
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.airplane-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.airplane-label {
    margin-top: 2px;
    color: white;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
}

.airplane-label .route {
    font-size: 10px;
    opacity: 0.8;
}

.airplane-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.airplane-plate {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 6px;
    margin-top: 64px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 1;
}

@media (max-width: 760px) {
    .map-controls {
        width: calc(100% - 3.5rem);
        max-height: 42%;
        top: 0.5rem;
        left: calc(0.5rem + 40px);
    }

    .map-departures {
        left: calc(0.5rem + 40px);
        right: auto;
        top: var(--departures-top, 4.5rem);
        bottom: auto;
        width: auto;
        max-width: calc(100% - 3.5rem);
        padding: 0.75rem;
    }

    .map-departures.is-minimized {
        width: calc(100% - 1rem);
    }

    .map-departures__flight {
        grid-template-columns: 4.9rem 6.8rem minmax(0, 1fr);
        gap: 0.5rem;
    }
}
