* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

.header {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1;
    max-width: 300px;
}

.header h1 {
    font-size: 18px;
    margin-bottom: 5px;
    color: #333;
}

.header p {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.header a {
    color: #0066cc;
    text-decoration: none;
    font-size: 11px;
}

.header-close {
    position: absolute;
    top: 5px;
    right: 10px;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    background: none;
    border: none;
    padding: 0;
}

.header-close:hover {
    color: #333;
}

.info-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 1;
    display: none;
    border: none;
    font-size: 16px;
}

.info-toggle:hover {
    background: #fff;
}

.borders-toggle {
    position: absolute;
    top: 150px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 100;
    border: none;
    font-size: 16px;
}

.borders-toggle:hover {
    background: #fff;
}

.borders-toggle.active {
    background: #e6f7ff;
    border: 1px solid #1890ff;
}

.legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    z-index: 1;
}

.legend-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.legend-scale {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #666;
    font-weight: 600;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    display: block;
}

.legend-subtitle {
    text-align: center;
    font-size: 10px;
    color: #888;
    margin-top: 5px;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(50, 50, 50, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.toast.show {
    display: block;
    opacity: 1;
}

.darkness-control {
    position: absolute;
    top: 240px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    min-width: 160px;
}

.darkness-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
}

.darkness-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #f0f0f0, #1a1a1a);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 6px;
}

.darkness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #663399;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.darkness-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.darkness-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #663399;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.darkness-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.darkness-value {
    font-size: 11px;
    color: #666;
    text-align: center;
    font-weight: 600;
}

.darkness-toggle {
    position: absolute;
    top: 200px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 100;
    border: none;
    font-size: 16px;
}

.darkness-toggle:hover {
    background: #fff;
}

.darkness-toggle.active {
    background: #f3e5f5;
    border: 1px solid #663399;
}

.darkness-control.collapsed {
    display: none;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .legend {
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 10px;
        font-size: 11px;
    }

    .legend-scale {
        gap: 5px;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .legend-item {
        font-size: 10px;
        gap: 4px;
        flex: 1;
        min-width: 0;
    }

    .color-box {
        width: 24px !important;
        height: 24px !important;
        display: block !important;
        flex-shrink: 0;
        min-width: 24px;
        min-height: 24px;
    }

    .legend-title {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .legend-subtitle {
        font-size: 9px;
    }

    .header {
        max-width: calc(100% - 20px);
        font-size: 11px;
    }

    .header h1 {
        font-size: 16px;
    }

    .header p {
        font-size: 11px;
    }

    .darkness-control {
        left: 10px;
        min-width: 140px;
        padding: 10px 12px;
    }
}

.maplibregl-ctrl-top-left {
    top: 250px !important;
}

/* Collapsible Geocoder */
.maplibregl-ctrl-geocoder {
    width: 50px !important;
    /* Start with icon width */
    min-width: 50px !important;
    transition: width 0.3s ease-in-out, min-width 0.3s ease-in-out;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    background-color: #fff;
    border-radius: 20px;
    /* Rounded pill shape looks better for this */
}

/* Expand on hover or focus */
.maplibregl-ctrl-geocoder:hover,
.maplibregl-ctrl-geocoder:focus-within {
    width: 300px !important;
    min-width: 300px !important;
}

/* Adjust icon position if needed */
.maplibregl-ctrl-geocoder--icon-search {
    left: 15px !important;
    /* Center icon when collapsed */
}

/* Adjust input padding to not overlap icon */
.maplibregl-ctrl-geocoder--input {
    padding-left: 45px !important;
}