/* CSS tùy chỉnh cho trang bản đồ */
body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#map {
    height: 100vh;
    width: calc(100% - 300px);
    float: right;
    transition: width 0.3s;
}

#sidebar {
    width: 300px;
    height: 100vh;
    background: #ffffff;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1001;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #333;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

/* Custom scrollbar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.stats-section {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.stats-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 15px;
    color: #555;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-item span:last-child {
    font-weight: bold;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 13px;
}

/* Styling for headings inside accordion content, e.g., in Layer Management */
.accordion-content h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 10px;
    color: #6c757d;
    padding-bottom: 5px;
    border-bottom: 1px solid #f0f0f0;
}

.accordion-content h4:first-child {
    margin-top: 0;
}

.layer-toggle {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
}

.layer-toggle input {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: #007bff;
}

.layer-toggle label {
    cursor: pointer;
}

.accordion-item {
    border-bottom: 1px solid #e0e0e0;
}

.accordion-header {
    background: #f8f9fa;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #444;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background: #e9ecef;
}

.accordion-header .arrow {
    transition: transform 0.2s;
    font-family: monospace;
    font-weight: bold;
}

.accordion-header.active .arrow {
    transform: rotate(90deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
    background: #fff;
    padding: 0 15px;
}

.route-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.route-list li {
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.route-list li:last-child {
    border-bottom: none;
}

.route-list li:hover {
    background: #f1f1f1;
}

.sidebar-item-count {
    font-weight: bold;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 13px;
    color: #555;
    flex-shrink: 0;
    /* Ngăn huy hiệu bị co lại */
}

.toggle-btn {
    position: absolute;
    top: 0px;
    left: 300px;
    /* sidebar width + 10px */
    cursor: pointer;
    background: #007bff;
    color: white;
    padding: 6px 10px;
    border-radius: 0 5px 5px 0;
    z-index: 1002;
    transition: left 0.3s;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15);
}

.toggle-btn.sidebar-hidden {
    left: 0px;
}

.hidden {
    transform: translateX(-100%);
}

.legend-toggle-container {
    position: absolute;
    top: 40px; /* Đặt bên dưới nút ẩn/hiện sidebar */
    left: 300px;
    z-index: 1002;
    transition: left 0.3s;
}

.legend-toggle-container.sidebar-hidden {
    left: 0px;
}

.legend-toggle-button {
    list-style: none;
    padding: 0;
    margin: 0;
    border-radius: 0 5px 5px 0;
    background-color: rgba(0, 123, 255, 0.85); /* Giống màu nút toggle */
    color: white;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.legend-toggle-button li {
    padding: 6px 10px;
}

.legend-toggle-button li svg {
    display: block;
    width: 18px;
    height: 18px;
}

#map.map-expanded {
    width: 100% !important;
}

.search-bar {
    margin-bottom: 15px;
}

.search-bar input,
.search-bar select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.search-bar button {
    padding: 8px 12px;
    width: 100%;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s;
}

.search-bar button:hover {
    background-color: #218838;
}

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: block;
}

.map-controls>div:not(:last-child) {
    margin-bottom: 12px;
}

.map-controls ul {
    list-style: none;
    padding: 0;
    margin: 0;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background-color: rgba(255, 255, 255, 0.75);
    color: #333;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.map-controls li {
    cursor: pointer;
    padding: 8px;
    transition: background-color 0.2s, color 0.2s;
    border-bottom: 1px solid #ddd;
}

.map-controls li:last-child {
    border-bottom: none;
}

.map-controls li:hover {
    background-color: #f0f0f0;
}

.map-controls li.active {
    background-color: #007bff;
    color: white;
}

.map-controls li svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Custom Map Popup */
.leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 0;
    /* Remove default padding */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #fff;
}

.leaflet-popup-content {
    margin: 0 !important;
    /* Override leaflet's margin */
    width: 250px !important;
    /* Set a fixed width */
    line-height: 1.5;
}

.leaflet-popup-close-button {
    padding: 8px 8px 0 0 !important;
    color: #555 !important;
}

.map-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
}

.popup-image-container {
    width: 100%;
    height: 120px;
    overflow: hidden;
}

.popup-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    transition: transform 0.3s ease;
}

.popup-image-container:hover img {
    transform: scale(1.05);
}

.popup-content {
    padding: 15px;
}

.popup-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    color: #2c5282;
    /* A nice blue */
}

.popup-subtitle {
    font-size: 0.8rem;
    color: #718096;
    /* Grayish color */
    margin: 0 0 15px 0;
    font-weight: 500;
}

.popup-info-list {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    font-size: 0.9rem;
}

.popup-info-list li {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    color: #4a5568;
}

.popup-info-list li:last-child {
    margin-bottom: 0;
}

.popup-info-list li strong {
    color: #2d3748;
}

.popup-button {
    display: block;
    width: 100%;
    padding: 8px;
    background-color: #28a745;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background-color 0.2s;
    box-sizing: border-box;
}

.popup-button:hover {
    background-color: #218838;
    color: white;
}

/* Add a bit of styling for icons inside popups */
.popup-info-list li .icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    opacity: 0.7;
}

.route-popup-station-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* --- Legend Styles --- */
.info.legend {
    padding: 8px 12px;
    font: 14px/1.5 Arial, Helvetica, sans-serif;
    background: white;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    line-height: 24px;
    color: #333;
}

.legend h4 {
    margin: 0 0 8px;
    color: #000;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.legend .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.legend .legend-symbol {
    width: 22px;
    height: 22px;
    margin-right: 8px;
    display: inline-block;
}

.legend .legend-symbol img {
    width: 100%;
    height: 100%;
}

/* Kiểu mới để căn giữa chú giải */
.map-center-legend {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000; /* Đảm bảo chú giải nằm trên các lớp bản đồ */
}

/* Alpine.js cloak to prevent flash of unstyled content */
[x-cloak] {
    display: none !important;
}
/* === CSS CHO POPUP CHUYÊN NGHIỆP === */

/* Tăng chiều rộng và tùy chỉnh khung popup mặc định của Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: 12px; /* Bo góc mềm mại hơn */
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    background: #fdfdfd;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: 340px !important; /* Tăng chiều rộng của popup */
}

/* Bỏ padding mặc định và áp dụng padding riêng */
.map-popup.professional-popup .popup-content {
    padding: 15px;
}

/* Tiêu đề chính của popup */
.map-popup.professional-popup .popup-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: #2c3e50; /* Màu xanh đen */
}

/* Tiêu đề phụ (mã cây) */
.map-popup.professional-popup .popup-subtitle {
    font-size: 0.85rem;
    color: #7f8c8d; /* Màu xám */
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #ecf0f1; /* Đường kẻ ngang mờ */
    padding-bottom: 10px;
}

/* Lưới chứa các thông tin chi tiết */
.popup-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Layout 2 cột */
    gap: 12px; /* Khoảng cách giữa các mục */
    margin-bottom: 18px;
}

/* Mỗi mục thông tin trong lưới */
.popup-details-grid .detail-item {
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}

/* Mục chiếm toàn bộ chiều rộng */
.popup-details-grid .detail-item.full-width-item {
    grid-column: 1 / -1; /* Trải dài trên cả 2 cột */
}

/* Nhãn của thông tin (vd: Chiều cao cây) */
.popup-details-grid .detail-label {
    color: #34495e;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

/* Giá trị của thông tin */
.popup-details-grid .detail-value {
    color: #27ae60; /* Màu xanh lá cây */
    font-weight: 700;
    font-size: 1rem;
}

/* Nút "Xem chi tiết" */
.map-popup.professional-popup .popup-button {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #3498db; /* Màu xanh dương */
    color: white;
    padding: 10px 0;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.map-popup.professional-popup .popup-button:hover {
    background-color: #2980b9;
    transform: translateY(-2px); /* Hiệu ứng nhấc lên khi hover */
}
