* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.header-container {
    position: absolute;
    top: 0;
    left: 0;
    height: 64px;
    left: 50%;
    z-index: 1000;
    display: flex;
    transform: translateX(-53.4px);
    justify-content: center;
}

.header {
    display: flex;
    align-items: center;
}

.header a {
    width: 91px;
    height: 31.5px;
    background: white;
    border-radius: 30px;
}

.header-logo {
    width: 100%;
    height: 100%;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

/* Map container */
#map {
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Nút mở panel chọn tỉnh */
.province-toggle-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
}

.province-toggle-btn:hover {
    background: #f5f5f5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Panel chọn tỉnh */
.province-panel {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 15px;
    width: 280px;
    max-width: 90%;
    display: none;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.province-panel.show {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Select box (dành cho Choices.js) */
.province-select-dropdown {
    width: 100%;
}

/* Nút "Xem bản đồ" */
.select-province-btn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.select-province-btn:hover {
    background-color: #0069d9;
}

/* Loading spinner */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #333;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 0;
    visibility: hidden;
    max-width: 150px;
}

.loading-spinner.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner .fa-spinner {
    font-size: 2em;
    color: #007bff;
}

.loading-spinner .loading-text {
    margin-top: 0px;
    font-weight: 600;
    font-size: 0.85em;
    text-align: center;
    white-space: nowrap;
}

.loading-spinner.hide {
    opacity: 0;
}

/* Thanh opacity slider */
.opacity-control {
    position: absolute;
    top: 138px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 12px 0px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    width: 38px;
}

.opacity-slider {
    -webkit-appearance: slider-vertical;
    width: 8px;
    height: 120px;
    padding: 0;
    margin: 10px 0;
    background: linear-gradient(to bottom, #007bff, #00ccff);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    align-self: center;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #007bff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-value-display {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px 6px;
    border-radius: 10px;
    min-width: 30px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

/* Hiệu ứng khi hover */
.opacity-control:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.opacity-control:hover .opacity-slider {
    background: linear-gradient(to bottom, #0069d9, #00b7ff);
}

/* Location button */
.location-btn {
    position: absolute;
    top: 90px;
    right: 10px;
    z-index: 1000;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #333;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.location-btn:hover {
    background: #f4f4f4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.location-btn:active {
    transform: scale(0.95);
}

.location-btn.loading {
    color: #007cff;
}

.location-btn.error {
    color: #ff4444;
}

/* Location permission popup */
.location-permission-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    text-align: center;
    display: none;
    max-width: 300px;
    box-sizing: border-box;
    width: calc(100% - 40px);
}

.permission-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.permission-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.permission-btn.allow {
    background: #007cff;
    color: white;
}

.permission-btn.deny {
    background: #ddd;
    color: #333;
}

.permission-btn:hover {
    opacity: 0.8;
}

/* Error message */
.error-message {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    z-index: 1002;
    font-size: 14px;
    display: none;
    max-width: 80%;
    text-align: center;
}

/* Layer control */
.leaflet-control-layers {
    border-radius: 8px;
    overflow: hidden;
}

/* Planning layer styles */
.leaflet-image-layer.planning-layer img {
    transition: opacity 0.5s ease-in-out;
}

.leaflet-image-layer.planning-layer {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
}

.leaflet-image-layer.planning-layer img {
    pointer-events: none;
}

.leaflet-image-layer.planning-layer:focus,
.leaflet-image-layer.planning-layer:active {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* Responsive styles */
@media (max-width: 768px) {
    .header {
        padding: 6px 15px;
    }

    .header-logo {
        height: 24px;
    }

    .header-title {
        font-size: 14px;
    }

    .province-panel {
        width: 90%;
        max-height: 60vh;
        bottom: 80px;
    }

    .province-toggle-btn {
        bottom: 15px;
        padding: 8px 16px;
        font-size: 13px;
    }

    .location-btn {
        top: 80px;
        /* Điều chỉnh top cho màn hình nhỏ hơn */
        right: 5px;
        /* Giảm khoảng cách lề phải */
        width: 34px;
        /* Giảm kích thước nút cho màn hình nhỏ */
        height: 34px;
        font-size: 14px;
        border-radius: 50%;
        /* Đảm bảo vẫn tròn trên mobile */
    }

    .opacity-control {
        top: calc(80px + 34px + 8px);
        /* top của location-btn + height của location-btn + khoảng cách */
        right: 5px;
        /* Giảm khoảng cách lề phải */
        padding: 8px 0px;
        /* Điều chỉnh padding cho màn hình nhỏ */
        width: 34px;
        /* Đảm bảo chiều rộng khớp với location-btn trên mobile */
    }

    .opacity-slider {
        height: 100px;
        /* Giữ nguyên hoặc điều chỉnh */
        width: 6px;
        /* Có thể làm thanh trượt mỏng hơn một chút */
    }

    .opacity-value-display {
        font-size: 10px;
        /* Giảm thêm font size */
        padding: 3px 5px;
        min-width: 25px;
    }

    .error-message {
        top: 60px;
        font-size: 13px;
        padding: 8px 12px;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .province-panel {
        max-height: 50vh;
    }

    .location-btn {
        top: 70px;
        /* Có thể giảm thêm top cho màn hình rất nhỏ */
        right: 5px;
        width: 30px;
        /* Kích thước nhỏ hơn nữa cho màn hình rất nhỏ */
        height: 30px;
        font-size: 12px;
    }

    .opacity-control {
        top: calc(70px + 30px + 8px);
        /* Tương tự, điều chỉnh top cho màn hình rất nhỏ */
        right: 5px;
        padding: 6px 0px;
        /* Giảm padding */
        width: 30px;
        /* Đảm bảo khớp chiều rộng */
    }

    .opacity-slider {
        height: 80px;
        /* Giảm chiều cao thanh trượt */
        width: 6px;
    }

    .opacity-value-display {
        font-size: 9px;
        padding: 2px 4px;
        min-width: 20px;
    }

    .loading-spinner {
        padding: 12px 20px;
        max-width: 130px;
    }

    .loading-spinner .fa-spinner {
        font-size: 1.5em;
    }

    .loading-spinner .loading-text {
        font-size: 0.8em;
    }
}
