/* Map-specific styles */
.map-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 900px;
}

.map-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-shrink: 0;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.map-filters .form-input,
.map-filters .form-select {
    flex: 1 1 150px;
    min-width: 120px;
}

.map-filters .radius-filters {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.map-filters .radius-filters .btn-sm {
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border);
    min-width: 40px;
}

.map-filters .radius-filters .btn-sm:last-child {
    border-right: none;
}

/* Competitor count display */
.competitor-count-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    box-shadow: var(--shadow);
}

.competitor-count-number {
    font-weight: 600;
    color: var(--primary);
}

/* Map style controls */
.map-style-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.map-style-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-style-btn:hover {
    background: var(--primary);
    color: white;
}

.map-style-btn.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

#map-wrapper {
    position: relative;
    flex-grow: 1;
    height: 900px;
    min-height: 900px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.map {
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
}

.map-table-container {
    margin-top: 1rem;
    max-height: 450px;
    overflow-y: auto;
    flex-shrink: 0;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.mapboxgl-popup-content {
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.map-tooltip {
    background: var(--surface);
    color: var(--text);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    max-width: 320px;
}

.tooltip-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--primary);
}

.tooltip-subtitle, .tooltip-address {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.tooltip-period {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.tooltip-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    margin-bottom: 4px;
}

.tooltip-stat:last-child {
    margin-bottom: 0;
}

.radius-filters .btn-sm.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(var(--primary-color-rgb), 0.3);
}

.marker {
    cursor: pointer;
    filter: drop-shadow(0px 3px 6px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

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

.map-info-box {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 10;
    max-width: 320px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-info-box h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 600;
}

.info-box-subtitle, .info-box-address {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.info-box-period {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-style: italic;
}

.map-info-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.map-info-box li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    align-items: center;
}

.map-info-box li strong {
    color: var(--text);
}

.map-legend {
    position: absolute;
    bottom: 30px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 10;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-legend h4 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
}

.map-legend div {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.legend-color {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Enhanced Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1001; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    margin: 8% auto;
    padding: 2rem;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 700px;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: var(--text);
    text-decoration: none;
}

#modalBody {
    max-height: 50vh;
    overflow-y: auto;
    border-radius: var(--radius);
}

.search-result-item {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.search-result-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.search-result-item:hover {
    background: var(--background);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-result-item.selected {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(var(--primary-color-rgb), 0.3);
}

.search-result-item.selected strong {
    color: white;
}

/* Improved loading overlay */
#map-loading-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
}

/* Enhanced data table in map */
.map-table-container .data-table {
    margin: 0;
}

.map-table-container .data-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    padding: 1rem 0.75rem;
    font-size: 0.85rem;
}

.map-table-container .data-table td {
    padding: 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.map-table-container .data-table tr:hover {
    background: var(--background);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map-container {
        min-height: 700px;
    }
    
    #map-wrapper {
        height: 700px;
        min-height: 700px;
    }
    
    .map-table-container {
        max-height: 300px;
    }
    
    .map-filters {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .map-filters .form-input,
    .map-filters .form-select {
        min-width: 100px;
        font-size: 0.9rem;
    }
    
    .map-info-box {
        right: 10px;
        top: 10px;
        max-width: 280px;
        padding: 1rem;
    }
    
    .map-legend {
        left: 10px;
        bottom: 20px;
        padding: 10px;
    }
    
    .map-style-controls {
        top: 10px;
        left: 10px;
    }
    
    .map-style-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}