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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 0;
}

#sidebar-backdrop {
    display: none;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header p {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#sidebar {
    width: 260px;
    min-width: 260px;
    background: #2c3e50;
    color: white;
    padding: 1.25rem;
    overflow-y: auto;
}

.search-section {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.search-section input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border: none;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.12);
    color: white;
    min-width: 0;
}

.search-section input::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-section input:focus {
    outline: none;
    background: rgba(255,255,255,0.2);
}

.search-section button {
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    border: none;
    background: #3498db;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.search-section button:hover {
    background: #2980b9;
}

.search-section input.search-error {
    background: rgba(231, 76, 60, 0.4);
}

#sidebar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header-logo {
    height: 36px;
    width: auto;
    filter: brightness(0) invert(1);
}

.filter-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 0.4em;
    padding: 0 0.2em;
    vertical-align: middle;
    line-height: 1;
    font-size: 1em;
    color: white;
    opacity: 0.85;
}
.refresh-btn:hover { opacity: 1; }

@keyframes spin { to { transform: rotate(360deg); } }

#map-loading {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#map-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,0.12);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    border: 2px solid rgba(255,255,255,0.25);
    border-top-color: rgba(255,255,255,0.85);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-left: 0.4em;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-checkbox input[type="checkbox"] {
    accent-color: #3498db;
    width: 16px;
    height: 16px;
}

.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

#map {
    flex: 1;
    position: relative;
}

/* Category cluster styles */
.category-cluster {
    background: transparent;
    border: none;
}

.category-cluster div {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.category-cluster span {
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Custom marker styles */
.custom-marker {
    background: transparent;
    border: none;
}

.marker-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-icon svg {
    display: block;
}

/* Aircraft: glow while animating to new position */
@keyframes ac-move-glow {
    0%, 100% { box-shadow: 0 2px 5px rgba(0,0,0,0.3), 0 0 6px 2px rgba(243,156,18,0.8); }
    50%       { box-shadow: 0 2px 5px rgba(0,0,0,0.3), 0 0 14px 4px rgba(241,196,15,1); }
}
.ac-moving .marker-icon {
    animation: ac-move-glow 0.6s ease-in-out infinite;
    border-color: #f1c40f;
}

/* Aircraft position-update pulse ring */
@keyframes ac-ping {
    0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
}
.ac-pulse {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(243, 156, 18, 0.45);
    animation: ac-ping 0.7s ease-out forwards;
    pointer-events: none;
}

/* Popup styles */
.point-popup {
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.point-popup h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.point-popup .category {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    text-transform: capitalize;
    margin-bottom: 0.5rem;
}

.point-popup .description {
    color: #555;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.point-popup .coordinates {
    color: #888;
    font-size: 0.8rem;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 12px 16px;
    max-height: 320px;
    overflow-y: auto;
}

@media (max-width: 640px) {
    header {
        padding: 0.75rem 1rem;
    }
    header p {
        display: none;
    }
    #sidebar-toggle {
        display: block;
    }
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    #sidebar-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
}
