/**
 * ShareSphere - Map Styles
 * 
 * Overrides for Leaflet + custom markers, popups, search results map, clusters.
 * Requires: leaflet.css loaded before this file.
 */

/* ============================================================
   MAP CONTAINER
   ============================================================ */

.map-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-gray-200);
    background: var(--color-gray-100);
}

.map-container--full {
    height: 500px;
}
.map-container--half {
    height: 360px;
}
.map-container--small {
    height: 240px;
}
.map-container--detail {
    height: 300px;
    border-radius: var(--radius-lg);
}

/* Search results split view: map on right */
.search-map {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    height: calc(100vh - var(--header-height) - var(--space-8));
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-gray-200);
}

/* Noscript fallback */
.map-noscript {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--color-gray-100);
    color: var(--color-gray-500);
    font-size: var(--font-size-sm);
}


/* ============================================================
   LEAFLET OVERRIDES
   ============================================================ */

/* Clean up default Leaflet controls */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius) !important;
    overflow: hidden;
}
.leaflet-control-zoom a {
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 16px !important;
    color: var(--color-gray-700) !important;
    background: var(--color-white) !important;
    border-bottom: 1px solid var(--color-gray-200) !important;
}
.leaflet-control-zoom a:hover {
    background: var(--color-gray-50) !important;
}
.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

/* Attribution */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75) !important;
    font-size: 10px !important;
    padding: 2px 6px !important;
    border-radius: var(--radius-sm) 0 0 0 !important;
}


/* ============================================================
   CUSTOM MARKERS
   ============================================================ */

.marker {
    position: relative;
    cursor: pointer;
}

.marker__pin {
    width: 36px;
    height: 46px;
    position: relative;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}
.marker__pin:hover {
    transform: scale(1.15);
}
.marker__pin svg {
    width: 100%;
    height: 100%;
    display: block;
}
.marker__pin-inner {
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 15px;
    line-height: 26px;
}

/* Color variants - fill applied via inline SVG fill attribute */
.marker__pin--selected {
    transform: scale(1.25);
}
.marker__pin--selected:hover {
    transform: scale(1.35);
}

/* Price marker (used in search results) */
.marker-price {
    background: var(--color-white);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all 0.2s ease;
}
.marker-price:hover {
    background: var(--color-primary);
    color: var(--color-white);
}
.marker-price.is-active {
    background: var(--color-primary);
    color: var(--color-white);
    transform: scale(1.1);
    z-index: 10 !important;
}

/* User location marker */
.marker-user {
    width: 20px;
    height: 20px;
    background: var(--color-info);
    border: 3px solid var(--color-white);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3), var(--shadow);
}


/* ============================================================
   POPUPS
   ============================================================ */

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
    overflow: hidden;
}
.leaflet-popup-content {
    margin: 0 !important;
    min-width: 240px;
    max-width: 300px;
}
.leaflet-popup-tip {
    box-shadow: none !important;
}

/* Custom popup content */
.map-popup {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
}
.map-popup__image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}
.map-popup__body {
    padding: var(--space-3);
}
.map-popup__category {
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: var(--space-1);
}
.map-popup__title {
    font-weight: 700;
    color: var(--color-gray-900);
    margin-bottom: var(--space-1);
}
.map-popup__title a {
    color: inherit;
}
.map-popup__title a:hover { color: var(--color-primary); }
.map-popup__rating {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-accent);
    margin-bottom: var(--space-1);
}
.map-popup__price {
    font-weight: 700;
    color: var(--color-gray-900);
}
.map-popup__distance {
    color: var(--color-gray-500);
    font-size: var(--font-size-xs);
}
.leaflet-popup-close-button {
    width: 28px !important;
    height: 28px !important;
    font-size: 18px !important;
    padding: 4px !important;
    color: var(--color-gray-500) !important;
}
.leaflet-popup-close-button:hover {
    color: var(--color-gray-800) !important;
}


/* ============================================================
   MARKER CLUSTERS
   ============================================================ */

.marker-cluster {
    border-radius: var(--radius-full);
    text-align: center;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--color-white);
}
.marker-cluster--small {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    background: rgba(79, 70, 229, 0.8);
}
.marker-cluster--medium {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    background: rgba(79, 70, 229, 0.7);
}
.marker-cluster--large {
    width: 52px !important;
    height: 52px !important;
    line-height: 52px !important;
    background: rgba(79, 70, 229, 0.6);
}


/* ============================================================
   MAP SEARCH BOX (geocoding)
   ============================================================ */

.map-search {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    right: var(--space-3);
    z-index: 1000;
    max-width: 360px;
}
.map-search__input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-left: 36px;
    font-size: var(--font-size-sm);
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    outline: none;
}
.map-search__input:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--color-primary-bg);
}
.map-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gray-400);
    font-size: 14px;
    pointer-events: none;
}

/* Geocoding suggestions dropdown */
.map-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: var(--space-1);
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}
.map-suggest.is-open { display: block; }

.map-suggest__item {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--color-gray-50);
}
.map-suggest__item:hover,
.map-suggest__item.is-active {
    background: var(--color-primary-bg);
}
.map-suggest__item:last-child { border-bottom: none; }


/* ============================================================
   RADIUS CIRCLE
   ============================================================ */

.leaflet-radius-circle {
    fill: var(--color-primary);
    fill-opacity: 0.08;
    stroke: var(--color-primary);
    stroke-width: 2;
    stroke-dasharray: 6, 4;
    stroke-opacity: 0.4;
}


/* ============================================================
   MAP SECTION (homepage)
   ============================================================ */

.map-section {
    padding: 3rem 0;
    background: var(--color-gray-50, #f8f9fa);
}

.map-section__header {
    text-align: center;
    margin-bottom: 2rem;
}

.map-section__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-gray-900, #1a1a2e);
    margin: 0 0 0.5rem;
}

.map-section__subtitle {
    font-size: 1rem;
    color: var(--color-gray-500, #6b7280);
    margin: 0;
}


/* ============================================================
   LOCALE BADGE (country indicator overlay)
   ============================================================ */

.map-locale-badge {
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.map-locale-badge__flag {
    font-size: 1.1rem;
    line-height: 1;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .map-container--full { height: 350px; }
    .map-container--half { height: 280px; }

    .search-map {
        position: relative;
        top: auto;
        height: 300px;
        margin-bottom: var(--space-4);
    }

    .map-search { max-width: 100%; }
}