/* Andah Flight Network — page-specific layout.
   Loaded after css/style.css, which provides the theme variables + chrome. */

/* Wider, full-height shell than the default .page-shell (960px). */
.flight-shell {
    width: min(1500px, 98%);
    margin: 0 auto;
    padding: 16px 0 24px;
}

/* Top bar: title · view toggle · search */
.flight-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.flight-topbar h1 {
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 400;
    margin: 0;
    padding: 0;
    border: 0;
    flex: 1 1 auto;
}

.flight-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Segmented Globe | Map toggle */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.view-toggle button {
    appearance: none;
    border: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.9rem;
    padding: 7px 16px;
    cursor: pointer;
}

.view-toggle button + button {
    border-left: 1px solid var(--border);
}

.view-toggle button[aria-pressed="true"] {
    background: var(--bg-sunken);
    font-weight: 600;
}

.flight-search {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.9rem;
    min-width: 200px;
}

/* Main split: side panel + viewport */
.flight-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    height: calc(100vh - 200px);
    min-height: 480px;
}

.flight-panel {
    overflow-y: auto;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-soft);
    padding: 14px 16px;
}

.flight-viewport {
    position: relative;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-sunken);
    overflow: hidden;
}

/* Each view fills the viewport; hidden ones use [hidden]. */
.flight-view {
    position: absolute;
    inset: 0;
}

.flight-view[hidden] {
    display: none;
}

.flight-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.95rem;
    padding: 24px;
}

@media (max-width: 800px) {
    .flight-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .flight-viewport {
        min-height: 60vh;
    }
}

/* --- Filter bar --------------------------------------------------------- */
.flight-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 12px;
    font-family: var(--sans);
    font-size: 0.85rem;
}

.flight-filter-group {
    display: inline-flex;
    gap: 12px;
}

.flight-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-transform: capitalize;
}

.flight-slider {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.haul-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

/* --- 2D map canvas ----------------------------------------------------- */
.flight-map-frame {
    position: absolute;
    inset: 0;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.flight-map-canvas {
    display: block;
    max-width: 100%;
}

.flight-map-tooltip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: var(--sans);
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* --- Airport legend ---------------------------------------------------- */
.flight-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 6;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px 10px;
    font-family: var(--sans);
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.flight-legend[hidden] {
    display: none;
}

.flight-legend-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.flight-legend-close {
    appearance: none;
    border: 0;
    background: none;
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0.6;
}

.flight-legend-close:hover {
    opacity: 1;
}

.flight-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 5px;
}

.flight-legend-list li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.flight-legend-dot {
    flex: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.45);
}

/* --- Side panel -------------------------------------------------------- */
.flight-back {
    appearance: none;
    border: 0;
    background: none;
    color: var(--link);
    font-family: var(--sans);
    font-size: 0.85rem;
    padding: 0 0 10px;
    cursor: pointer;
}

.flight-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.flight-flag {
    width: 44px;
    height: auto;
    border: 1px solid var(--border-soft);
}

.flight-city {
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 400;
    margin: 0;
    border: 0;
    padding: 0;
}

.flight-sub {
    margin: 2px 0 0;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.85rem;
}

.flight-tag {
    font-family: var(--sans);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-sunken);
    border: 1px solid var(--border-soft);
    border-radius: 3px;
    padding: 1px 5px;
    vertical-align: middle;
}

.flight-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
    margin: 12px 0;
    font-family: var(--sans);
}

.flight-stats div { margin: 0; }
.flight-stats dt { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.flight-stats dd { margin: 1px 0 0; font-size: 0.98rem; }

.flight-list-title {
    font-family: var(--sans);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 16px 0 6px;
    border: 0;
}

.flight-routes {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sans);
    font-size: 0.82rem;
}

.flight-routes th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border-soft);
    padding: 4px 6px;
    cursor: pointer;
    white-space: nowrap;
}

.flight-routes th.sorted-asc::after { content: ' ▲'; font-size: 0.7em; }
.flight-routes th.sorted-desc::after { content: ' ▼'; font-size: 0.7em; }

.flight-routes td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.flight-routes tbody tr { cursor: pointer; }
.flight-routes tbody tr:hover { background: var(--bg-sunken); }
.flight-routes td .haul-dot { margin-right: 5px; }

.muted { color: var(--muted); }

/* --- Network dashboard ------------------------------------------------- */
.flight-haulbar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 4px 0 14px;
    background: var(--bg-sunken);
}
.haul-seg { display: block; height: 100%; }

.flight-planner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.flight-planner label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-family: var(--sans);
    font-size: 0.85rem;
}
.flight-planner-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.flight-planner-row label { flex: 1 1 auto; }
.flight-planner input {
    flex: 1 1 auto;
    max-width: 70%;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
}
.flight-pick {
    flex: 0 0 auto;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
    cursor: pointer;
    line-height: 1;
}
.flight-pick:hover { background: var(--bg-sunken); }
.flight-pick.picking {
    border-color: var(--link);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--link) 35%, transparent);
}
.flight-pick-hint {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--link);
    margin: 6px 0 0;
}
.flight-planner button[data-action="plan"] {
    align-self: flex-start;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
    color: var(--text);
    font-family: var(--sans);
    cursor: pointer;
}
.flight-planner button:hover { background: var(--bg-sunken); }

.flight-legs {
    margin: 8px 0 4px;
    padding-left: 20px;
    font-family: var(--sans);
    font-size: 0.85rem;
}
.flight-leg { cursor: pointer; padding: 2px 0; }
.flight-leg:hover { color: var(--link); }
.flight-total { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); margin: 4px 0; }

.flight-source {
    margin-top: 18px;
    font-family: var(--sans);
    font-size: 0.72rem;
    color: var(--note-text);
}

/* --- Airport tagger ---------------------------------------------------- */
.tagger-shell {
    width: min(1600px, 99%);
    margin: 0 auto;
    padding: 12px 0 24px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 14px;
    font-family: var(--sans);
}

.tagger-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.tagger-toolbar button {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
}
.tagger-counts { font-weight: 600; }
.tagger-hint { color: var(--muted); font-size: 0.78rem; }

.tagger-viewport {
    position: relative;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-sunken);
    overflow: hidden;
    height: calc(100vh - 170px);
    min-height: 480px;
}
.tagger-viewport canvas { display: block; touch-action: none; cursor: crosshair; }

.tagger-panel {
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-soft);
    padding: 12px 14px;
    overflow-y: auto;
    height: calc(100vh - 170px);
}

.tagger-band { font-weight: 600; margin: 0 0 8px; }

.tagger-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
    font-size: 0.82rem;
}
.tagger-field input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
}

.tagger-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.tagger-actions button {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
}
.tagger-actions button#tag-save { background: var(--bg-sunken); font-weight: 600; }
.tagger-danger { color: var(--wrong-text); border-color: var(--wrong-border) !important; }

.tagger-progress { font-size: 0.85rem; margin-bottom: 8px; }
.tagger-prog-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tagger-prog-row span:last-child { margin-left: auto; }

@media (max-width: 900px) {
    .tagger-shell { grid-template-columns: 1fr; }
    .tagger-viewport, .tagger-panel { height: auto; }
    .tagger-viewport { min-height: 60vh; }
}

/* --- Flight cities editor ---------------------------------------------- */
.fce-shell {
    width: min(1600px, 99%);
    margin: 0 auto;
    padding: 12px 0 24px;
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 14px;
    font-family: var(--sans);
}

.fce-side {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-soft);
    height: calc(100vh - 150px);
    min-height: 480px;
    overflow: hidden;
}

.fce-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
}
.fce-toolbar-row { display: flex; align-items: center; gap: 10px; }
.fce-search {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}
.fce-side .tagger-actions { margin: 0; }

.fce-list { flex: 1 1 auto; overflow-y: auto; padding: 6px; }

.fce-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 4px 8px;
    align-items: center;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
}
.fce-row + .fce-row { margin-top: 2px; }
.fce-row:hover { background: var(--bg-sunken); }
.fce-row.sel { border-color: var(--link); background: var(--bg-sunken); }

.fce-idx {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.fce-dot { width: 10px; height: 10px; border-radius: 50%; }

.fce-fields { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fce-fields input {
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}
.fce-row.done .fce-name { font-weight: 600; }
.fce-meta { font-size: 0.72rem; color: var(--muted); }

@media (max-width: 900px) {
    .fce-shell { grid-template-columns: 1fr; }
    .fce-side, .fce-map.tagger-viewport { height: auto; }
    .fce-side { max-height: 60vh; }
    .fce-map.tagger-viewport { min-height: 60vh; }
}
