:root {
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-light: rgba(255, 255, 255, 0.9);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}


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

html,
body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#map {
    height: 100vh;
    width: 100%;
}

/* Controls positioning */
#controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

/* Filter panels */
.filter {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px 16px;
    min-width: 160px;
    color: var(--text-light);
}

.filter legend {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.filter>div {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

/*Checkboxes */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2A9D8F;
}

label {
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

/* Legend dots */
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}


/* Buttons */
button {
    background: white;
    border: 1px solid #ccc;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
}

/* Rate limit card */
#rate-limit-card {
    background: white;
    border: 1px solid #ccc;
    padding: 8px;
    font-size: 12px;
    color: #333;
}

#rate-count {
    font-weight: bold;
}

/* Marker count */
#marker-count {
    background: white;
    border: 1px solid #ccc;
    padding: 8px;
    font-size: 12px;
    color: #333;
}

/* Polygon labels */
.polygon-label {
    background: transparent;
    border: none;
    box-shadow: none;
    font-weight: bold;
    color: #333;
    text-align: center;
}

/*Vehicle popups */
.leaflet-popup-content-wrapper {
    background: rgba(20, 20, 30, 0.95) !important;
    backdrop-filter: blur(10px);
    border-radius: 8px !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
}

.leaflet-popup-tip {
    background: rgba(20, 20, 30, 0.95) !important;
}

.vehicle-card {
    padding: 12px;
    color: #fff;
    font-size: 13px;
}

.vehicle-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.vehicle-badge {
    font-weight: 700;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    letter-spacing: 0.5px;
}

.vehicle-direction {
    margin: 4px 0 8px;
    opacity: 0.8;
}

.vehicle-details {
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.7;
    font-size: 12px;
}

.vehicle-details small {
    line-height: 1.6;
}

.portfolio-link {
    position: fixed;
    bottom: 16px;
    left: auto;
    z-index: 1000;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: bluer(8px);
    transition: all 0.2s ease;
}

.portfolio-link:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Filter handle (hidden on desktop) */
.filter-handle {
    display: none;
}



/* Mobile-specific styles */
@media (max-width: 768px) {
    #controls {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        align-items: stretch;
        background: rgba(20, 20, 30, 0.98);
        backdrop-filter: blur(20px);
        border-radius: 20px 20px 0 0;
        padding: 0;
        gap: 0;
        max-height: 80vh;
        transform: translateY(calc(100% - 60px));
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
    }

    #controls.open {
        transform: translateY(0);
    }

    /* Filter handle */
    .filter-handle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 12px;
        cursor: pointer;
        user-select: none;
        gap: 6px;
        min-height: 60px;
    }

    .handle-bar {
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        transition: background 0.2s;
    }

    .filter-handle:active .handle-bar {
        background: rgba(255, 255, 255, 0.5);
    }

    .handle-text {
        font-size: 12px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.7);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Filters container */
    #controls>fieldset {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        min-width: auto;
    }

    #controls>fieldset:last-of-type {
        border-bottom: none;
    }

    /* Adjust filter layout for mobile */
    .filter {
        padding: 16px 20px;
    }

    .filter legend {
        font-size: 15px;
        margin-bottom: 12px;
        color: rgba(255, 255, 255, 0.9);
    }

    .filter>div {
        padding: 6px 0;
    }

    .portfolio-link {
        bottom: auto;
        top: 16px;
        right: 16px;
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Two-column layout for checkboxes on wider mobile screens */
    @media (min-width: 480px) {
        .filter {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

        .filter legend {
            grid-column: 1 / -1;
        }
    }

    /* Hide debugging controls on mobile */
    #debugging-controls {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    #controls {
        top: 12px;
        right: 12px;
        gap: 10px;
    }

    .filter {
        min-width: 140px;
        padding: 10px 14px;
    }
}