/* =============================================================
   public-map.css — Trang Bản đồ Du lịch Public
   ============================================================= */

/* ---- Biến màu & chủ đề ---- */
:root {
    --map-sidebar-width: 280px;
    --map-sidebar-bg: #ffffff;
    --map-sidebar-border: #e8eaed;
    --map-filter-active-bg: #f0f7ff;
    --map-filter-active-border: #1a73e8;
    --map-accent: #1a73e8;
    --map-accent-hover: #1557b0;
    --map-text-primary: #212529;
    --map-text-secondary: #6c757d;
    --map-shadow-panel: 0 2px 16px rgba(0,0,0,0.10);
    --map-radius: 12px;
    --map-transition: 0.25s ease;

    /* Badge màu theo loại */
    --color-luutru: #F4A261;
    --color-anuong: #E76F51;
    --color-diemthamquan: #2A9D8F;
    --color-cosodichvu: #457B9D;
    --color-luhanh: #6A0572;
    --color-vanchuyen: #3D405B;

    /* Popup header gradient theo Figma */
    --map-popup-gradient-from: #4f46e5;
    --map-popup-gradient-to: #7c3aed;
}

/* ---- Layout tổng thể ---- */
.map-page {
    display: flex;
    position: relative;
    height: calc(100vh - 72px);
    overflow: hidden;
}

/* ---- Panel lọc bên trái ---- */
.map-filter-panel {
    width: var(--map-sidebar-width);
    background: var(--map-sidebar-bg);
    border-right: 1px solid var(--map-sidebar-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--map-shadow-panel);
    z-index: 500;
    overflow-y: auto;
    transition: transform var(--map-transition), width var(--map-transition);
    flex-shrink: 0;
}

.map-filter-panel.is-hidden {
    transform: translateX(-100%);
    width: 0;
    overflow: hidden;
    border: none;
}

.map-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--map-sidebar-border);
}

.map-filter-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--map-text-primary);
    letter-spacing: 0.01em;
}

.map-filter-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--map-text-secondary);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background var(--map-transition);
}

.map-filter-close:hover {
    background: #f1f3f4;
    color: var(--map-text-primary);
}

/* ---- Danh sách filter ---- */
.map-filter-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.map-filter-item {
    transition: background var(--map-transition);
}

/* .map-filter-item + .map-filter-item {
    border-top: 1px solid #f1f3f4;
}
 */
.map-filter-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background var(--map-transition);
    border-radius: 0;
    margin: 0;
}

.map-filter-label:hover {
    background: #f8f9fa;
}

/* Khi checkbox được check */
.map-filter-checkbox:checked ~ .map-filter-name {
    color: var(--map-accent);
    font-weight: 600;
}

.map-filter-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--map-accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ---- Icon vòng tròn màu ---- */
.map-filter-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    flex-shrink: 0;
}

/* .map-filter-icon-wrap--luutru  { background: rgba(244,162,97,0.15); }
.map-filter-icon-wrap--anuong  { background: rgba(231,111,81,0.15); }
.map-filter-icon-wrap--diemthamquan { background: rgba(42,157,143,0.15); }
.map-filter-icon-wrap--cosodichvu { background: rgba(69,123,157,0.15); }
.map-filter-icon-wrap--luhanh  { background: rgba(106,5,114,0.12); }
.map-filter-icon-wrap--vanchuyen { background: rgba(61,64,91,0.12); }
.map-filter-icon-wrap--all     { background: rgba(26,115,232,0.12); } */

.map-filter-icon {
/*     width: 20px;
    height: 20px; */
    object-fit: contain;
}

.map-filter-name {
    flex: 1;
    font-size: 13.5px;
    color: var(--map-text-primary);
    transition: color var(--map-transition);
}

.map-filter-count {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--map-accent);
    border-radius: 20px;
    padding: 1px 8px;
    min-width: 24px;
    text-align: center;
}

.map-filter-item--all .map-filter-count {
    background: #6c757d;
}

/* ---- Nút toggle (hiện khi panel ẩn) ---- */
.map-filter-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--map-sidebar-border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    width: 32px;
    height: 56px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 0 4px rgba(33,37,41,0.12);
    color: var(--map-text-primary);
    transition: background var(--map-transition);
}

.map-filter-toggle:hover {
    background: #f8f9fa;
}

.map-filter-toggle.is-visible {
    display: flex;
}

/* ---- Container bản đồ ---- */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

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

/* ---- Loading Overlay ---- */
.map-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 900;
    gap: 14px;
    transition: opacity 0.3s ease;
}

.map-loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e8eaed;
    border-top-color: var(--map-accent);
    border-radius: 50%;
    animation: map-spin 0.7s linear infinite;
}

.map-loading-text {
    font-size: 14px;
    color: var(--map-text-secondary);
    font-weight: 500;
}

@keyframes map-spin {
    to { transform: rotate(360deg); }
}

/* ---- Leaflet Search Control ---- */
.map-search-control {
    background: #fff;
    width: 400px;
    border: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: none !important;
    border-radius: 24px;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.20) !important;
}

.map-search-wrapper {
    position: relative;
    width: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 12px 24px;
    box-sizing: border-box;
}

.map-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 400;
    background: transparent;
    color: #212529;
    letter-spacing: 0.5px;
    font-family: 'Roboto', sans-serif;
}

.map-search-input::placeholder {
    color: #adb5bd;
}

/* Icon kính lúp bên PHẢI */
.map-search-icon {
    flex-shrink: 0;
    color: #9ca3af;
    display: flex;
    margin-left: 8px;
}

.map-search-results {
    display: none;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid #e5e7eb;
}

.map-search-results.is-visible {
    display: block;
}

.map-search-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.map-search-result-item:hover {
    background: #f8f9fa;
}

.map-search-result-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.map-search-result-text {
    flex: 1;
    margin: 0;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-search-result-name {
    color: #212529;
}

.map-search-result-address {
    color: #a6a8a9;
    margin-left: 4px;
}

.map-search-no-result {
    padding: 14px 12px;
    text-align: center;
    color: var(--map-text-secondary);
    font-size: 13px;
}

/* ---- Leaflet Popup Card ---- */
/* Theo Figma: có header gradient tím với logo "HỆ THỐNG DỮ LIỆU MỞ" */
.map-popup {
    font-family: inherit;
    min-width: 240px;
    max-width: 300px;
}

/* Header gradient theo Figma */
.map-popup-header {
    background: linear-gradient(135deg, var(--map-popup-gradient-from), var(--map-popup-gradient-to));
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-popup-header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.20);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.map-popup {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.map-popup-image-wrapper {
    height: 125px;
    width: 100%;
}

.map-popup-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #f1f3f4;
}

.map-popup-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.map-popup-name {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #212529;
    letter-spacing: 0.15px;
    line-height: 24px;
    margin: 0 !important;
    padding-right: 48px; /* space for directions button */
    word-break: break-word;
}

.map-popup-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-popup-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.map-popup-review {
    gap: 4px;
}

.map-popup-star-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-popup-rating-score,
.map-popup-rating-count,
.map-popup-type,
.map-popup-address {
    font-family: 'Roboto', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #4d5154;
    letter-spacing: 0.4px;
    line-height: 16px;
    margin: 0;
}

.map-popup-status {
    font-family: 'Roboto', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #1447e6;
    letter-spacing: 0.4px;
    line-height: 16px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-popup-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #d1d5db;
    margin: 0 4px;
    flex-shrink: 0;
}

.map-popup-group {
    flex-wrap: wrap;
    gap: 0;
}

.map-popup-address-row {
    margin-top: 0;
}

.map-popup-address-row svg {
    flex-shrink: 0;
    color: #4d5154;
}

.map-popup-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.map-popup-btn-direction {
    background-color: #ede9fe;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    color: #7008E7;
}

.map-popup-btn-direction:hover {
    background-color: #ddd6fe;
}

.leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 300px;
}

.leaflet-popup-tip-container {
    margin-top: -1px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .map-page {
        height: calc(100vh - 56px);
    }

    .map-filter-panel {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1001; /* Increase from 900 to 1001 to cover Leaflet search control (z-index 1000) */
        box-shadow: 4px 0 20px rgba(0,0,0,0.18);
    }

    .map-filter-panel.is-hidden {
        transform: translateX(-100%);
        width: var(--map-sidebar-width);
    }

    .map-filter-toggle.is-visible {
        display: flex;
    }

    .map-search-control {
        width: calc(100vw - 32px);
        margin: 16px;
    }
    
    .leaflet-control-zoom {
        margin-bottom: 80px !important;
        margin-right: 16px !important;
    }
    
    .map-gps-btn {
        display: flex;
        position: absolute;
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        z-index: 1000;
        align-items: center;
        justify-content: center;
        border: none;
        color: #212529;
        cursor: pointer;
    }
}

.map-gps-btn {
    display: none; /* Only show on mobile, or based on media query */
}

/* ---- Di chuyển Leaflet zoom controls về góc phải dưới (theo Figma) ---- */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14) !important;
    border-radius: 10px !important;
    overflow: hidden;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background: #fff !important;
    color: var(--map-text-primary) !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 34px !important;
    width: 34px !important;
    height: 34px !important;
    border: none !important;
    transition: background var(--map-transition) !important;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: #f8f9fa !important;
    color: var(--map-accent) !important;
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid #e8eaed !important;
}

/* Ẩn zoom mặc định ở góc trái để JS tạo lại ở góc phải dưới */
.leaflet-top.leaflet-left .leaflet-control-zoom {
    display: none;
}

/* Override footer margin cho trang b?n d? */
.plantrip-footer { margin-top: 0 !important; }

/* Remove breadcrumb and footer margin on map layout */
.dss-breadcrumb-wrapper { display: none !important; }
.plantrip-footer { margin-top: 0 !important; }
