/**
 * EmeFa Leaflet Maps Styles
 * 
 * @package EmeFa
 * @since 1.0.0
 */

/* Map Container */
.emefa-map-container,
#listing-map,
#listings-map {
    width: 100%;
    height: 400px;
    border-radius: var(--radius-xl, 1rem);
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: #f3f4f6;
}

/* Responsive map height and mobile optimizations */
@media (max-width: 768px) {
    .emefa-map-container,
    #listing-map,
    #listings-map {
        height: 450px !important;
        border-radius: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        border-left: none !important;
        border-right: none !important;
        position: relative !important;
        transform: none !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1 !important;
    }
    
    /* Full width map container on mobile */
    .listing-map-section {
        margin-left: calc(-1 * var(--spacing-sm, 0.75rem)) !important;
        margin-right: calc(-1 * var(--spacing-sm, 0.75rem)) !important;
        padding: 0 !important;
        width: calc(100% + 2 * var(--spacing-sm, 0.75rem)) !important;
        max-width: 100vw !important;
        overflow: visible !important;
        position: relative;
    }
    
    #listings-map-container {
        margin-left: calc(-1 * var(--spacing-sm, 0.75rem)) !important;
        margin-right: calc(-1 * var(--spacing-sm, 0.75rem)) !important;
        padding: 0 !important;
        width: calc(100% + 2 * var(--spacing-sm, 0.75rem)) !important;
        max-width: 100vw !important;
        overflow: visible !important;
        position: relative;
    }
    
    /* Ensure Leaflet container is visible on mobile */
    .leaflet-container {
        width: 100% !important;
        height: 450px !important;
        min-height: 450px !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1 !important;
        position: relative !important;
        background: #f3f4f6 !important;
    }
    
    .leaflet-map-pane,
    .leaflet-tile-pane,
    .leaflet-overlay-pane {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Smaller zoom controls on mobile */
    .leaflet-control-zoom {
        margin: 10px !important;
    }
    
    .leaflet-control-zoom a {
        width: 32px !important;
        height: 32px !important;
        line-height: 32px !important;
        font-size: 16px !important;
    }
    
    /* Smaller popups on mobile */
    .leaflet-popup-content-wrapper {
        max-width: 280px !important;
        padding: 8px !important;
    }
    
    .leaflet-popup-content {
        font-size: 0.9rem !important;
    }
    
    .leaflet-popup-content h4 {
        font-size: 0.95rem !important;
        margin-bottom: 6px !important;
    }
    
    /* Route button smaller on mobile */
    .emefa-route-btn,
    .emefa-route-btn-list {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }
    
    /* Better touch targets */
    .leaflet-bar a {
        min-width: 32px;
        min-height: 32px;
    }
    
    /* Adjust popup close button */
    .leaflet-popup-close-button {
        width: 28px !important;
        height: 28px !important;
        font-size: 20px !important;
        line-height: 28px !important;
    }
}

/* Address Autocomplete Styles */
.emefa-address-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 0.5rem);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.emefa-suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.emefa-suggestions-list li {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

.emefa-suggestions-list li:last-child {
    border-bottom: none;
}

.emefa-suggestions-list li:hover {
    background-color: var(--color-light, #f8fafc);
}

.emefa-suggestions-list li i {
    margin-right: 8px;
    color: var(--color-accent, #6366f1);
}

/* Form group with address input should be relative */
.form-group:has(#listing_address) {
    position: relative;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg, 0.75rem);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.leaflet-popup-content h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 600;
}

.leaflet-popup-content a {
    color: var(--color-accent, #6366f1);
    text-decoration: none;
}

.leaflet-popup-content a:hover {
    text-decoration: underline;
}

/* Loading state */
.emefa-map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-light, #64748b);
}

.emefa-map-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border, #e2e8f0);
    border-top-color: var(--color-accent, #6366f1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Custom Marker Styles */
.emefa-custom-marker {
    background: transparent !important;
    border: none !important;
}

/* Route Button Styles */
.emefa-route-btn,
.emefa-route-btn-list {
    transition: all 0.2s ease;
}

.emefa-route-btn:hover,
.emefa-route-btn-list:hover {
    background: #4f46e5 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.emefa-route-btn:active,
.emefa-route-btn-list:active {
    transform: translateY(0);
}

.emefa-route-btn:disabled,
.emefa-route-btn-list:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Enhanced Map Controls */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: #1e293b !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    transition: all 0.2s;
}

.leaflet-control-zoom a:hover {
    background-color: #f8fafc !important;
    color: #6366f1 !important;
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Enhanced Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
}

.leaflet-popup-tip {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Route Line Style */
.leaflet-interactive {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Map Container Enhancements */
.emefa-map-container,
#listing-map,
#listings-map {
    border: 2px solid #e2e8f0;
    transition: box-shadow 0.3s;
}

.emefa-map-container:hover,
#listing-map:hover,
#listings-map:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Loading Overlay */
.emefa-map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: var(--radius-xl, 1rem);
}

/* Route Info Box */
.emefa-route-info {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 10px;
    font-size: 0.9rem;
}

.emefa-route-info strong {
    color: #1e293b;
    display: block;
    margin-bottom: 4px;
}

.emefa-route-info span {
    color: #64748b;
}

