/* ==============================================
   MAP - Google Maps Container & Markers
   Airbnb-style modern styling
   ============================================== */

/* Map Container */
#searchMap {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border-radius: 0;
    background: #e5e3df;
}

.search-map-container {
    width: 100%;
    height: 100%;
    min-height: 400px;
    position: relative;
    background: #e5e3df;
}

/* Loading State */
.map-loading-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f5f5f5;
    z-index: 10;
}

.map-loading-state .spinner-border {
    width: 40px;
    height: 40px;
    border-width: 3px;
    color: #ff385c;
}

/* Custom Google Maps Styling */
.gm-style {
    font-family: inherit !important;
}

/* Hide default Google UI elements we don't need */
.gm-style-cc,
.gm-svpc {
    display: none !important;
}

/* Custom Zoom Controls styling */
.gm-bundled-control {
    margin: 12px !important;
}

.gm-bundled-control button {
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

/* Info Window Styling — do NOT override position, let Google Maps control placement */
.gm-style-iw {
    border-radius: 14px !important;
    padding: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
    background: transparent !important;
    max-width: 320px !important;
}

.gm-style-iw-d {
    overflow: visible !important;
    max-height: none !important;
    padding: 0 !important;
    max-width: 320px !important;
}

.gm-style-iw-c {
    padding: 0 !important;
    border-radius: 14px !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    max-width: 320px !important;
}

.gm-style-iw-t::after,
.gm-style-iw-tc {
    display: none !important;
}

/* Close Button */
.gm-ui-hover-effect {
    position: absolute !important;
    top: 6px !important;
    right: 6px !important;
    width: 30px !important;
    height: 30px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    opacity: 1 !important;
    z-index: 100 !important;
    cursor: pointer !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.gm-ui-hover-effect:hover {
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2) !important;
    transform: scale(1.05) !important;
}

.gm-ui-hover-effect > span {
    background-color: #222 !important;
    margin: 9px !important;
    width: 12px !important;
    height: 12px !important;
}

/* ==============================================
   SEARCH MAP POPUP CARD
   ============================================== */

/* Popup entrance animation */
@keyframes searchPopupSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-map-popup {
    width: 300px;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 6px 14px rgba(0, 0, 0, 0.1),
        0 16px 32px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: searchPopupSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.search-map-popup__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.search-map-popup__link:hover .search-map-popup {
    transform: translateY(-3px);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 8px 18px rgba(0, 0, 0, 0.12),
        0 20px 40px rgba(0, 0, 0, 0.18);
}

/* Image Container */
.search-map-popup__image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.search-map-popup__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    image-rendering: auto;
}

.search-map-popup__image.loaded {
    opacity: 1;
}

.search-map-popup__link:hover .search-map-popup__image {
    transform: scale(1.06);
}

/* Gradient Overlay */
.search-map-popup__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.03) 0%,
        transparent 35%,
        transparent 45%,
        rgba(0, 0, 0, 0.55) 80%,
        rgba(0, 0, 0, 0.8) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* Badge */
.search-map-popup__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.search-map-popup__badge--short_term {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.7), rgba(180, 140, 30, 0.7));
}

.search-map-popup__badge--long_term {
    background: linear-gradient(135deg, rgba(12, 35, 64, 0.7), rgba(20, 50, 90, 0.7));
}

/* Content Overlay (over image) */
.search-map-popup__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    padding: 12px 14px;
    color: #fff;
}

.search-map-popup__title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 3px;
    line-height: 1.25;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-map-popup__location {
    font-size: 0.75rem;
    margin: 0 0 8px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.search-map-popup__location svg {
    flex-shrink: 0;
    opacity: 0.8;
}

/* Footer: Details + Price */
.search-map-popup__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.search-map-popup__details {
    display: flex;
    gap: 10px;
}

.search-map-popup__detail {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
}

.search-map-popup__detail svg {
    opacity: 0.75;
}

.search-map-popup__price {
    text-align: right;
}

.search-map-popup__price-amount {
    font-size: 1.1rem;
    font-weight: 800;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.search-map-popup__price-suffix {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Mobile Map adjustments */
@media (max-width: 768px) {
    #searchMap {
        border-radius: 0;
    }

    .gm-bundled-control {
        margin: 8px !important;
    }

    .gm-bundled-control-on-bottom {
        right: 8px !important;
        bottom: 60px !important;
    }

    .search-map-popup {
        width: 260px;
    }

    .search-map-popup__image-container {
        height: 170px;
    }

    .search-map-popup__title {
        font-size: 0.9rem;
    }

    .gm-ui-hover-effect {
        width: 34px !important;
        height: 34px !important;
    }
}

/* Dark Mode */
[data-theme="dark"] .map-loading-state {
    background: #2a2a2a;
}

[data-theme="dark"] .search-map-popup {
    background: #1a1a1a;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 8px 20px rgba(0, 0, 0, 0.4),
        0 20px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .search-map-popup__image-container {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
}

[data-theme="dark"] .gm-ui-hover-effect {
    background: rgba(30, 30, 30, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .gm-ui-hover-effect > span {
    background-color: #fff !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .search-map-popup,
    .search-map-popup__image {
        transition: none;
        animation: none;
    }
    .search-map-popup__link:hover .search-map-popup {
        transform: none;
    }
    .search-map-popup__link:hover .search-map-popup__image {
        transform: none;
    }
}

/* Focus states for accessibility */
.search-map-popup__link:focus-visible {
    outline: 3px solid #d4af37;
    outline-offset: 3px;
    border-radius: 14px;
}

/* Ensure InfoWindow content is not clipped */
.gm-style-iw-d > div {
    overflow: visible !important;
    max-width: 320px !important;
}