/* d:\dung_chung\phuquy_travel\static\css\map_core.css */

/* --- 1. MAP CONTAINER --- */
.map-container-full {
    width: 100%;
    height: 100%;
    background-color: #e5e7eb;
    position: relative;
    overflow: hidden;
}

/* --- 2. CUSTOM CONTROLS (Nút bấm) --- */
.map-custom-controls {
    position: absolute;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    right: 10px;
    bottom: 100px; /* Mặc định cho Mobile */
    align-items: flex-end; /* [FIX] Đảm bảo các nút luôn căn phải */
    transition: all 0.3s ease;
}

@media (min-width: 768px) {
    .map-custom-controls {
        bottom: 95px;
        right: 20px;
    }
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background-color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    transition: all 0.2s;
    border: 1px solid #f3f4f6;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}
.map-control-btn:hover {
    color: #2563eb; /* Primary Blue */
    background-color: #f9fafb;
    transform: scale(1.05);
}
.map-control-btn.active {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

/* [NEW] Style cho nút Reset North */
#btn-reset-north {
    background-color: rgba(255, 255, 255, 0.95);
}

/* [NEW] Các trạng thái của nút My Location */
#btn-my-location.mode-tracking {
    color: #2563eb; /* Xanh dương */
    background-color: #eff6ff;
    border-color: #bfdbfe;
}
#btn-my-location.mode-compass {
    background-color: rgba(37, 99, 235, 0.85); /* [UPDATE] Nền xanh trong suốt */
    backdrop-filter: blur(4px); /* [NEW] Hiệu ứng mờ nền */
    color: white;
    border-color: rgba(29, 78, 216, 0.5);
}

/* [NEW] Wrapper cho icon la bàn để xoay */
.compass-icon-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s linear; /* Xoay mượt mà */
}

/* [NEW] Map Tools Wrapper (Container cho nút toggle và list ngang) */
.map-tools-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* [NEW] Map Tools Group (Menu con) */
.map-tools-list {
    display: none; /* Ẩn mặc định */
    flex-direction: row; /* [UPDATE] Mở ngang */
    gap: 8px;
    margin-bottom: 0;
    animation: slideLeftFade 0.2s ease-out;
}
.map-tools-list.show {
    display: flex;
}
@keyframes slideLeftFade {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* [NEW] Toggle Button Active State */
#btn-tools-toggle.active {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

/* [NEW] Offline Badge & Button */
#btn-save-offline {
    color: #059669; /* Green */
}
.offline-badge {
    background-color: #fee2e2;
    color: #dc2626;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid #fecaca;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* [NEW] Share Location Button */
#btn-share-location {
    color: #8b5cf6; /* Violet */
}

/* [NEW] Measure Button */
#btn-measure {
    color: #f59e0b; /* Amber */
}
/* Khi đang đo, đổi con trỏ chuột */
.map-measuring .gm-style {
    cursor: crosshair !important;
}

/* --- 3. USER LOCATION MARKER (Chấm xanh) --- */
.user-location-dot {
    width: 18px; height: 18px;
    background-color: #2563eb;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
    animation: pulse-blue 2s infinite;
}
@keyframes pulse-blue {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* [NEW] Navigation Arrow Marker (Mũi tên dẫn đường 3D) */
.nav-arrow-marker {
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    /* [UPDATE] Hiệu ứng trong suốt tinh tế (Glassmorphism) */
    background-color: rgba(37, 99, 235, 0.85); 
    backdrop-filter: blur(4px);
    border: 2px solid rgba(255, 255, 255, 0.6); /* Viền trắng mờ */
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease;
}
.arrow-shape {
    width: 20px; height: 20px;
    background-color: white;
    /* Tạo hình mũi tên dẫn đường hiện đại (Delta Wing) */
    clip-path: polygon(50% 0%, 0% 100%, 50% 80%, 100% 100%);
    transform-origin: center center;
    z-index: 2;
    margin-top: 2px; /* Căn chỉnh nhẹ */
}
/* --- 4. INFOWINDOW (Popup) --- */
.gm-style-iw { padding: 0 !important; }
.gm-style-iw-c {
    padding: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
    max-width: 320px !important;
}
.gm-style-iw-d { overflow: hidden !important; padding: 0 !important; max-height: none !important; }
.gm-style-iw-ch { padding: 0 !important; margin: 0 !important; height: 0 !important; overflow: visible !important; }

.custom-iw-content {
    padding: 16px;
    padding-top: 12px;
    padding-right: 30px; /* Chừa chỗ cho nút đóng */
}

/* [NEW] Ẩn hoàn toàn InfoWindow (Popup) khi đang dẫn đường */
body.nav-mode-active .gm-style-iw,
body.nav-mode-active .gm-style-iw-c,
body.nav-mode-active .gm-style-iw-t,
body.nav-mode-active .gm-style-iw-d {
    display: none !important;
}

/* Nút đóng Popup */
.gm-ui-hover-effect {
    position: absolute !important;
    top: 6px !important;
    right: 6px !important;
    background: rgba(0,0,0,0.05) !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    opacity: 0.6 !important;
    margin: 0 !important;
}
.gm-ui-hover-effect:hover { opacity: 1 !important; background: rgba(0,0,0,0.1) !important; }
.gm-ui-hover-effect > span { margin: 0 !important; width: 100% !important; height: 100% !important; display: block !important; }

/* --- 5. DIRECTIONS PANEL (Bảng chỉ đường) --- */
.directions-panel-container {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 340px;
    max-width: calc(100% - 20px);
    max-height: calc(100% - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.directions-panel-container.hidden { display: none !important; }

/* [NEW] Styles khi đang mở bảng chỉ đường (Directions Open) */
body.directions-open .navbar,               /* Ẩn Navbar chính */
body.directions-open .map-filter-bar-container, /* Ẩn thanh lọc (Location List) */
body.directions-open .floating-header,      /* Ẩn nút Back/Dropdown (Itinerary) */
body.directions-open #radius-filter-container /* Ẩn lọc bán kính */
{
    display: none !important;
}

/* Đẩy bảng chỉ đường lên sát mép trên khi các thanh khác đã ẩn */
body.directions-open .directions-panel-container {
    top: 10px !important;
    max-height: 60vh !important; /* Tăng chiều cao hiển thị */
}

/* Header của bảng chỉ đường */
.directions-header {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.btn-start-nav {
    background: #2563eb;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}
.btn-start-nav:hover { background: #1d4ed8; }

.header-tools { display: flex; align-items: center; gap: 4px; }
.tool-separator { width: 1px; height: 20px; background-color: #e5e7eb; margin: 0 6px; }

.btn-icon-tool {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon-tool:hover { background-color: #f3f4f6; color: #111827; }
.btn-close-red:hover { background-color: #fee2e2; color: #dc2626; }

#google-directions-content {
    overflow-y: auto;
    flex: 1;
    padding: 0;
    background: #f9fafb;
}
/* Tùy chỉnh nội dung Google trả về */
#google-directions-content .adp-warnbox { display: none; }
#google-directions-content .adp-text { padding: 12px 16px; font-size: 0.9rem; border-bottom: 1px solid #f3f4f6; background: white; }
#google-directions-content .adp-step { padding: 10px 16px; border-bottom: 1px solid #f3f4f6; background: white; }
#google-directions-content .adp-substep { border-bottom: 1px solid #f9fafb; }

/* Trạng thái thu gọn */
.directions-panel-container.minimized {
    height: auto !important;
    max-height: none !important;
    width: auto !important;
    min-width: 0;
    border-radius: 12px;
}
.directions-panel-container.minimized #google-directions-content { display: none !important; }

/* --- 6. NAVIGATION MODE (Chế độ dẫn đường toàn màn hình) --- */
body.nav-mode-active .map-custom-controls,
body.nav-mode-active .mobile-booking-bar,
body.nav-mode-active header,
body.nav-mode-active nav,
body.nav-mode-active .navbar { display: none !important; }

/* [UPDATE] Ẩn bảng chỉ đường cũ vì đã có Bottom Sheet */
body.nav-mode-active .directions-panel-container {
    display: none !important;
}

/* Nút Thoát dẫn đường */
#exit-nav-btn { display: none; }
body.nav-mode-active #exit-nav-btn {
    display: flex;
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background-color: white;
    color: #dc2626;
    border: 1px solid #fee2e2;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* [NEW] Bảng hiển thị ETA (Thời gian dự kiến) */
.nav-eta-panel {
    position: fixed;
    bottom: 100px; /* Nằm trên nút Thoát */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 10px 25px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none; /* Mặc định ẩn */
    flex-direction: column;
    align-items: center;
    min-width: 160px;
    border: 1px solid rgba(255,255,255,0.5);
    text-align: center;
}

/* [NEW] Navigation Mode: My Location Button Transformation */
body.nav-mode-active .map-custom-controls {
    display: block !important; /* Giữ container trong DOM */
    pointer-events: none; /* Cho phép click xuyên qua vùng trống */
    bottom: 0 !important; right: 0 !important; left: 0 !important; top: 0 !important;
    width: 100%; height: 100%;
    padding: 0; margin: 0;
    z-index: 11000 !important; /* [FIX] Tăng z-index để nằm trên Map Container (9999) */
}

/* [FIX] Ẩn tất cả nút con trước... */
body.nav-mode-active .map-custom-controls > * {
    display: none !important;
}
/* [FIX] ...Sau đó hiện lại cụ thể nút Vị trí và Tìm kiếm */
body.nav-mode-active .map-custom-controls > #btn-my-location,
body.nav-mode-active .map-custom-controls > #itinerary-search-wrapper {
    display: flex !important;
    pointer-events: auto !important; /* [FIX] Đảm bảo nhận được sự kiện click */
}

body.nav-mode-active #btn-my-location {
    display: flex !important; /* Chỉ hiện nút Vị trí */
    pointer-events: auto;
    position: fixed;
    top: auto !important;
    bottom: 240px !important; /* [UPDATE] Hạ thấp do Bottom Sheet nhỏ lại */
    right: 20px;
    z-index: 10000;
    width: 50px; height: 50px; /* To hơn một chút */
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    border: 2px solid white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* [NEW] Mute Button (Navigation Mode) */
#btn-nav-mute {
    display: none;
}
body.nav-mode-active #btn-nav-mute {
    display: flex;
    position: fixed;
    top: auto !important;
    bottom: 130px !important; /* [UPDATE] Hạ thấp do Bottom Sheet nhỏ lại */
    right: 20px;
    z-index: 10000;
    width: 50px; height: 50px;
    background-color: white;
    color: #4b5563;
    border-radius: 50%;
    align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid #e5e7eb;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}
body.nav-mode-active #btn-nav-mute.muted {
    color: #ef4444;
    background-color: #fef2f2;
    border-color: #fee2e2;
}

/* [NEW] Speedometer Widget (Đồng hồ tốc độ) */
#nav-speed-display {
    position: fixed;
    top: auto !important;
    bottom: 130px !important; /* [UPDATE] Hạ thấp do Bottom Sheet nhỏ lại */
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 10px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none; /* Mặc định ẩn */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid #e5e7eb;
    min-width: 70px;
    transition: all 0.3s ease;
}
body.nav-mode-active #nav-speed-display { display: flex; }

#nav-speed-display .speed-value { font-size: 1.8rem; font-weight: 900; line-height: 1; color: #374151; }
#nav-speed-display .speed-unit { font-size: 0.7rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; margin-top: 2px; }

/* Cảnh báo tốc độ cao */
#nav-speed-display.speed-warning { border-color: #ef4444; background-color: #fef2f2; animation: pulse-red 1s infinite; }
#nav-speed-display.speed-warning .speed-value { color: #dc2626; }

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* [NEW] Styling for Google Directions Panel (Chi tiết chỉ đường) */
/* Ẩn các thành phần thừa của Google */
#google-directions-content .adp-warnbox, 
#google-directions-content .adp-legal,
#google-directions-content .adp-step-number { 
    display: none !important; 
}

/* Reset khung bao ngoài */
#google-directions-content .adp {
    background: transparent !important;
    font-family: inherit !important;
}
#google-directions-content .adp-list {
    border: none !important;
    background: transparent !important;
}

/* [FIX] Tinh chỉnh lại các hàng (Rows) để không bị vỡ khung Table */
#google-directions-content .adp-step, 
#google-directions-content .adp-substep {
    background: white;
    border-bottom: 1px solid #f3f4f6 !important;
    /* [FIX] Bỏ display:flex vì đây là thẻ tr của bảng, dùng flex sẽ vỡ layout */
    height: auto !important;
}

/* Style cho các ô (Cells) bên trong để tạo độ thoáng */
#google-directions-content .adp-step td {
    padding: 12px 10px !important;
    vertical-align: middle !important;
    font-size: 0.9rem;
    color: #374151;
}

/* Icon hướng đi (Cột trái) */
#google-directions-content .adp-maneuver {
    width: 24px !important;
    height: 24px !important;
    opacity: 0.8;
    background-size: contain !important;
    margin: 0 auto; /* Căn giữa icon trong ô */
}

/* Nội dung chỉ dẫn (Cột phải) */
#google-directions-content .adp-step-main {
    padding-left: 10px !important;
}

/* Khoảng cách (Distance) - Làm đẹp badge */
#google-directions-content .adp-distance {
    float: right; /* Đẩy sang phải */
    font-weight: 700;
    color: #2563eb;
    font-size: 0.8rem;
    background: #eff6ff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    white-space: nowrap;
}

/* --- [NEW] TOP NAVIGATION INSTRUCTIONS (Google Maps Style) --- */
.nav-top-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 11000; /* Cao hơn tất cả */
    display: none; /* Mặc định ẩn */
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* Để click xuyên qua vùng trống */
}
body.nav-mode-active .nav-top-panel { display: flex; }

.nav-instruction-card {
    background-color: #0F9D58; /* Google Green */
    color: white;
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    padding: 12px 15px; /* [OPTIMIZE] Giảm padding */
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center; /* [UPDATE] Căn giữa dọc cho đẹp */
    position: relative;
    z-index: 2;
    pointer-events: auto;
    gap: 15px; /* [NEW] Khoảng cách giữa 3 cột */
}

.nav-instruction-icon {
    font-size: 2rem; /* [OPTIMIZE] Giảm kích thước icon */
    min-width: 40px;
    text-align: center;
    flex-shrink: 0; /* Không bị co lại */
    margin: 0; /* Reset margin cũ */
}

.nav-instruction-dist {
    font-size: 1.5rem; /* [OPTIMIZE] Giảm kích thước chữ khoảng cách */
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0; /* Không bị co lại */
    min-width: 70px; /* Đảm bảo độ rộng cho số mét */
    text-align: center;
}

.nav-instruction-text {
    font-size: 1rem; /* [OPTIMIZE] Giảm kích thước chữ hướng dẫn */
    font-weight: 500;
    line-height: 1.2;
    white-space: normal;
    flex: 1; /* Chiếm phần không gian còn lại */
    border-left: 1px solid rgba(255,255,255,0.3); /* [NEW] Đường kẻ ngăn cách */
    padding-left: 15px;
}
/* Reset style mặc định của Google trong text */
.nav-instruction-text b { font-weight: 700; }
.nav-instruction-text div { display: inline; }

.nav-next-step-card {
    background-color: #00695C; /* Darker Green */
    color: rgba(255,255,255,0.9);
    width: 95%;
    max-width: 580px;
    border-radius: 0 0 12px 12px;
    padding: 6px 15px; /* [OPTIMIZE] Giảm padding */
    margin-top: -5px; /* Dính liền với thẻ trên */
    padding-top: 10px;
    display: flex;
    align-items: center;
    font-size: 0.85rem; /* [OPTIMIZE] Giảm font size */
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1;
    pointer-events: auto;
}
.nav-next-step-icon {
    margin-right: 10px;
    font-size: 0.9rem;
    min-width: 24px;
    text-align: center;
}

/* [NEW] Speedometer Widget (Đồng hồ tốc độ) */
#nav-speed-display {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 10px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none; /* Mặc định ẩn */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid #e5e7eb;
    min-width: 70px;
    transition: all 0.3s ease;
}
body.nav-mode-active #nav-speed-display { display: flex; }

#nav-speed-display .speed-value { font-size: 1.8rem; font-weight: 900; line-height: 1; color: #374151; }
#nav-speed-display .speed-unit { font-size: 0.7rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; margin-top: 2px; }

/* Cảnh báo tốc độ cao */
#nav-speed-display.speed-warning { border-color: #ef4444; background-color: #fef2f2; animation: pulse-red 1s infinite; }
#nav-speed-display.speed-warning .speed-value { color: #dc2626; }

/* [NEW] Global Offline Toast Notification */
.global-offline-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px); /* Ẩn bên trên */
    background-color: #374151; /* Dark Gray */
    color: white;
    padding: 10px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 12000; /* Cao hơn mọi thứ */
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}
.global-offline-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.global-offline-toast.is-online {
    background-color: #10b981; /* Green */
}
.global-offline-toast i {
    font-size: 1.1rem;
}

/* --- LEAFLET CUSTOM OVERRIDES & POPUPS --- */
.leaflet-container {
    font-family: inherit !important;
}

.leaflet-custom-popup .leaflet-popup-content-wrapper {
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 4px;
}

.leaflet-custom-popup .leaflet-popup-content {
    margin: 8px 12px;
    line-height: 1.4;
}

.leaflet-custom-popup .leaflet-popup-tip {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.custom-leaflet-marker, .custom-itinerary-marker-wrapper, .custom-search-marker {
    background: transparent !important;
    border: none !important;
}

