/* ===== Runway Gap Monitor — DRONESHOT.TW ===== */

:root {
    --bg-dark: #0f1724;
    --bg-dark-2: #373A46;
    --primary: #FEEEA5;
    --primary-dark: #F6A170;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-hover: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --good: #2ecc71;
    --caution: #f0b90b;
    --bad: #e74c3c;
    --radius: 16px;
    --blur: blur(16px);
    --header-h: 54px;
}

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

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(160deg, #2a2d38 0%, #373A46 40%, #2f323d 100%);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ===== Header ===== */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: rgba(55, 58, 70, 0.88);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center;
    padding: 0 16px; z-index: 100; gap: 12px;
}
.header-logo img { height: 30px; display: block; }
.header-title { font-size: 15px; font-weight: 700; flex: 1; }
.header-btn {
    background: rgba(255,255,255,0.08); border: none; color: var(--text-primary);
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px; transition: background .2s;
}
.header-btn:hover { background: rgba(255,255,255,0.18); }
.header-log-btn {
    background: linear-gradient(135deg, #FEEEA5, #F6A170);
    color: #1a2332; border: none; appearance: none; -webkit-appearance: none;
    cursor: pointer; font-family: inherit;
    border-radius: 8px; padding: 6px 12px;
    font-size: 0.8em; font-weight: 700;
    text-decoration: none; white-space: nowrap;
    flex-shrink: 0; line-height: 1;
}
.header-log-btn:hover { opacity: 0.88; }

/* ===== Airport Selection ===== */
.airport-select {
    margin-top: var(--header-h);
    padding: 32px 16px;
    max-width: 640px;
    margin-left: auto; margin-right: auto;
}
.select-intro { text-align: center; margin-bottom: 24px; }
.select-intro h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.select-intro p { color: var(--text-secondary); font-size: 14px; }

.airport-group-label {
    font-size: 11px; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 1px;
    margin: 16px 0 8px; padding-left: 2px;
}
.airport-group-label:first-of-type { margin-top: 0; }
.airport-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.airport-btn {
    background: var(--glass-bg);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center; cursor: pointer;
    color: var(--text-primary); font-family: inherit;
    transition: all .25s;
    min-height: 134px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.airport-btn:hover {
    background: var(--glass-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}
.airport-code {
    font-size: 20px; font-weight: 900; letter-spacing: 1px;
    color: var(--primary);
}
.airport-name {
    font-size: 13px; color: var(--text-secondary); margin-top: 4px;
}
.airport-tag {
    margin-top: 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(0,0,0,.26);
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ===== Dashboard ===== */
.dashboard {
    margin-top: var(--header-h);
    padding: 0 12px 24px;
    max-width: 640px;
    margin-left: auto; margin-right: auto;
}

/* Airport Info Bar */
.airport-info {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 4px;
}
.airport-info-left { display: flex; align-items: center; gap: 8px; }
.info-code { font-size: 16px; font-weight: 900; color: var(--primary); }
.info-name { font-size: 13px; color: var(--text-secondary); }
.info-update { font-size: 11px; color: var(--text-muted); }

/* ===== Timeline ===== */
.timeline { max-height: 500px; overflow-y: auto; }

.tl-event {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.tl-event:last-child { border-bottom: none; }
.tl-past { opacity: 0.45; }
.tl-confirmed .tl-time { color: var(--good); }

.tl-icon { font-size: 16px; flex-shrink: 0; }
.tl-arr .tl-icon { color: var(--bad); }
.tl-dep .tl-icon { color: var(--primary); }

.tl-info { flex: 1; min-width: 0; }
.tl-flight { font-size: 13px; font-weight: 700; }
.tl-airline { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.tl-label {
    font-size: 10px; font-weight: 400; color: var(--text-muted);
    margin: 0 2px;
}
.tl-route {
    font-size: 11px; font-weight: 400; color: var(--text-muted);
    margin: 0 2px;
}
.tl-unsched {
    font-size: 9px; font-weight: 700; color: var(--caution);
    background: rgba(240,185,11,.12); padding: 1px 6px; border-radius: 3px;
    margin-left: 4px;
}

.tl-time { font-size: 14px; font-weight: 700; font-family: monospace; text-align: right; flex-shrink: 0; }
.tl-note { font-size: 9px; color: var(--text-muted); font-family: inherit; }
.tl-time-dynamic > div:first-child { color: var(--caution); }
.tl-time-dynamic .tl-note { color: var(--caution); }
.tl-time-dynamic .tl-note-secondary { color: var(--text-secondary); }
.tl-note-secondary { color: var(--text-secondary); }

/* Gap bars between events */
.tl-gap {
    padding: 4px 14px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.04);
    font-size: 12px; font-weight: 900;
    font-variant-numeric: tabular-nums;
}
.tl-gap span {
    padding: 2px 12px; border-radius: 4px;
}
.gap-long span { background: rgba(46,204,113,.15); color: var(--good); }
.gap-med span { background: rgba(240,185,11,.12); color: var(--caution); }
.gap-short span { background: rgba(231,76,60,.12); color: var(--bad); }
.tl-closure span {
    border: 1px solid rgba(46,204,113,.28);
    box-shadow: 0 0 18px rgba(46,204,113,.08);
}

/* ===== Next Gap ===== */
.next-gap {
    padding: 14px;
}
.next-gap-flights {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; color: var(--text-secondary);
}
.next-gap-side { text-align: center; flex: 1; }
.next-gap-side .ng-time {
    font-size: 20px; font-weight: 900; color: var(--text-primary);
    font-family: monospace; font-variant-numeric: tabular-nums;
}
.next-gap-side .ng-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.next-gap-arrow { font-size: 16px; color: var(--text-muted); padding: 0 8px; flex-shrink: 0; }
.next-gap-mins {
    text-align: center; margin-top: 10px;
    font-size: 22px; font-weight: 900;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.next-gap-mins span {
    background: rgba(255,255,255,.08); padding: 4px 18px; border-radius: 8px;
}
.next-gap-mins.good {
    color: var(--good);
}
.next-gap-mins.good span {
    background: rgba(46,204,113,.12);
}
.next-gap-mins.caution {
    color: var(--caution);
}
.next-gap-mins.caution span {
    background: rgba(240,185,11,.12);
}
.next-gap-mins.waiting {
    font-size: 15px; color: var(--text-muted);
}
.next-gap-mins.waiting span {
    background: rgba(255,255,255,.06);
}
.special-op-alert {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px; padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(240,185,11,.28);
    background: rgba(240,185,11,.10);
    color: var(--caution);
    font-size: 13px; font-weight: 800;
}
.special-op-alert i { font-size: 17px; }

/* ===== Section ===== */
.section {
    background: var(--glass-bg);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--glass-border);
}
.section-header h3 {
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 6px;
    color: var(--text-secondary);
}
.section-header h3 i { color: var(--primary); font-size: 16px; }
.btn-now {
    background: rgba(255,255,255,.08); color: var(--text-secondary);
    border: 1px solid var(--glass-border); border-radius: 4px;
    font-size: 11px; padding: 3px 10px; cursor: pointer;
    transition: background .15s;
}
.btn-now:active { background: rgba(255,255,255,.18); }
.tl-now-marker {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 14px; color: var(--primary); font-size: 11px; font-weight: 700;
}
.tl-now-marker::before, .tl-now-marker::after {
    content: ''; flex: 1; height: 1px; background: var(--primary); opacity: .5;
}
.aircraft-count {
    background: var(--primary); color: #1a2332;
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 10px; min-width: 24px; text-align: center;
}
.clear-btn {
    background: rgba(255,255,255,.08); border: none; color: var(--text-muted);
    font-size: 11px; padding: 3px 10px; border-radius: 6px;
    cursor: pointer; font-family: inherit;
}
.clear-btn:hover { color: var(--text-primary); background: rgba(255,255,255,.15); }

/* ===== Aircraft List ===== */
.aircraft-list { max-height: 300px; overflow-y: auto; }
.aircraft-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    transition: background .15s;
}
.aircraft-item:last-child { border-bottom: none; }
.aircraft-item:hover { background: rgba(255,255,255,.03); }

.ac-icon { font-size: 18px; flex-shrink: 0; }
.ac-icon.on-ground { color: var(--caution); }
.ac-icon.airborne { color: var(--good); }
.ac-icon.approaching { color: var(--bad); animation: pulse 1.5s infinite; }
.ac-icon.departing { color: var(--primary); animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ac-info { flex: 1; min-width: 0; }
.ac-callsign { font-size: 14px; font-weight: 700; font-family: monospace; }
.ac-airline { font-size: 11px; font-weight: 400; font-family: inherit; color: var(--text-muted); margin-left: 4px; }
.ac-detail { font-size: 11px; color: var(--text-muted); }

.ac-status {
    font-size: 10px; font-weight: 700; padding: 3px 8px;
    border-radius: 6px; white-space: nowrap; flex-shrink: 0;
}
.ac-status.ground { background: rgba(240,185,11,.15); color: var(--caution); }
.ac-status.cruise { background: rgba(46,204,113,.15); color: var(--good); }
.ac-status.approach { background: rgba(231,76,60,.15); color: var(--bad); }
.ac-status.departure { background: rgba(254,238,165,.15); color: var(--primary); }

/* P1: 爬升/下降箭頭 + 機種標記 */
.vr { font-weight: 700; font-size: 12px; }
.vr.up   { color: var(--good); }
.vr.down { color: var(--primary); }
.vr.lvl  { color: var(--text-muted); }
.ac-kind {
    display: inline-block; font-size: 10px; font-weight: 700;
    padding: 1px 6px; border-radius: 5px; margin-left: 4px;
    background: rgba(255,255,255,.08); color: var(--text-muted);
    white-space: nowrap;
}
.ac-kind.emerg { background: rgba(231,76,60,.18); color: var(--bad); }
.aircraft-item.emerg { background: rgba(231,76,60,.08); }

.empty-state {
    padding: 24px; text-align: center;
    color: var(--text-muted); font-size: 13px;
}

/* ===== Footer ===== */
.app-footer {
    padding: 18px 16px; border-top: 1px solid var(--glass-border); margin-top: 12px;
}
.footer-credits { text-align: center; font-size: 10px; color: var(--text-muted); line-height: 1.9; }
.footer-credits a { color: var(--text-secondary); text-decoration: none; }
.footer-credits a:hover { color: var(--primary); }

/* ===== Responsive ===== */
@media (min-width: 480px) {
    .airport-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 360px) {
    .airport-grid { grid-template-columns: 1fr; }
}
