/* ═══ Map ═══ */
.map-container { display: flex; flex-direction: column; height: auto; }

#map-filters {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px; margin-bottom: 12px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px;
}

#radius-filters { display: flex; gap: 4px; align-items: center; }
#radius-filters .btn-sm {
    background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border);
}
#radius-filters .btn-sm.active { background: var(--primary); color: white; border-color: var(--primary); }

.competitor-count-display {
    background: var(--primary-bg); color: var(--primary);
    padding: 8px 12px; border-radius: 8px; font-size: var(--text-sm);
    margin-bottom: 12px; border: 1px solid var(--primary-border);
}
.competitor-count-number { font-weight: 700; }

/* Map wrapper */
#map-wrapper {
    position: relative; width: 100%;
    height: 500px; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
#map { width: 100%; height: 100%; }

/* Map controls */
.map-style-controls {
    position: absolute; top: 10px; left: 10px; z-index: 10;
    display: flex; gap: 4px; background: var(--bg-surface);
    border-radius: 6px; padding: 4px; border: 1px solid var(--border);
}
.map-style-btn {
    padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer;
    font-size: var(--text-xs); font-family: inherit; font-weight: 500;
    background: transparent; color: var(--text-secondary);
    transition: background 0.2s;
}
.map-style-btn.active { background: var(--primary); color: white; }

/* Info box */
#map-info-box {
    position: absolute; top: 10px; right: 10px; z-index: 10;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px; max-width: 280px;
    box-shadow: var(--shadow); display: none;
}
#map-info-box h3 { font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 4px; }
.info-box-subtitle { font-size: var(--text-xs); color: var(--text-tertiary); }
.info-box-address { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: 8px; }
.info-box-period { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 8px; }
#map-info-box ul { list-style: none; }
#map-info-box li { font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 4px; }
#map-info-box li strong { color: var(--text-secondary); font-weight: 500; }

/* Legend */
#map-legend {
    position: absolute; bottom: 10px; left: 10px; z-index: 10;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px; font-size: var(--text-xs);
    box-shadow: var(--shadow);
}
#map-legend h4 { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
#map-legend > div { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--text-secondary); }
.legend-color { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* Map table */
.map-table-container {
    max-height: 350px; overflow-y: auto; margin-top: 12px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Mapbox tooltip overrides */
.mapboxgl-popup-content {
    background: var(--bg-surface) !important; border: 1px solid var(--border-strong) !important;
    border-radius: 8px !important; padding: 12px !important; box-shadow: var(--shadow) !important;
    color: var(--text-primary) !important;
}
.mapboxgl-popup-tip { border-top-color: var(--bg-surface) !important; }
.map-tooltip { font-size: var(--text-sm); }
.tooltip-title { font-weight: 600; font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 2px; }
.tooltip-subtitle { font-size: var(--text-xs); color: var(--text-tertiary); }
.tooltip-address { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: 6px; }
.tooltip-period { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 6px; }
.tooltip-stat { font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 2px; }
.tooltip-stat span { color: var(--text-secondary); }

/* Search results modal (map) */
.search-result-item {
    padding: 12px; cursor: pointer; border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-elevated); }
.search-result-item.selected { background: var(--primary-bg); border-left: 3px solid var(--primary); }
.result-info { font-size: var(--text-sm); color: var(--text-secondary); }
.result-info strong { color: var(--text-tertiary); font-weight: 500; }

/* Responsive */
@media (max-width: 768px) {
    #map-filters { grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; }
    #map-filters .form-input, #map-filters .form-select { min-height: 40px; font-size: var(--text-xs); padding: 6px 8px; }
    #map-wrapper { height: 300px; }
    #map-info-box { max-width: 180px; padding: 8px; font-size: var(--text-xs); }
    #map-info-box h3 { font-size: var(--text-xs); }
    .map-table-container { max-height: 200px; }
    .map-style-controls { top: 4px; left: 4px; }
    .map-style-btn { padding: 6px 10px; font-size: var(--text-xs); }
    .competitor-count-display { font-size: var(--text-xs); padding: 6px 8px; }
}
@media (max-width: 480px) {
    #map-filters { grid-template-columns: 1fr; gap: 4px; }
    #map-wrapper { height: 260px; }
    #map-legend { display: none; }
    #map-info-box { display: none; }
}
