@font-face {
    font-family: 'ERAM';
    src: url('fonts/ERAMv304.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #1a1a1a;
    color: #ffffff;
}

#header {
    background: #2a2a2a;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

#header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
}

#stats {
    font-size: 14px;
    color: #cccccc;
}

#flight-count {
    font-weight: 600;
    color: #4CAF50;
}

#filter-container {
    display: flex;
    align-items: center;
}

#va-filter {
    padding: 6px 12px;
    background: #3a3a3a;
    border: 1px solid #4a4a4a;
    color: #ffffff;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

#va-filter:hover {
    border-color: #5a5a5a;
    background: #404040;
}

#va-filter:focus {
    border-color: #4CAF50;
    background: #404040;
}

#va-filter option {
    background: #3a3a3a;
    color: #ffffff;
}

#dark-mode-toggle {
    background: #3a3a3a;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
}

#dark-mode-toggle:hover {
    background: #4a4a4a;
    border-color: #5a5a5a;
}

#dark-mode-toggle:active {
    background: #2a2a2a;
}

#dark-mode-icon {
    display: block;
    line-height: 1;
}

/* Floating Flight Info Panel */
.flight-panel {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 120px);
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}

.flight-panel.hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.flight-panel-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    padding-right: 50px; /* Extra padding on right to make room for close button */
    border-bottom: 1px solid #3a3a3a;
    background: #1f1f1f;
    gap: 12px;
    position: relative; /* Allow absolute positioning of close button */
}

.flight-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #4CAF50;
    flex-shrink: 0;
    font-family: 'ERAM', 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.flight-panel-logo {
    flex: 1;
    max-height: 40px;
    width: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    min-width: 0; /* Allow logo to shrink if needed */
}

.close-btn {
    background: transparent;
    border: none;
    color: #cccccc;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    position: absolute;
    right: 16px; /* Fixed distance from right edge */
    top: 50%;
    transform: translateY(-50%);
    flex-shrink: 0;
}

.close-btn:hover {
    background: #3a3a3a;
    color: #ffffff;
}

.flight-panel-content {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    font-family: 'ERAM', 'Courier New', monospace;
}

.flight-panel-content .flight-info {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
    font-family: 'ERAM', 'Courier New', monospace;
    display: flex;
}

.flight-panel-content .flight-info:last-child {
    margin-bottom: 0;
}

.flight-panel-content .flight-info strong {
    color: #cccccc;
    display: inline-block;
    width: 120px;
    flex-shrink: 0;
    margin-right: 8px;
}

.flight-panel-content .flight-info span {
    color: #ffffff;
    flex: 1;
}

/* Scrollbar styling for panel content */
.flight-panel-content::-webkit-scrollbar {
    width: 6px;
}

.flight-panel-content::-webkit-scrollbar-track {
    background: #1f1f1f;
}

.flight-panel-content::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

.flight-panel-content::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

#map-container {
    position: relative;
    height: calc(100vh - 60px);
    width: 100%;
    background: #1a1a1a; /* Dark background to prevent white flash */
}

#map {
    height: 100%;
    width: 100%;
    background: #1a1a1a; /* Dark background to prevent white flash */
}

/* Zoom Level Indicator */
.zoom-indicator {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(26, 26, 26, 0.85);
    color: #00ff00;
    padding: 6px 12px;
    border: 1px solid #00ff00;
    border-radius: 4px;
    font-family: 'ERAM', 'Courier New', monospace;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
    user-select: none;
}

.zoom-indicator #zoom-level-value {
    font-weight: bold;
    color: #ffff00;
}

/* Prevent white flash when tiles load or wrap */
.leaflet-container {
    background: #1a1a1a !important;
}

.leaflet-tile-container {
    background: #1a1a1a;
}

/* Mobile-specific tile rendering fixes */
@media (max-width: 768px) {
    /* Force proper rendering and remove stale tiles */
    .leaflet-tile-container img {
        image-rendering: auto;
        -webkit-image-rendering: auto;
        opacity: 1 !important;
        will-change: auto;
    }
    
    /* Hide tiles that are loading or stale */
    .leaflet-tile-container img[src=""] {
        display: none !important;
    }
    
    /* Ensure loaded tiles are visible */
    .leaflet-tile-loaded {
        opacity: 1 !important;
        display: block !important;
    }
    
    /* Remove any grey placeholder tiles */
    .leaflet-tile-container img:not(.leaflet-tile-loaded) {
        opacity: 0 !important;
        pointer-events: none;
    }
    
    /* Force hardware acceleration for tile rendering */
    .leaflet-tile-pane {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* Ensure tile containers are properly cleared */
    .leaflet-tile-container {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Improve icon rendering quality - smooth anti-aliasing */
.leaflet-marker-icon {
    image-rendering: auto;
    -ms-interpolation-mode: bicubic;
    /* Force hardware acceleration for better rendering */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Smooth scaling */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ATC Radar Scope Styling */
.atc-aircraft-icon {
    background: transparent !important;
    border: none !important;
    pointer-events: auto; /* Ensure aircraft markers are clickable */
    z-index: 1000; /* Ensure aircraft markers are above datablocks */
}

.atc-aircraft-dot {
    width: 7.5px; /* Reduced by 25% from 10px */
    height: 7.5px; /* Reduced by 25% from 10px */
    background: transparent; /* Hollow - no fill */
    border: 1px solid #ffff00; /* Yellow outline - thinner */
    transform: rotate(45deg); /* Rotate square to make diamond */
    position: relative;
}

.atc-aircraft-dot::after {
    content: '';
    position: absolute;
    top: 50%; /* Centered vertically */
    left: 50%; /* Centered horizontally */
    width: calc(141% + 7.5px); /* Reduced proportionally from 10px to 7.5px */
    height: 1px; /* Thin line */
    background: #ffff00; /* Yellow slash */
    transform: translate(-50%, -50%) rotate(8deg); /* Centered with slight clockwise rotation */
    transform-origin: center center; /* Center origin for proper centering */
}

/* Ground aircraft marker - airplane symbol */
.atc-aircraft-ground {
    width: 12px;
    height: 12px;
    background: transparent;
    position: relative;
}

/* Vertical line (fuselage) */
.atc-aircraft-ground::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: #ffff00; /* Yellow vertical line */
    transform: translateX(-50%);
}

/* Horizontal line (wings) - above center */
.atc-aircraft-ground::after {
    content: '';
    position: absolute;
    top: 30%; /* Above center */
    left: 0;
    width: 100%;
    height: 1px;
    background: #ffff00; /* Yellow horizontal line */
}

/* Tail - shorter horizontal line towards the back (bottom) */
.atc-aircraft-tail {
    position: absolute;
    bottom: 15%; /* Towards the back */
    left: 50%;
    width: 60%; /* Shorter than wings */
    height: 1px;
    background: #ffff00; /* Yellow tail line */
    transform: translateX(-50%);
}

/* Arrival airport X marker */
.arrival-airport-x {
    width: 10px;
    height: 10px;
    position: relative;
}

.arrival-airport-x::before,
.arrival-airport-x::after {
    content: '';
    position: absolute;
    width: 1px; /* Thinner lines */
    height: 141%; /* sqrt(2) * 100% for diagonal */
    background: #ffff00;
    top: 50%;
    left: 50%;
}

.arrival-airport-x::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.arrival-airport-x::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Horizontal line at bottom to close the X */
.arrival-airport-x-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px; /* Thinner line */
    background: #ffff00;
}

.arrival-airport-icon {
    background: transparent !important;
    border: none !important;
}

.atc-data-block-icon {
    background: transparent !important;
    border: none !important;
    pointer-events: none; /* Allow clicks to pass through to aircraft marker */
}

.atc-data-block-wrapper {
    position: relative;
    display: inline-block;
}

.atc-vertical-line {
    position: absolute;
    top: 1px; /* Slightly further from text */
    left: 2px; /* Slightly further from text */
    width: 1px; /* Thinner line */
    height: calc(11px * 1.0 * 3); /* Height for 3 lines: font-size * line-height * 3 lines */
    background: #c0c0c0; /* Slightly more grey */
    /* Starts at the top of the callsign and extends down to the bottom of line 3 */
}

/* Ground data block vertical line - only extends to bottom of line 1 */
.atc-ground-vertical-line {
    top: 1px; /* Slightly further from text */
    left: 2px; /* Slightly further from text */
    height: calc(11px * 1.0); /* Height for 1 line: font-size * line-height */
}

.atc-horizontal-line {
    position: absolute;
    top: 1px; /* Slightly further from text */
    left: 2px; /* Slightly further from text */
    width: 50%; /* Extends halfway across */
    height: 1px; /* Thinner line */
    background: #c0c0c0; /* Slightly more grey */
}

.atc-data-block {
    color: #ffff00; /* Yellow */
    background: transparent; /* Fully transparent background */
    padding: 2px 4px;
    font-family: 'ERAM', 'Courier New', monospace;
    font-size: 11px;
    font-weight: normal;
    line-height: 1.0;
    display: inline-block;
    transform-origin: bottom left;
}

.atc-callsign {
    color: #ffff00; /* Yellow */
    font-size: 11px;
    line-height: 1.0;
    margin-bottom: 0px;
    font-family: 'ERAM', 'Courier New', monospace;
}

.atc-altitude {
    color: #ffff00; /* Yellow */
    font-size: 11px;
    line-height: 1.0;
    margin-bottom: 0px;
    font-family: 'ERAM', 'Courier New', monospace;
}

.atc-cid-speed {
    color: #ffff00; /* Yellow */
    font-size: 11px;
    line-height: 1.0;
    margin-bottom: 0px;
    font-family: 'ERAM', 'Courier New', monospace;
}

.atc-arrival-icao {
    color: #b8b800; /* Faint yellow, darker than main yellow */
    font-size: 11px;
    line-height: 1.0;
    opacity: 0.7; /* Additional dimming for faint appearance */
    font-family: 'ERAM', 'Courier New', monospace;
}

.loading-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(42, 42, 42, 0.95);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: none;
}

.loading-indicator.show {
    display: block;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    background: #2a2a2a;
    color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 14px;
    min-width: 250px;
}

.leaflet-popup-content h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #4CAF50;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.leaflet-popup-content .flight-info {
    margin: 8px 0;
}

.leaflet-popup-content .flight-info strong {
    color: #cccccc;
    display: inline-block;
    width: 120px;
}

.leaflet-popup-content .flight-info span {
    color: #ffffff;
}

.leaflet-popup-tip {
    background: #2a2a2a;
}

.leaflet-popup-close-button {
    color: #ffffff;
    font-size: 20px;
    padding: 5px;
}

.leaflet-popup-close-button:hover {
    color: #ff4444;
}

/* Airport marker styling */
.airport-marker {
    background: #ffffff;
    border: 2px solid #2196F3;
    border-radius: 50%;
    width: 12px;
    height: 12px;
}

.airport-marker.highlighted {
    background: #FFD700;
    border-color: #FFA500;
    width: 16px;
    height: 16px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

/* Responsive design */
@media (max-width: 768px) {
    #header {
        padding: 10px 15px;
    }
    
    #header h1 {
        font-size: 20px;
    }
    
    #stats {
        font-size: 12px;
    }
    
    .leaflet-popup-content {
        min-width: 200px;
        font-size: 12px;
    }
    
    /* Mobile-optimized flight panel - bottom sheet style */
    .flight-panel {
        top: auto;
        bottom: 20px; /* Shift up to avoid Safari address bar */
        left: 10px;
        right: 10px;
        width: calc(100% - 20px); /* Account for left/right margins */
        max-width: calc(100% - 20px);
        max-height: 50vh; /* Limit to 50% of viewport height */
        border-radius: 16px 16px 0 0; /* Rounded top corners only */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
        transform: translateY(0);
    }
    
    .flight-panel.hidden {
        transform: translateY(calc(100% + 20px)); /* Slide down off screen, accounting for bottom margin */
        opacity: 1; /* Keep opacity at 1 for smooth slide animation */
    }
    
    .flight-panel-header {
        padding: 12px 16px;
        padding-right: 44px; /* Room for close button */
        min-height: 48px; /* Touch-friendly minimum height */
    }
    
    .flight-panel-header h3 {
        font-size: 16px;
    }
    
    .flight-panel-logo {
        max-height: 32px; /* Smaller logo on mobile */
    }
    
    .close-btn {
        width: 32px; /* Larger touch target */
        height: 32px;
        font-size: 28px;
        right: 12px;
    }
    
    .flight-panel-content {
        padding: 12px 16px;
        max-height: calc(50vh - 60px); /* Account for header */
        font-size: 13px;
    }
    
    .flight-panel-content .flight-info {
        margin-bottom: 10px;
        font-size: 13px;
        line-height: 1.4;
    }
    
    .flight-panel-content .flight-info strong {
        width: 100px; /* Narrower label width on mobile */
        font-size: 12px;
    }
    
    /* Add drag handle indicator for mobile */
    .flight-panel-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #4a4a4a;
        border-radius: 2px;
    }
    
    /* Adjust zoom indicator for mobile */
    .zoom-indicator {
        bottom: 8px;
        left: 8px;
        font-size: 11px;
        padding: 4px 10px;
    }
    
    /* Adjust map container for mobile header */
    #map-container {
        height: calc(100vh - 60px);
    }
}


