/**
 * Advanced Maps Manager - Frontend Styles
 */

.amm-map-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.amm-map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.amm-map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Search Container */
.amm-search-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 3000;
    width: 300px;
}

.amm-location-search {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.amm-location-search:focus {
    outline: none;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.amm-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 3500; /* above filters and other UI */
}

.amm-search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.amm-search-result-item:hover {
    background-color: #f8f9fa;
}

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

/* Filters Container */
.amm-filters-container {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.amm-region-filter,
.amm-type-filter {
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.amm-region-filter:hover,
.amm-type-filter:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

/* Legend */
.amm-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 300px;
    backdrop-filter: blur(10px);
}

.amm-legend h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.amm-legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.amm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.amm-legend-item:hover {
    opacity: 0.7;
}

.amm-legend-item.hidden {
    opacity: 0.3;
}

.amm-legend-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.amm-legend-label {
    font-weight: 500;
}

/* Controls */
.amm-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.amm-control-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amm-control-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

/* Pins List */
.amm-pins-list {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 2000;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.amm-pins-list.active {
    transform: translateX(0);
}

.amm-list-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.amm-list-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.amm-close-list {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amm-list-search {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.amm-list-search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.amm-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.amm-list-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.amm-list-item:hover {
    background-color: #f8f9fa;
}

.amm-list-item.active {
    background-color: var(--amm-primary, #EC078E);
    color: white;
}

.amm-list-item-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.amm-list-item-content {
    flex: 1;
}

.amm-list-item h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
}

.amm-list-item p {
    margin: 0 0 5px 0;
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.4;
}

.amm-list-item-region {
    font-size: 12px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Popup Styles - elegant card */
.leaflet-popup-content-wrapper {
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    padding: 0;
}

.leaflet-popup-tip {
    background: #fff;
}

.leaflet-popup-content {
    width: 280px !important;
    margin: 0;
    padding: 0;
}

.amm-popup-content {
    padding: 14px 16px 16px 16px;
}

.amm-popup-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #1f2937;
}

.amm-popup-description {
    font-size: 14px;
    line-height: 1.5;
    color: #4b5563;
    margin: 0 0 8px 0;
}

.amm-popup-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
}

.amm-popup-links {
    display: flex;
    gap: 10px;
}

.amm-popup-link {
    display: inline-block;
    padding: 8px 12px;
    background: var(--amm-primary, #EC078E);
    color: #fff !important;
    text-decoration: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.amm-popup-link:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}

.amm-popup-link:visited,
.amm-popup-link:focus {
    color: #fff !important;
}

/* Force white text for buttons inside leaflet popup against theme overrides */
.leaflet-container .amm-popup-content .amm-popup-link,
.leaflet-container .amm-popup-content .amm-popup-link:link,
.leaflet-container .amm-popup-content .amm-popup-link:visited,
.leaflet-container .amm-popup-content .amm-popup-link:hover,
.leaflet-container .amm-popup-content .amm-popup-link:active,
.leaflet-container .amm-popup-content .amm-popup-link:focus {
    color: #fff !important;
    text-decoration: none !important;
}

/* MapLibre Popup Styles */
.maplibregl-popup-content {
    border-radius: 18px !important;
    padding: 0 !important;
    margin: 0 !important;
}

.maplibregl-popup-tip {
    background: #fff !important;
}

.maplibregl-popup-close-button {
    color: #6b7280 !important;
    font-weight: 700 !important;
    font-size: 18px !important;
    padding: 8px !important;
    border-radius: 50% !important;
    transition: background-color 0.2s ease !important;
}

.maplibregl-popup-close-button:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

.leaflet-popup-close-button {
    color: #6b7280 !important;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 768px) {
    .amm-search-container {
        width: calc(100% - 120px); /* Leave space for control icons */
        max-width: 250px;
    }
    
    .amm-filters-container {
        display: none; /* Hide filters on mobile by default */
    }
    
    .amm-filters-container.mobile-visible {
        display: flex;
        position: absolute;
        top: 70px;
        left: 10px;
        right: 10px;
        background: rgba(255, 255, 255, 0.95);
        padding: 10px;
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        z-index: 2500;
        flex-direction: row;
        gap: 8px;
    }
    
    .amm-region-filter,
    .amm-type-filter {
        flex: 1;
        min-width: 0;
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .amm-pins-list {
        width: 100%;
    }
    
    .amm-legend {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        padding: 8px 10px;
        border-radius: 8px;
    }
    
    .amm-legend h4 {
        display: none; /* Hide title on mobile */
    }
    
    .amm-legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
    
    .amm-legend-item {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        font-size: 12px;
        margin: 0;
    }
    
    .amm-legend-icon {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
    }
    
    .amm-legend-label {
        font-weight: 400;
        white-space: nowrap;
    }
    
    .amm-controls {
        top: 10px;
        right: 10px;
        z-index: 2000;
    }
    
    .amm-control-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    /* Add filter toggle button - mobile only */
    .amm-filter-toggle {
        display: none; /* Hidden by default on desktop */
    }
    
    .amm-filter-toggle {
        background: rgba(255, 255, 255, 0.9);
        border: none;
        border-radius: 50%;
        width: 35px;
        height: 35px;
        font-size: 16px;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .amm-filter-toggle:hover {
        background: rgba(255, 255, 255, 1);
        transform: scale(1.1);
    }
    
    /* Show filter toggle on mobile */
    .amm-filter-toggle {
        display: flex !important;
    }
}

/* Custom Map Styles */
.amm-custom-styles {
    /* Additional custom styles can be added here */
}

/* Loading States */
.amm-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.amm-loading::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid #EC078E;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Error States */
.amm-error {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #c62828;
    margin: 10px 0;
}

/* Success States */
.amm-success {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #2e7d32;
    margin: 10px 0;
}
