/**
 * Styles CSS optimisés pour les cartes Google Maps
 * Améliore les performances et l'expérience utilisateur
 */

/* Animation de clignotement pour guider l'utilisateur */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 15px #0d6efd44, 0 0 0 0 rgba(13, 110, 253, 0.7);
    }
    50% {
        box-shadow: 0 6px 20px #0d6efd66, 0 0 0 10px rgba(13, 110, 253, 0.3);
    }
    100% {
        box-shadow: 0 4px 15px #0d6efd44, 0 0 0 0 rgba(13, 110, 253, 0);
    }
}

.btn-pulse {
    animation: pulse 2s infinite;
}

/* Optimisations pour les champs d'autocomplete */
.optimized-autocomplete {
    position: relative;
}

.optimized-autocomplete input {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.optimized-autocomplete input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Indicateur de cache actif */
.cache-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cache-indicator.active {
    opacity: 1;
}

/* Suggestions d'autocomplete optimisées */
.address-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Loader pour les requêtes Google Maps */
.maps-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    display: none;
    z-index: 1001;
}

.maps-loader.active {
    display: block;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0d6efd;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications d'économies */
.savings-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    z-index: 10000;
    max-width: 300px;
    font-size: 14px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.savings-notification.show {
    transform: translateX(0);
}

.savings-notification .icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 16px;
}

/* Optimisations pour cartes en plein écran */
.map-container {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.map-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
}

/* Contrôles de carte optimisés */
.custom-map-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

.custom-map-controls button {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    margin-right: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.custom-map-controls button:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.custom-map-controls button.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* Indicateur de connexion réseau */
.network-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #ff6b6b;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 10000;
    display: none;
}

.network-status.offline {
    display: block;
}

.network-status.online {
    background: #28a745;
    display: block;
    animation: fadeOut 3s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; display: none; }
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .map-container {
        height: 300px;
    }
    
    .savings-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .custom-map-controls {
        top: 5px;
        left: 5px;
    }
    
    .custom-map-controls button {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Debug mode (peut être activé pour voir les optimisations) */
.debug-mode .cache-indicator {
    opacity: 1 !important;
}

.debug-mode .maps-loader {
    border: 2px dashed #0d6efd;
}

.debug-mode .suggestion-item::after {
    content: " [cached]";
    color: #28a745;
    font-size: 11px;
}

/* Accessibilité */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible pour navigation clavier */
.suggestion-item:focus,
.custom-map-controls button:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}
