/* Clear Map Styles */
.clear-map-container {
    position: relative;
    width: 100%;
    height: 60vh; /* Default height, overridden by JS for responsive values */
    min-height: 400px;
    background: #f5f5f0;
    font-family: 'Area Normal', -apple-system, BlinkMacSystemFont, sans-serif;
}

.clear-map {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* Filter Panel */
.clear-map-filters {
    position: absolute;
    top: 0;
    left: 40px;
    width: 320px; /* Default, overridden by inline style */
    min-width: 200px;
    max-width: 90%;
    background: #FBF8F1;
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-radius: 0;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 100%;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.clear-map-filters.collapsed .filters-content {
    display: none;
}

/* Transparent background - remove shadow and border */
.clear-map-filters.bg-transparent {
    box-shadow: none;
    border: none;
}

.clear-map-filters.bg-transparent .filters-header {
    background: transparent;
    border-bottom: none;
}

/* Frosted glass panel effect */
.clear-map-filters.filters-frosted {
    background: rgba(251, 248, 241, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.clear-map-filters.filters-frosted .filters-header {
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.clear-map-filters.filters-frosted .filter-category {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Frosted + transparent - allow custom bg color to show through */
.clear-map-filters.filters-frosted.bg-transparent {
    background: rgba(255, 255, 255, 0.15);
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(212, 165, 116, 0.15);
    background: #FBF8F1;
}

.filters-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* The map's "The Area" heading carries a class so its heading LEVEL can be set
   for a valid document outline (WCAG 1.3.1) independent of its appearance. The
   !important keeps it a compact panel label regardless of the host theme's hN
   font-size rules (e.g. Salient child themes set h2 font-size !important, which
   would otherwise blow this title up to multi-line heading size). */
.filters-header .filters-title {
    margin: 0 !important;
    font-size: 16px !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
    color: #333 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
}

.toggle-filters {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    transition: transform 0.2s ease;
}

.toggle-filters:hover {
    color: #333;
}

.clear-map-filters.collapsed .toggle-filters {
    transform: rotate(180deg);
}

.filters-content {
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* When container has explicit height, let content fill available space */
.clear-map-filters[style*="height:"] .filters-content {
    max-height: none;
}

/* Category Styles */
.filter-category {
    border-bottom: 1px solid rgba(212, 165, 116, 0.1);
    transition: opacity 0.2s ease;
}

.filter-category.inactive {
    opacity: 0.5;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.category-header:hover {
    background: rgba(212, 165, 116, 0.05);
}

.category-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.category-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
}

.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.category-dot:hover {
    transform: scale(1.2);
}

.category-x {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: none;
}

/* Filtered state - show X, hide dot */
.category-icon.filtered .category-dot {
    opacity: 0;
    display: none;
}

.category-icon.filtered .category-x {
    opacity: 1;
    display: block;
}

.category-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.category-expand {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    transition: transform 0.2s ease;
}

.category-expand.expanded {
    transform: rotate(90deg);
}

/* POI List Styles */
.category-pois {
    padding: 0 24px 16px;
    background: rgba(245, 245, 240, 0.3);
}

.poi-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.poi-item:hover {
    opacity: 0.7;
}

.poi-item.inactive {
    opacity: 0.4;
}

.poi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.poi-dot:hover {
    transform: scale(1.3);
}

.poi-name {
    font-size: 13px;
    color: #555;
    line-height: 1.3;
}

/* Building Marker */
.building-marker {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.building-marker:hover {
    transform: scale(1.1);
}

.building-icon {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

/* Map Tooltip */
.clear-map-tooltip {
    position: absolute;
    background: #ffffff;
    color: #333;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid rgba(212, 165, 116, 0.3);
    font-size: 13px;
    pointer-events: none;
    z-index: 10000;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Area Normal', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.4;
}

.tooltip-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: #222;
    font-size: 14px;
}

.tooltip-address {
    color: #666;
    font-size: 12px;
    line-height: 1.3;
}

/* ============================================
   Filter Panel Appearance Variations
   ============================================ */

/* No Header */
.clear-map-filters.no-header .filters-header {
    display: none;
}

.clear-map-filters.no-header .filters-content {
    padding-top: 8px;
}

/* No Items (hide expand buttons and POI lists) */
.clear-map-filters.no-items .category-expand {
    display: none;
}

.clear-map-filters.no-items .category-pois {
    display: none !important;
}

.clear-map-filters.no-items .category-header {
    cursor: pointer;
}

/* ============================================
   Pills Style
   ============================================ */
.filter-style-pills .filters-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 24px;
}

/* Pills with no header - add top padding */
.filter-style-pills.no-header .filters-content {
    padding-top: 50px;
}

.filter-style-pills .filter-category {
    border-bottom: none;
    margin: 0;
}

.filter-style-pills .category-header {
    border: 2px solid var(--pill-border-color, #666666);
    border-radius: 50px;
    padding: 14px 28px;
    background: var(--pill-bg-color, transparent);
    justify-content: center;
    transition: all 0.2s ease;
}

.filter-style-pills .category-header:hover {
    background: var(--pill-bg-hover, rgba(0, 0, 0, 0.03));
}

/* Pill frosted glass background */
.filter-style-pills.pills-frosted .category-header {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.35);
}

.filter-style-pills.pills-frosted .category-header:hover {
    background: rgba(255, 255, 255, 0.5);
}

.filter-style-pills .category-toggle {
    justify-content: center;
    gap: 12px;
}

/* Hide colored dots in pill style */
.filter-style-pills .category-icon {
    display: none;
}

.filter-style-pills .category-name {
    text-transform: none;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* Expand button positioning in pills */
.filter-style-pills .category-expand {
    position: absolute;
    right: 20px;
}

/* Active/filtered state for pills */
.filter-style-pills .filter-category.filtered .category-header {
    background: var(--pill-border-color, #666666);
    border-color: var(--pill-border-color, #666666);
}

.filter-style-pills .filter-category.filtered .category-name {
    color: #ffffff;
}

.filter-style-pills .filter-category.filtered .category-expand {
    color: #ffffff;
}

/* Inactive state for pills */
.filter-style-pills .filter-category.inactive .category-header {
    opacity: 0.5;
}

/* POI list in pills style */
.filter-style-pills .category-pois {
    background: transparent;
    padding: 12px 28px 0;
    margin-top: -4px;
}

.filter-style-pills .poi-item {
    padding: 10px 0;
}

/* Pills style with items - position header relative for absolute expand button */
.filter-style-pills .category-header {
    position: relative;
}

/* ============================================
   Mobile Responsive (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Mobile layout: stacked flex column */
    .clear-map-container {
        display: flex;
        flex-direction: column;
        height: auto !important; /* Container auto, map element gets height */
        min-height: auto;
    }

    /* Map element gets explicit height on mobile (set via JS) */
    .clear-map {
        flex: 0 0 auto;
        width: 100%;
        height: 50vh; /* Default mobile height, overridden by JS */
        min-height: 250px;
        order: 1; /* Explicit order for flexbox positioning */
    }

    /* Filters flow naturally below map */
    .clear-map-filters {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important; /* Allow POI lists to expand */
        order: 2; /* Below map by default */
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid rgba(212, 165, 116, 0.2);
        border-bottom: none;
    }

    /* Allow filters content to expand naturally on mobile */
    .clear-map-filters .filters-content {
        max-height: none;
        overflow: visible;
    }

    /* Mobile filters above map */
    .clear-map-filters.mobile-filters-above {
        order: 0; /* Before map (which has order: 1) */
        border-top: none;
        border-bottom: 1px solid rgba(212, 165, 116, 0.2);
    }

    /* Mobile filters below map (default) */
    .clear-map-filters.mobile-filters-below {
        order: 2;
    }

    /* Mobile filters hidden */
    .clear-map-filters.mobile-filters-hidden {
        display: none !important;
    }

    /* Mobile drawer mode - overlay on map */
    .clear-map-container.mobile-drawer-mode {
        display: block;
        height: auto !important;
        min-height: 400px;
    }

    .clear-map-container.mobile-drawer-mode .clear-map {
        height: 100%;
        min-height: 400px;
    }

    .clear-map-container.mobile-drawer-mode .clear-map-filters {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 50vh !important;
        border-top: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    .clear-map-container.mobile-drawer-mode .clear-map-filters.mobile-drawer {
        transform: translateY(calc(100% - 70px));
        transition: transform 0.3s ease;
    }

    .clear-map-container.mobile-drawer-mode .clear-map-filters.mobile-drawer.expanded {
        transform: translateY(0);
    }

    /* Common mobile styles */
    .filters-header {
        padding: 16px 20px;
    }

    .filters-header h3 {
        font-size: 14px;
    }

    .category-header {
        padding: 12px 20px;
    }

    .category-pois {
        padding: 0 20px 12px;
    }

    /* Pills style mobile */
    .filter-style-pills .filters-content {
        padding: 16px 20px;
        gap: 10px;
    }

    .filter-style-pills .category-header {
        padding: 12px 20px;
    }

    .filter-style-pills .category-name {
        font-size: 14px;
    }

    .filter-style-pills .category-expand {
        right: 16px;
    }

    .filter-style-pills .category-pois {
        padding: 10px 20px 0;
    }
}

@media (max-width: 480px) {
    /* Smaller map aspect ratio on very small screens */
    .clear-map {
        aspect-ratio: 4/3;
    }

    /* Drawer mode keeps original aspect ratio on container */
    .clear-map-container.mobile-drawer-mode {
        aspect-ratio: 4/3;
    }

    .clear-map-container.mobile-drawer-mode .clear-map {
        aspect-ratio: auto;
    }

    .filters-header h3 {
        font-size: 13px;
    }

    .category-name {
        font-size: 13px;
    }

    .poi-name {
        font-size: 12px;
    }
}

/* Map Controls Override */
.mapboxgl-ctrl-attrib {
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Cluster Animations */
.mapboxgl-marker {
    transition: transform 0.2s ease;
}

.mapboxgl-marker:hover {
    transform: scale(1.1);
}

/* Smooth accordion animations */
.category-pois {
    overflow: hidden;
    transition: height 0.3s ease;
}

/* Custom scrollbar for filters */
.filters-content::-webkit-scrollbar {
    width: 4px;
}

.filters-content::-webkit-scrollbar-track {
    background: rgba(212, 165, 116, 0.1);
}

.filters-content::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 116, 0.4);
    border-radius: 2px;
}

.filters-content::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 165, 116, 0.6);
}

/* Subway Toggle Switch */
.subway-toggle-section {
    border-bottom: 1px solid rgba(212, 165, 116, 0.15);
    padding: 16px 24px;
    margin-bottom: 8px;
}

.subway-toggle-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.subway-toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #8B7355;
    gap: 12px;
    user-select: none;
}

.subway-toggle-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.subway-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #E5E5E5;
    border-radius: 12px;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 2px;
}

.subway-toggle-switch::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subway-toggle-checkbox:checked + .subway-toggle-switch {
    background: #D4A574;
}

.subway-toggle-checkbox:checked + .subway-toggle-switch::before {
    transform: translateX(20px);
}

.subway-toggle-text {
    color: #8B7355;
    font-weight: 500;
}

/* Mobile responsive styles for subway toggle */
@media (max-width: 768px) {
    .subway-toggle-section {
        padding: 12px 20px;
    }

    .subway-toggle-label {
        font-size: 13px;
        gap: 10px;
    }

    .subway-toggle-switch {
        width: 40px;
        height: 22px;
    }

    .subway-toggle-switch::before {
        width: 18px;
        height: 18px;
    }

    .subway-toggle-checkbox:checked + .subway-toggle-switch::before {
        transform: translateX(18px);
    }
}

/* ============================================
   POI Popup Styles
   ============================================ */

.mapboxgl-popup-content {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.mapboxgl-popup-close-button {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    background: #fff;
    color: #333;
    font-size: 20px;
    line-height: 1;
    font-weight: 400;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

.mapboxgl-popup-close-button:hover,
.mapboxgl-popup-close-button:focus {
    background: #333;
    color: #fff;
    transform: scale(1.05);
}

.poi-popup {
    font-family: 'Area Normal', -apple-system, BlinkMacSystemFont, sans-serif;
}

.poi-popup-photo {
    width: 100%;
    max-height: 200px;
    overflow: hidden;
}

.poi-popup-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.poi-popup-content {
    padding: 20px;
    text-align: center;
}

.poi-popup-name {
    font-size: 16px;
    font-weight: 400;
    color: #5a4a3a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.poi-popup-divider {
    width: 40px;
    height: 2px;
    background: #5a4a3a;
    margin: 0 auto 16px;
}

.poi-popup-address {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
}

.poi-popup-logo {
    margin-bottom: 16px;
}

.poi-popup-logo img {
    max-width: 180px;
    max-height: 80px;
    height: auto;
    display: block;
    margin: auto;
}

.poi-popup-description {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 12px;
}

.poi-popup-website {
    margin-top: 12px;
}

.poi-popup-website a {
    color: #2271b1;
    text-decoration: none;
    font-size: 13px;
}

.poi-popup-website a:hover {
    text-decoration: underline;
}

/* ============================================
   Building Popup (hover tooltip)
   The global .mapboxgl-popup-content has padding:0, so the inner
   wrapper supplies its own padding — matches the POI popup look.
   ============================================ */
.building-popup {
    font-family: 'Area Normal', -apple-system, BlinkMacSystemFont, sans-serif;
}

.building-popup-content {
    padding: 18px 22px;
    text-align: center;
    max-width: 260px;
}

.building-popup-name {
    font-size: 15px;
    font-weight: 400;
    color: #5a4a3a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.35;
}

.building-popup-divider {
    width: 40px;
    height: 2px;
    background: #5a4a3a;
    margin: 12px auto 14px;
}

.building-popup-description {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 10px;
}

.building-popup-contact {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

.building-popup-contact a {
    color: #2271b1;
    text-decoration: none;
}

.building-popup-contact a:hover {
    text-decoration: underline;
}