/* Hide the default online sidebar widgets on the traffic page */
html.rr-traffic #online-sidebar-header,
html.rr-traffic #online-sidebar-list {
    display: none !important;
}

/* Make the right sidebar scroll independently */
html.rr-traffic aside.sidebar {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

/* Full-width map shell */
.traffic-shell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 0;
    padding: 0;
}

    .traffic-shell > #traffic-map,
    .traffic-shell > #traffic-error {
        width: 100%;
    }

.traffic-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.traffic-overlay-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 999px;
    padding: 6px 12px;
    background: var(--surface, #fff);
    color: var(--fg, #1f2937);
    cursor: pointer;
}

.traffic-overlay-toggle input[type=checkbox] {
    margin: 0;
}

.traffic-legend {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.traffic-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    background: var(--accent-weak, rgba(31, 41, 55, 0.05));
}

.traffic-legend-chip--adsb {
    border-color: #1d4ed8;
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.12);
}

.traffic-legend-chip--presence {
    border-color: #f97316;
    color: #c2410c;
    background: rgba(249, 115, 22, 0.12);
}

/* Stats bar */
.traffic-stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 12px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e5e5);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted, #6b7280);
}

.traffic-stat {
    padding: 2px 8px;
    white-space: nowrap;
}

.traffic-stat-sep {
    width: 1px;
    height: 14px;
    background: var(--border, #e5e5e5);
    flex-shrink: 0;
}

/* Map container - fill entire viewport width */
#traffic-map {
    width: 100%;
    box-sizing: border-box;
    height: calc(100vh - 140px);
    min-height: 420px;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
}

/* Horizontal filter bar above map */
.traffic-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.traffic-filter-bar input[type=text],
.traffic-filter-bar input[type=number],
.traffic-filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
}

.traffic-filter-bar input[type=text] {
    min-width: 180px;
    flex: 0 1 auto;
}

.traffic-filter-bar input[type=number] {
    width: 90px;
}

.traffic-filter-bar select {
    min-width: 120px;
}

.traffic-filter-bar .filter-reset-btn {
    padding: 6px 12px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    cursor: pointer;
    font-size: 13px;
}

.traffic-filter-bar .filter-reset-btn:hover {
    background: var(--accent-weak, #f6f6f6);
}

.traffic-filter-bar label {
    font-size: 12px;
    color: var(--muted, #666);
}

.traffic-filter-bar input[type="datetime-local"] {
    padding: 5px 8px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    font-size: 12px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
}

.traffic-history-status {
    font-size: 12px;
    color: var(--muted, #666);
}

.traffic-history-status:empty {
    display: none;
}

.leaflet-control.rr-connections-toggle {
    background: var(--surface, rgba(255, 255, 255, 0.92));
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    font-size: 13px;
    color: var(--fg, #1b1b1b);
}

.rr-connections-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-weight: 500;
}

.rr-connections-toggle-label input[type=checkbox] {
    margin: 0;
}

/* Aircraft icon (SVG silhouette, rotated by heading) */
.acft {
    width: 24px;
    height: 24px;
    margin-left: -12px;
    margin-top: -12px;
    pointer-events: auto;
}

    .acft .glyph {
        display: block;
        width: 24px;
        height: 24px;
        transform-origin: 50% 50%;
        color: #3b82f6; /* Default blue */
        filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.9));
        transition: filter 0.3s ease, color 0.3s ease;
    }

    .acft .glyph svg {
        display: block;
        width: 100%;
        height: 100%;
    }

/* Source-based colors */
.acft-adsb .glyph { color: #2563eb; }
.acft-presence .glyph { color: #ea580c; }

/* TCAS alert - orange with glow (overrides source color) */
.acft-tcas .glyph,
.acft-ta .glyph,
.acft-ra .glyph {
    color: #f97316 !important;
    filter: drop-shadow(0 0 4px #f97316) drop-shadow(0 0 8px rgba(249, 115, 22, 0.5));
    animation: tcas-pulse 1.5s ease-in-out infinite;
}

/* ELT/Emergency alert - red with urgent glow (overrides source color) */
.acft-elt .glyph,
.acft-emergency .glyph,
.acft-distress .glyph,
.acft-mayday .glyph {
    color: #ef4444 !important;
    filter: drop-shadow(0 0 6px #ef4444) drop-shadow(0 0 12px rgba(239, 68, 68, 0.6));
    animation: elt-pulse 0.8s ease-in-out infinite;
}

@keyframes tcas-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px #f97316) drop-shadow(0 0 8px rgba(249, 115, 22, 0.5)); }
    50% { filter: drop-shadow(0 0 6px #f97316) drop-shadow(0 0 12px rgba(249, 115, 22, 0.7)); }
}

@keyframes elt-pulse {
    0%, 100% { filter: drop-shadow(0 0 6px #ef4444) drop-shadow(0 0 12px rgba(239, 68, 68, 0.6)); }
    50% { filter: drop-shadow(0 0 10px #ef4444) drop-shadow(0 0 18px rgba(239, 68, 68, 0.8)); }
}

/* Follow control */
.rr-follow-control {
    background: var(--surface, rgba(255, 255, 255, 0.92));
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.rr-follow-control.hidden {
    display: none;
}

.rr-follow-btn {
    display: block;
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg, #1f2937);
    cursor: pointer;
    border-radius: 6px;
}

.rr-follow-btn:hover {
    background: var(--accent-weak, #f0f0f0);
}

.rr-follow-btn.active {
    background: var(--accent-color, #2563eb);
    color: #fff;
}

/* FIR labels */
.fir-label.dim {
    opacity: .75;
    font-size: 11px;
}

/* Navaid icon (DivIcon wrapper) */
.navaid-icon {
    background: transparent !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Navaid ident label */
.navaid-label {
    font-size: 10px;
    font-weight: 600;
    color: hsl(210, 70%, 40%);
    background: rgba(255, 255, 255, 0.85);
    border: none;
    box-shadow: none;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    pointer-events: none;
}

.navaid-label::before {
    display: none;
}

.navaid-hover-tooltip {
    font-size: 12px;
    font-weight: 500;
}

/* Airport labels */
.airport-label {
    font-size: 10px;
    font-weight: 600;
    color: hsl(0, 0%, 35%);
    background: rgba(255, 255, 255, 0.85);
    border: none;
    box-shadow: none;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    pointer-events: none;
}

.airport-label::before {
    display: none;
}

.airport-hover-tooltip {
    font-size: 12px;
    font-weight: 500;
}

/* Sidebar cards + filters */
.ac-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ac-card {
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
    cursor: pointer;
}

    .ac-card:hover {
        background: var(--accent-weak, #fafafa);
    }

.ac-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ac-pilot-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border, #e5e5e5);
    flex-shrink: 0;
}

.ac-pilot-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-weak, #f0f0f0);
    color: var(--fg, #555);
    font-size: 11px;
    font-weight: 600;
}

.ac-meta {
    font-size: 12px;
    opacity: .8;
}

.ac-chip {
    font-size: 12px;
    border: 1px solid var(--accent-color);
    border-radius: 999px;
    padding: 2px 8px;
    line-height: 1;
    align-self: start;
    color: var(--accent-color, #1b7a2a);
    background: var(--surface, #fff);
}

.ac-route {
    grid-column: 1 / -1;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color, #1d4ed8);
    letter-spacing: 0.02em;
}

.ac-quiet {
    opacity: .7;
}

.ac-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
}

.ac-action {
    font-size: 12px;
    border: none;
    background: transparent;
    color: var(--accent-color);
    padding: 0;
    cursor: pointer;
}

.ac-action:hover,
.ac-action:focus {
    text-decoration: underline;
    outline: none;
}

.ac-empty {
    opacity: .7;
    padding: 10px;
    border: 1px dashed var(--border, #e5e5e5);
    border-radius: 8px;
    color: var(--muted, inherit);
}

.ac-muted {
    opacity: .75;
    font-size: .9rem;
}

.ac-meta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 12px;
    color: var(--accent-color, #14532d);
}

.ac-meta-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--accent-color);
    background: var(--accent-weak, rgba(20, 83, 45, 0.08));
    line-height: 1.2;
}

.ac-filters {
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    padding: 8px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
}

.ac-f-row {
    display: contents;
}

.ac-filters input[type=text],
.ac-filters input[type=number],
.ac-filters select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
}

.ac-filters .full {
    grid-column: 1 / -1;
}

.ac-filters .btn {
    padding: 6px 8px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    cursor: pointer;
    font-size: 13px;
}

    .ac-filters .btn:hover {
        background: var(--accent-weak, #f6f6f6);
    }

.ac-history {
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.ac-history-title {
    margin: 0;
}

.ac-history-range {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    align-items: center;
}

.ac-history-range label {
    font-size: 12px;
    opacity: .8;
}

.ac-history-range input[type=datetime-local] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
}

.ac-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ac-history .btn {
    padding: 6px 10px;
    border: 1px solid var(--border, #dcdcdc);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--fg, inherit);
    cursor: pointer;
    font-size: 13px;
}

.ac-history .btn.primary {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: #fff;
}

.ac-history .btn.primary:hover {
    filter: brightness(0.95);
}

.ac-history .btn.secondary:hover {
    background: var(--accent-weak, #f6f6f6);
}

.ac-history-results .ac-history-card {
    cursor: pointer;
}

.ac-history-results .ac-history-card.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(27, 122, 42, 0.25);
}

/* Flight Info Popup */
.flight-info-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flight-info-popup.hidden {
    display: none;
}

.flight-info-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.flight-info-panel {
    position: relative;
    background: var(--card-bg, var(--surface, #fff));
    color: var(--fg, #1f2937);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1rem;
}

.flight-info-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted, #6b7280);
    line-height: 1;
    padding: 0.25rem;
}

.flight-info-close:hover {
    color: var(--text, #111);
}

.flight-info-title {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.flight-info-content {
    font-size: 0.9rem;
}

.flight-info-loading {
    text-align: center;
    color: var(--muted, #6b7280);
    padding: 2rem;
}

.flight-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.flight-info-row:last-child {
    border-bottom: none;
}

.flight-info-label {
    color: var(--muted, #6b7280);
    font-weight: 500;
}

.flight-info-value {
    text-align: right;
    font-weight: 500;
}

.flight-info-section {
    margin-top: 1rem;
}

.flight-info-section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted, #6b7280);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.flight-info-route {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.flight-info-airport {
    text-align: center;
    flex: 1;
}

.flight-info-airport-icao {
    font-size: 1.1rem;
    font-weight: 700;
}

.flight-info-airport-name {
    font-size: 0.75rem;
    color: var(--muted, #6b7280);
}

.flight-info-arrow {
    font-size: 1.2rem;
    color: var(--accent-color, #2563eb);
}

.flight-info-highlight {
    background: var(--accent-color, #2563eb);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.flight-info-error {
    color: #b91c1c;
    text-align: center;
    padding: 1rem;
}

.flight-info-route-text {
    font-size: 0.75rem;
    word-break: break-all;
    line-height: 1.3;
}

/* Pilot info section */
.flight-info-pilot {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pilot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.pilot-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color, #2563eb);
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.pilot-name {
    font-weight: 600;
    font-size: 1rem;
}

/* Info button styling */
.ac-action-info {
    background: var(--accent-color, #2563eb);
    color: white;
}

.ac-action-info:hover {
    background: var(--accent-hover, #1d4ed8);
}
