/* ─── Discovery Map Layout ─── */

.uce-map-discovery {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--uce-bg-primary, #fdf6e6);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(13,27,42,0.06);
}

.uce-map-discovery-body {
    display: flex;
    height: 570px;
    position: relative;
}

/* ─── Search Bar ─── */

.uce-map-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--uce-bg-secondary, #fdf6e6);
    border-bottom: 1px solid rgba(13,27,42,0.06);
    flex-wrap: nowrap;
}

.uce-map-search {
    position: relative;
    flex: 1;
    min-width: 200px;
    height: 40px;
    align-self: center;
}

.uce-map-search-inner {
    display: flex;
    background: rgba(13,27,42,0.06);
    border: 1px solid rgba(13,27,42,0.1);
    border-radius: 8px;
    height: 40px;
    box-sizing: border-box;
    position: relative;
    top: -8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.uce-map-search-inner:focus-within {
    border-color: var(--uce-gold, #6b1e3f);
    box-shadow: 0 0 0 2px rgba(107,30,63,0.12);
}

.uce-map-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    color: rgba(13,27,42,0.35);
}

#uce-map-search-input,
#uce-map-search-input:focus,
#uce-map-search-input:active {
    flex: 1;
    border: none !important;
    background: none !important;
    color: var(--uce-text-primary, #0d1b2a);
    font-size: 14px;
    padding: 0 12px 0 0;
    height: 100%;
    outline: none !important;
    box-shadow: none !important;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

#uce-map-search-input::placeholder {
    color: rgba(13,27,42,0.3);
}

#uce-map-search-clear {
    display: none;
    background: none;
    border: none;
    color: rgba(13,27,42,0.35);
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
}

#uce-map-search-clear:hover {
    color: var(--uce-text-primary, #0d1b2a);
}

#uce-map-search-btn {
    flex-shrink: 0;
    align-self: center;
    background: var(--uce-gold, #6b1e3f);
    color: #fdf6e6;
    border: none;
    border-radius: 8px;
    padding: 0 28px;
    height: 40px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
}

#uce-map-search-btn:hover {
    background: #8f2854;
}

/* Autocomplete */

#uce-map-autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--uce-bg-secondary, #fdf6e6);
    border: 1px solid rgba(13,27,42,0.1);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(13,27,42,0.08);
    max-height: 320px;
    overflow-y: auto;
}

.uce-map-ac-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(13,27,42,0.04);
}

.uce-map-ac-item:last-child {
    border-bottom: none;
}

.uce-map-ac-item:hover {
    background: rgba(13,27,42,0.06);
}

.uce-map-ac-label {
    color: var(--uce-text-primary, #0d1b2a);
    font-size: 13px;
    font-weight: 500;
}

.uce-map-ac-sub {
    color: rgba(13,27,42,0.35);
    font-size: 11px;
    margin-top: 2px;
}

.uce-map-ac-item--location .uce-map-ac-label::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--uce-gold, #6b1e3f);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* ─── Toolbar buttons ─── */

.uce-map-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#uce-map-filters-toggle,
#uce-map-locate-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(13,27,42,0.06);
    border: 1px solid rgba(13,27,42,0.1);
    color: var(--uce-text-secondary, #4a5568);
    border-radius: 8px;
    padding: 0 14px;
    height: 40px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
}

#uce-map-filters-toggle:hover,
#uce-map-locate-btn:hover {
    background: rgba(13,27,42,0.1);
    color: var(--uce-text-primary, #0d1b2a);
}

#uce-map-filters-toggle.is-active {
    border-color: var(--uce-gold, #6b1e3f);
    color: var(--uce-gold, #6b1e3f);
}

#uce-map-locate-btn.is-active {
    border-color: var(--uce-gold, #6b1e3f);
    color: var(--uce-gold, #6b1e3f);
}

#uce-map-locate-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ─── Filters Panel ─── */

#uce-map-filters {
    display: none;
    padding: 14px 16px;
    background: #ffffff;
    border-bottom: 1px solid rgba(13,27,42,0.1);
    border-top: 1px solid rgba(13,27,42,0.06);
    gap: 16px;
    flex-wrap: wrap;
}

#uce-map-filters.is-open {
    display: flex;
}

.uce-map-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.uce-map-filter-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a0aec0;
}

.uce-map-type-toggles {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.uce-map-type-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(13,27,42,0.15);
    background: rgba(13,27,42,0.04);
    color: #4a5568;
    transition: all 0.2s;
    user-select: none;
}

.uce-map-type-chip input {
    display: none;
}

.uce-map-type-chip .uce-map-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: opacity 0.2s;
    opacity: 0.4;
}

.uce-map-type-chip.is-checked {
    border-color: var(--chip-color, rgba(13,27,42,0.3));
    background: rgba(13,27,42,0.08);
    color: #0d1b2a;
}

.uce-map-type-chip.is-checked .uce-map-type-dot {
    opacity: 1;
}

.uce-map-filter-select {
    background: #f7f8fa;
    border: 1.5px solid rgba(13,27,42,0.15);
    color: #0d1b2a;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    min-width: 120px;
}

.uce-map-filter-select option {
    background: #ffffff;
    color: #0d1b2a;
}

.uce-map-filter-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
}

.uce-map-filter-check input {
    accent-color: var(--uce-gold, #6b1e3f);
}

/* Radius group */

#uce-map-radius-group {
    display: none;
    align-items: center;
    gap: 8px;
}

#uce-map-radius-group.is-visible,
#uce-map-radius-group:not([style*="display:none"]):not([style*="display: none"]) {
    display: flex;
}

#uce-map-radius {
    background: rgba(13,27,42,0.06);
    border: 1px solid rgba(13,27,42,0.1);
    color: var(--uce-text-primary, #0d1b2a);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    width: 90px;
}

#uce-map-radius option {
    background: #fdf6e6;
}

/* ─── Map Container ─── */

.uce-map-container {
    flex: 1;
    min-width: 0;
    position: relative;
}

#uce-discovery-map {
    width: 100%;
    height: 100%;
    background: #0d1a2e;
}

/* Loading overlay */

#uce-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 800;
    display: none;
    align-items: center;
    gap: 10px;
    background: rgba(10,22,40,0.92);
    border: 1px solid rgba(253,246,230,0.1);
    border-radius: 8px;
    padding: 12px 20px;
    color: rgba(253,246,230,0.7);
    font-size: 13px;
}

#uce-map-loading.is-visible {
    display: flex;
}

.uce-map-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(13,27,42,0.15);
    border-top-color: var(--uce-gold, #6b1e3f);
    border-radius: 50%;
    animation: uceMapSpin 0.7s linear infinite;
}

@keyframes uceMapSpin {
    to { transform: rotate(360deg); }
}

/* Notice */

#uce-map-notice {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 800;
    background: rgba(10,22,40,0.95);
    border: 1px solid rgba(107,30,63,0.3);
    border-radius: 8px;
    padding: 10px 18px;
    color: var(--uce-gold, #6b1e3f);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

#uce-map-notice.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Custom Markers ─── */

.uce-map-marker {
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    background: rgba(226,234,245,0.9);
    box-shadow: 0 2px 8px rgba(13,27,42,0.06);
    transition: transform 0.2s;
    border: none !important;
    overflow: visible !important;
}

.uce-map-marker:hover {
    transform: scale(1.3);
}

.uce-map-marker svg {
    stroke: #fdf6e6;
    display: block !important;
    width: 12px !important;
    height: 12px !important;
    flex-shrink: 0;
    overflow: visible !important;
}

.uce-map-marker--event {
    background: rgba(58,123,213,0.9);
}
.uce-map-marker--event svg { stroke: #fff; }

.uce-map-marker--dealer {
    background: rgba(232,146,58,0.9);
}
.uce-map-marker--dealer svg { stroke: #fff; }

.uce-map-marker--club {
    background: rgba(46,204,113,0.9);
}
.uce-map-marker--club svg { stroke: #fff; }

.uce-map-marker--featured {
    box-shadow: 0 0 0 3px rgba(107,30,63,0.6), 0 2px 10px rgba(13,27,42,0.08);
}

/* Leaflet divIcon resets — prevent default white-square appearance */
.leaflet-marker-icon.uce-map-marker,
.leaflet-marker-icon.uce-map-cluster,
.leaflet-marker-icon.uce-map-marker-user {
    background-clip: padding-box;
    border: none !important;
}

/* User location marker */

.uce-map-marker-user {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
}

.uce-map-marker-user span {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3a7bd5;
    box-shadow: 0 0 0 4px rgba(58,123,213,0.3), 0 0 12px rgba(58,123,213,0.4);
    animation: uceMapPulse 2s ease infinite;
}

@keyframes uceMapPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(58,123,213,0.3), 0 0 12px rgba(58,123,213,0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(58,123,213,0.15), 0 0 20px rgba(58,123,213,0.2); }
}

/* Cluster markers */

.uce-map-cluster {
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    border: none !important;
    text-align: center;
    line-height: 1;
}

.uce-map-cluster span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.uce-map-cluster--sm {
    background: rgba(58,123,213,0.85);
    box-shadow: 0 0 0 4px rgba(58,123,213,0.25);
}

.uce-map-cluster--md {
    background: rgba(107,30,63,0.85);
    box-shadow: 0 0 0 4px rgba(107,30,63,0.25);
}

.uce-map-cluster--lg {
    background: rgba(232,146,58,0.85);
    box-shadow: 0 0 0 5px rgba(232,146,58,0.25);
}

/* Leaflet MarkerCluster default overrides — prevent square icons after spiderfy */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: transparent !important;
    border: none !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: transparent !important;
}

/* ─── Popups ─── */

.uce-map-popup-wrap .leaflet-popup-content-wrapper {
    background: var(--uce-bg-secondary, #fdf6e6);
    border: 1px solid rgba(13,27,42,0.1);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(13,27,42,0.1);
    color: var(--uce-text-primary, #0d1b2a);
    padding: 0;
}

.uce-map-popup-wrap .leaflet-popup-tip {
    background: var(--uce-bg-secondary, #fdf6e6);
    border: 1px solid rgba(13,27,42,0.08);
}

.uce-map-popup-wrap .leaflet-popup-content {
    margin: 0;
    min-width: 220px;
}

.uce-map-popup {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.uce-map-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.uce-map-popup-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--type-color, #4a5568);
    background: rgba(13,27,42,0.06);
    padding: 2px 8px;
    border-radius: 4px;
}

.uce-map-popup-feat {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--uce-gold, #6b1e3f);
    background: rgba(107,30,63,0.12);
    padding: 2px 8px;
    border-radius: 4px;
}

.uce-map-popup-thumb {
    border-radius: 6px;
    overflow: hidden;
    margin: 4px 0;
}

.uce-map-popup-thumb img {
    display: block;
    width: 100%;
    height: 80px;
    object-fit: cover;
}

.uce-map-popup-title {
    font-size: 14px;
    line-height: 1.3;
}

.uce-map-popup-title a {
    color: var(--uce-text-primary, #0d1b2a);
    text-decoration: none;
}

.uce-map-popup-title a:hover {
    color: var(--uce-gold, #6b1e3f);
}

.uce-map-popup-date,
.uce-map-popup-venue,
.uce-map-popup-meta,
.uce-map-popup-loc {
    font-size: 12px;
    color: rgba(13,27,42,0.5);
}

.uce-map-popup-date {
    color: var(--uce-gold, #6b1e3f);
    font-weight: 500;
}

.uce-map-popup-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--uce-gold, #6b1e3f);
    text-decoration: none;
    margin-top: 4px;
    transition: color 0.2s;
}

.uce-map-popup-link:hover {
    color: #8f2854;
}

/* ─── Listing Panel ─── */

.uce-map-listing {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(13,27,42,0.06);
    background: var(--uce-bg-primary, #fdf6e6);
    max-height: 570px;
    overflow: hidden;
}

.uce-map-listing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(13,27,42,0.06);
}

.uce-map-listing-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--uce-text-primary, #0d1b2a);
}

#uce-map-result-count {
    font-size: 12px;
    color: var(--uce-text-dim, #718096);
}

#uce-map-listing-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* List items */

.uce-map-list-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.uce-map-list-item:hover {
    background: rgba(13,27,42,0.04);
}

.uce-map-list-item.is-selected {
    background: rgba(107,30,63,0.06);
    border-color: rgba(107,30,63,0.2);
}

.uce-map-list-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(13,27,42,0.04);
}

.uce-map-list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uce-map-list-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.uce-map-list-type-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.uce-map-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.uce-map-list-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.uce-map-list-type-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--type-color, #4a5568);
    background: rgba(13,27,42,0.06);
    padding: 1px 6px;
    border-radius: 3px;
}

.uce-map-list-feat {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--uce-gold, #6b1e3f);
}

.uce-map-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--uce-text-primary, #0d1b2a);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uce-map-list-title:hover {
    color: var(--uce-gold, #6b1e3f);
}

.uce-map-list-date {
    font-size: 11px;
    color: var(--uce-gold, #6b1e3f);
    font-weight: 500;
}

.uce-map-list-venue,
.uce-map-list-spec,
.uce-map-list-sched,
.uce-map-list-loc {
    font-size: 11px;
    color: var(--uce-text-dim, #718096);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uce-map-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: rgba(13,27,42,0.3);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.uce-map-list-more {
    display: block;
    width: 100%;
    margin-top: 8px;
}

/* ─── Responsive ─── */

@media (max-width: 900px) {
    .uce-map-discovery-body {
        flex-direction: column;
        height: auto;
    }

    .uce-map-container {
        height: 350px;
    }

    #uce-discovery-map {
        min-height: 350px;
    }

    .uce-map-listing {
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(13,27,42,0.06);
        max-height: 400px;
    }

    #uce-map-listing-items {
        max-height: 320px;
    }
}

@media (max-width: 600px) {
    .uce-map-toolbar {
        padding: 10px 12px;
        gap: 8px;
    }

    .uce-map-search {
        min-width: 160px;
    }

    #uce-map-search-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    #uce-map-filters-toggle span,
    #uce-map-locate-btn span {
        display: none;
    }

    .uce-map-container {
        min-height: 280px;
    }

    #uce-discovery-map {
        min-height: 280px;
    }

    .uce-map-listing {
        max-height: 300px;
    }
}
