/* ===================================================================
   BẢN ĐỒ (MAP) PAGE SPECIFIC STYLES
   =================================================================== */

.map-page .main-content {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#main-map {
    width: 100%;
    flex: 1;
    z-index: 1;
}

.map-overlay {
    position: absolute;
    top: 100px;
    right: 20px;
    z-index: 1000;
    width: 320px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.map-overlay.hidden {
    transform: translateX(350px);
    opacity: 0;
    pointer-events: none;
}

.map-search-card {
    background: var(--bg-card) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.custom-marker i {
    transform: rotate(45deg);
    font-size: 1.2rem;
    color: #fff;
}
.marker-temple { background: linear-gradient(135deg, #ca8a04, #eab308); }
.marker-birthplace { background: linear-gradient(135deg, #16a34a, #4ade80); }
.marker-grave { background: linear-gradient(135deg, #475569, #94a3b8); }
.marker-landmark { background: linear-gradient(135deg, #2563eb, #60a5fa); }

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.2);
    z-index: 1000 !important;
}

.map-controls-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1001;
    display: flex;
    gap: 10px;
}

.map-ctrl-btn {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.3rem;
    transition: var(--transition-base);
    box-shadow: var(--shadow-md);
}

.map-ctrl-btn:hover {
    background: var(--primary-main);
    border-color: var(--primary-light);
    color: #fff;
}

.admin-controls {
    display: none; /* Shown if isOwner */
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.btn-edit-mode {
    width: 100%;
    background: var(--primary-main);
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-base);
}

.btn-edit-mode.active {
    background: #ef4444;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    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); }
}

.map-search-input {
    width: 100%;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 15px;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
}

.site-list {
    max-height: 350px;
    overflow-y: auto;
    margin-top: 15px;
}

.site-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-base);
    margin-bottom: 5px;
}

.site-item:hover {
    background: rgba(202, 160, 82, 0.1);
}

.site-icon {
    width: 40px;
    height: 40px;
    background: rgba(202, 160, 82, 0.15);
    color: var(--text-gold);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.site-info h4 { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--text-main); }
.site-info p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }

.popup-card { min-width: 220px; padding: 5px; }
.popup-card h3 { color: var(--text-gold); margin: 0 0 8px; font-size: 1.1rem; }
.popup-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }

/* Routing Machine Customization */
.leaflet-routing-container {
    background: var(--bg-card) !important;
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    border-radius: 15px !important;
    padding: 10px !important;
    font-family: inherit !important;
    max-width: 320px !important;
    max-height: calc(100vh - 180px) !important; /* Prevent going off screen */
    overflow-y: auto !important;
    box-shadow: var(--shadow-lg) !important;
    margin-top: 80px !important; /* Below top header */
    position: relative;
}
.leaflet-routing-alt { color: var(--text-main) !important; }
.leaflet-routing-alt h2 { color: var(--text-gold) !important; font-size: 0.9rem !important; margin: 5px 0 !important; }
.leaflet-routing-alt h3 { color: var(--text-muted) !important; font-size: 0.8rem !important; }
.leaflet-routing-icon { filter: invert(1); } /* Make icons visible on dark */
:root.light-mode .leaflet-routing-icon { filter: none; }

/* Custom Close Button for Routing */
.routing-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--bg-glass);
    color: var(--text-main);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.routing-close-btn:hover { background: #ef4444; color: #fff; }

.btn-locate {
    background: var(--bg-dark);
    color: var(--text-gold);
    border: 1px solid var(--text-gold);
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    margin-bottom: 12px;
    width: 100%;
    justify-content: center;
    transition: all 0.2s;
}
.btn-locate:hover { background: var(--text-gold); color: #fff; }

.current-loc-marker {
    background: #2196f3;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.8);
}

.popup-actions { display: flex; flex-direction: column; gap: 8px; }

.popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-main);
    color: #fff !important;
    padding: 8px 15px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}
.popup-btn.nav-btn { background: rgba(33, 150, 243, 0.2); border: 1px solid #2196f3; color: #2196f3 !important; }
.popup-btn.nav-btn:hover { background: #2196f3; color: #fff !important; }

@media (max-width: 768px) {
    .map-overlay {
        top: auto;
        bottom: 110px;
        right: 10px;
        left: 10px;
        width: auto;
    }
    .map-overlay.hidden { transform: translateY(150%); }
    .site-list { max-height: 200px; }
}
