:root {
    --bg-dark: #0a0a0c;
    --panel-bg: rgba(20, 20, 25, 0.8);
    --accent: #00d4ff;
    --accent-glow: rgba(0, 212, 255, 0.4);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    touch-action: pan-x pan-y;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Custom UI Overlay */
#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    width: 320px;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, width 0.3s ease;
    pointer-events: none;
}

/* Collapsed state for mobile: essentially hidden until toggled */
#ui-overlay.collapsed {
    display: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    background: #ff4b2b;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff4b2b;
}

.dot.online {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.stat-box .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

#aircraft-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Critical for flex scrolling */
    margin-bottom: 20px;
}

.stat-box .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    color: var(--accent);
}

#aircraft-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
    padding-right: 4px;
}

#aircraft-list::-webkit-scrollbar {
    width: 4px;
}

#aircraft-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.ac-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ac-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border);
}

.ac-item.active {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent);
    padding: 12px;
}

.ac-compact {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    flex: 1;
}

.ac-compact-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.ac-compact-dist {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    margin-left: 8px;
    white-space: nowrap;
}

.ac-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ac-callsign {
    font-weight: 600;
    color: var(--accent);
}

.ac-icao {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ac-route {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
}

.ac-info-row {
    display: flex;
    justify-content: space-around;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.heavy-badge {
    background: #ffaa00;
    color: #000;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

/* Map Overrides */
.leaflet-container {
    background: var(--bg-dark) !important;
}

.leaflet-bar {
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-bar a {
    background-color: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border) !important;
}

/* Plane Marker Styling */
.plane-icon-svg {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.3));
    transition: transform 0.5s linear;
}



.leaflet-tooltip {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #333 !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
    pointer-events: none;
}

.tooltip-line-1 {
    font-weight: 600;
    color: #0070ff;
}

.tooltip-line-2 {
    color: #666;
}

/* Rich Hover Card */
#hover-card {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 280px;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 1001;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, width 0.3s ease;
    pointer-events: none;
}

/* Collapsed state for mobile: essentially hidden until toggled */
#ui-overlay.collapsed {
    display: none;
}

#hover-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
    transition: all 0.2s ease;
    pointer-events: auto;
    /* Enable clicks even if parent has pointer-events: none */
}

#hover-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#hover-card.hidden {
    opacity: 0;
    transform: translateY(-10px);
    display: block !important;
    pointer-events: none;
}

.hover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#hover-type {
    background: var(--accent);
    color: #000;
    font-size: 0.70rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
}

#hover-reg {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

#hover-callsign {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

#hover-model {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.detail-row {
    font-size: 0.75rem;
    margin-bottom: 4px;
    display: flex;
    gap: 6px;
}

.detail-row .label {
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-row span:not(.label) {
    color: var(--text-primary);
}

.hover-route {
    font-size: 0.75rem; /* Small font size as requested */
    flex-wrap: wrap;
    text-align: center;
    word-wrap: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-family: 'JetBrains Mono', monospace;
}

.hover-route .arrow {
    color: var(--accent);
}

.hover-route #hover-from,
.hover-route #hover-to {
    font-size: 0.8rem;
    font-weight: 600;
}

/* Settings UI */
#settings-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 10px;
    padding: 0;
    line-height: 1;
}

/* Mobile Media Queries */
@media (max-width: 768px) {
    /* Fixed Sidebar on Mobile when open */
    #ui-overlay.open {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        display: flex;
        z-index: 2000;
        transform: none;
        opacity: 1;
        box-shadow: 10px 0 50px rgba(0, 0, 0, 0.5);
    }

    #menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--accent);
        color: #000;
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        z-index: 2100;
        cursor: pointer;
    }

    /* Move Leaflet controls to top-right on mobile to avoid overlap */
    .leaflet-top.leaflet-right {
        top: 70px;
    }
}

.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background-color: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    position: relative;
    color: var(--text-primary);
    backdrop-filter: var(--glass-blur);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-secondary);
}

.close-modal:hover {
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.btn-primary {
    background-color: #0070ff;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: background-color 0.2s;
    height: auto;
    min-height: 44px;
    white-space: normal;
    line-height: 1.4;
    word-wrap: break-word;
}

.btn-primary:hover {
    background-color: #0056c7;
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 1.25rem;
    }
}
#ui-overlay > *, #hover-card > * { pointer-events: auto; }

.route-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    pointer-events: auto;
}

.route-btn {
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    height: 24px;
    line-height: 1;
}

.route-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 8px var(--accent-glow);
}

