/* Reset CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    overflow: hidden; /* Ngăn scroll trang chính */
}

/* Container chính */
.container {
    display: flex;
    flex-direction: row; /* Mặc định PC/Tablet */
    height: 100vh; /* Trở lại 100vh vì nút nằm trong container */
    padding: 15px;
    gap: 15px;
    box-sizing: border-box;
}

/* Khung hiển thị bản đồ tổng thể */
.map-container {
    position: relative; /* Rất quan trọng để các nút con có position absolute */
    flex: 1; /* Chiếm hết chiều rộng còn lại */
    overflow: hidden; /* Giúp zoom và pan mượt mà */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex; /* Để căn giữa ảnh */
    justify-content: center;
    align-items: center;
    height: 100%; /* Đảm bảo chiều cao bằng 100% viewport */
}

.full-map {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Giữ nguyên tỷ lệ, không bóp méo */
    cursor: grab;
    transition: transform 0.3s ease-out; /* Thời gian 0.3s và kiểu ease-out */
    will-change: transform; /* Tối ưu hiệu suất */
}

/* KHUNG ĐIỀU KHIỂN NÚT - NẰM TRONG map-container */
.map-controls {
    position: absolute; /* Quan trọng: vị trí tuyệt đối trong map-container */
    bottom: 20px; /* Cách đáy 20px */
    left: 50%; /* Dịch sang 50% từ trái */
    transform: translateX(-50%); /* Dịch ngược lại 50% chiều rộng của chính nó để căn giữa */
    display: flex;
    gap: 10px;
    z-index: 10;
}

.map-controls button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.map-controls button:hover {
    background-color: #0056b3;
}

/* Khung danh sách bản đồ */
.map-list-container {
    width: 350px; /* Bề ngang cố định cho PC/Tablet */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow-y: auto; /* Tạo thanh cuộn khi cần */
    height: 100%; /* Đảm bảo chiều cao bằng 100% của .container */
}

.map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.map-table th, .map-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.map-table th {
    background-color: #e9ecef;
    color: #495057;
    font-weight: bold;
    position: sticky; /* Giữ header khi cuộn */
    top: 0;
    z-index: 1; /* Đảm bảo header nằm trên content */
}

.map-table tbody tr:hover {
    background-color: #f8f9fa;
}

.map-table tbody tr:last-child td {
    border-bottom: none;
}

.map-table .map-title {
    color: #007bff;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
}

.map-table .map-title:hover {
    text-decoration: underline;
    color: #0056b3;
}

.map-table .detail-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s ease;
}

.map-table .detail-button:hover {
    background-color: #218838;
}

/* Chi tiết bản đồ nhỏ */
.detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
    opacity: 0;
    transform: scale(0.8); /* Bắt đầu nhỏ để zoom out */
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    overflow-y: auto; /* Cho phép cuộn nếu nội dung dài */
}

.detail-view.visible {
    opacity: 1;
    transform: scale(1);
}

.detail-view.hidden {
    display: none; /* Ẩn hoàn toàn khi không dùng */
}

.detail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 900px; /* Giới hạn độ rộng nội dung */
    width: 95%;
    padding: 20px;
    gap: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.detail-map-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.detail-description {
    font-size: 16px;
    line-height: 1.6;
    text-align: justify;
    word-wrap: break-word; /* Đảm bảo từ dài không tràn */
    overflow-wrap: break-word;
    white-space: pre-wrap; /* Giữ định dạng xuống dòng từ HTML */
    max-height: 50vh; /* Giới hạn chiều cao description, cho phép cuộn */
    overflow-y: auto;
    padding-right: 10px; /* Khoảng trống cho thanh cuộn */
}

/* Custom scrollbar */
.detail-description::-webkit-scrollbar {
    width: 8px;
}

.detail-description::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.detail-description::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.detail-description::-webkit-scrollbar-thumb:hover {
    background: #555;
}


.back-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

.back-button:hover {
    background-color: #5a6268;
}

/* Responsive cho Mobile */
@media (max-width: 768px) {
    .container {
        flex-direction: column; /* Đổi sang cột cho mobile */
        height: 100vh; /* Trở lại 100vh */
        padding: 10px;
    }

    .map-container {
        width: 100%;
        height: 60vh; /* Chiều cao cố định cho bản đồ trên mobile */
        flex-shrink: 0; /* Ngăn bản đồ bị co lại */
    }

    .map-list-container {
        width: 100%; /* Full width cho mobile */
        height: auto; /* Chiều cao tự động, cho phép cuộn độc lập */
        max-height: calc(100vh - 60vh - 20px); /* Chiều cao tối đa còn lại của màn hình */
        margin-top: 10px; /* Khoảng cách giữa bản đồ và danh sách */
    }

    .map-controls {
        bottom: 10px; /* Cách đáy 10px cho mobile */
        /* Giữ nguyên left: 50% và transform: translateX(-50%) */
    }

    .map-controls button {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .detail-content {
        padding: 15px;
        gap: 15px;
    }

    .detail-description {
        max-height: 40vh; /* Giới hạn chiều cao description trên mobile */
    }
}

/* Animation cho zoom in/out của detail view */
@keyframes zoomOutFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomInFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}