/* * styles.css
 * Fichier pour vos styles personnalisés.
 */

/* --- CORRECTIF DU SCROLL (PULL-TO-REFRESH & APP NATIVE) --- */
html,
body {
    overscroll-behavior-y: contain;
    /* Bloque le rafraîchissement natif */
    touch-action: pan-x pan-y;
    /* Améliore la réponse tactile */
    min-height: 100%;
    /* Permet au body de s'étendre au-delà de l'écran quand clavier ouvert */
    overflow-y: auto;
    /* Permet le scroll quand nécessaire */
    scroll-padding-bottom: 150px;
    /* Espace réservé pour le clavier Android */
}

/* --- KEYBOARD VISIBILITY FIX --- */
/* Garantit que les inputs focusés restent visibles au-dessus du clavier */
input:focus,
textarea:focus,
select:focus {
    scroll-margin-bottom: 200px;
}

/* Amélioration du scroll tactile pour les conteneurs */
.overflow-y-auto,
[class*="overflow-y-auto"] {
    -webkit-overflow-scrolling: touch;
}

/* --- FIX MODALS SCROLL AVEC CLAVIER --- */
/* Les modales fixed doivent permettre le scroll interne quand le clavier est ouvert */
#authModal>div,
#formModal>div,
[class*="fixed"][class*="inset-0"]>div {
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Forcer le scroll sur les formulaires dans les modales */
#authModal form,
#formModal form,
.space-y-4 {
    padding-bottom: 20px;
}

body {
    -webkit-font-smoothing: antialiased;
}

/* Gestion du padding safe-area pour les iPhones récents */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom);
}

.pt-safe {
    padding-top: env(safe-area-inset-top);
}

.py-safe {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}


/* Helpers généraux */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

#map {
    height: 100%;
    width: 100%;
}

/* Icônes */
.fa-bicycle,
.fa-road,
.fa-plus-circle,
.fa-save,
.fa-sync-alt {
    vertical-align: middle;
}

/* Formulaires */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
    -webkit-appearance: none;
}

/* --- STYLES GPS 3D & ANIMATIONS --- */
.gps-tile-3d {
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5), 0 10px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.btn-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.4) 0%, transparent 50%);
    pointer-events: none;
}

.btn-3d-content {
    position: relative;
    z-index: 10;
}

.btn-glass-overlay {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.05) 50%, transparent 51%, transparent 100%);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border-radius: inherit;
}

/* Pile de contrôles côté droit - Valeur par défaut (Desktop) */
#saved-map-controls {
    position: absolute;
    bottom: 5rem;
    /* Juste au-dessus du bouton "i" (qui est à 1.5rem + 36px hauteur) */
    right: 1.5rem;
    top: auto;
    transform: none;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: auto;
}

/* Animation REC (Point rouge) */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

.animate-pulse-red {
    animation: pulse-red 2s infinite;
}

/* Animation Horloge GPS (:) */
@keyframes flash-colon {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0.2;
    }
}

.flash-anim {
    animation: flash-colon 1s infinite;
    display: inline-block;
}

/* --- BROUTER-WEB STYLE POSITION MARKER --- */
.brouter-marker {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Center Dot - Blue with white border */
.brouter-center-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

/* Heading Cone - Rotates with compass */
.brouter-heading-cone {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 2;
    transition: transform 0.1s ease-out;
    /* Smooth 60fps rotation */
    will-change: transform;
}

.brouter-heading-cone svg {
    width: 100%;
    height: 100%;
}

/* Accuracy Circle - Large gray/blue like BRouter-Web */
.brouter-accuracy-circle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 140px;
    height: 140px;
    margin-left: -70px;
    margin-top: -70px;
    background: rgba(100, 130, 170, 0.3);
    border: none;
    border-radius: 50%;
    z-index: 1;
    transition: width 0.3s ease, height 0.3s ease, margin 0.3s ease;
}

@keyframes accuracy-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Snapped to route - Green variant */
.brouter-marker.snapped .brouter-center-dot {
    background: #16a34a;
}

.brouter-marker.snapped .brouter-accuracy-circle {
    background: rgba(22, 163, 74, 0.15);
    border-color: rgba(22, 163, 74, 0.3);
}

/* --- PULSE MARKER ANIMATION (Round Pointer) --- */
@keyframes pulse-marker {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }

    70% {
        transform: scale(1.2);
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.pulse-marker {
    animation: pulse-marker 2s infinite;
    will-change: transform, box-shadow;
}

/* --- LEGACY GPS MARKER (keep for compatibility) --- */
.gps-marker-container {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* La flèche navigation (SVG injecté par JS) */
.gps-marker-arrow-svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 2;
}

/* Halo de position (le point bleu classique sous la flèche) */
.gps-marker-dot {
    position: absolute;
    width: 28px;
    height: 28px;
    background: rgba(37, 99, 235, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    z-index: 1;
    transition: width 0.3s, height 0.3s, background 0.3s;
}

/* Halo de précision dynamique (affiché autour du point) */
.gps-marker-accuracy {
    position: absolute;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 50%;
    z-index: 0;
    transition: width 0.3s, height 0.3s;
    pointer-events: none;
}

/* Indicateur "snapped to route" - cercle vert */
.gps-marker-container.snapped .gps-marker-dot {
    background: rgba(22, 163, 74, 0.3);
    border-color: rgba(22, 163, 74, 0.9);
}

.gps-marker-container.snapped .gps-marker-arrow-svg path {
    fill: #16a34a;
}

/* Animation de pulsation subtile quand immobile */
.gps-marker-container.pulsing .gps-marker-dot {
    animation: gps-pulse-subtle 2s infinite;
}

@keyframes gps-pulse-subtle {
    0% {
        transform: scale(1);
        background: rgba(37, 99, 235, 0.3);
    }

    50% {
        transform: scale(1.5);
        background: rgba(37, 99, 235, 0.1);
    }

    100% {
        transform: scale(1);
        background: rgba(37, 99, 235, 0.3);
    }
}

/* Snapped pulsation - green */
.gps-marker-container.snapped.pulsing .gps-marker-dot {
    animation: gps-pulse-snapped 2s infinite;
}

@keyframes gps-pulse-snapped {
    0% {
        transform: scale(1);
        background: rgba(22, 163, 74, 0.3);
    }

    50% {
        transform: scale(1.3);
        background: rgba(22, 163, 74, 0.15);
    }

    100% {
        transform: scale(1);
        background: rgba(22, 163, 74, 0.3);
    }
}

/* --- MAP ATTRIBUTION RIBBON --- */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.9) !important;
    font-size: 10px !important;
    padding: 2px 8px !important;
    border-radius: 4px 0 0 0;
    backdrop-filter: blur(4px);
    z-index: 50;
    max-width: 100%;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.1);
}

.maplibregl-ctrl-attrib a {
    color: #2563eb;
    text-decoration: none;
}

/* Compact mode (PiP/thumbnails): show only "i" button */
.map-container--compact .maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 4px !important;
    border-radius: 4px;
}

.maplibregl-ctrl-attrib-inner {
    display: none !important;
}

.maplibregl-ctrl-attrib-button {
    display: block !important;
    width: 16px;
    height: 16px;
}

/* [CREDITS-UI] Nouveau bouton d'information chirurgical */
.btn-map-info {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 9999px;
    /* Forcer le cercle parfait */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    color: #1f2937;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.btn-map-info:hover {
    background: rgba(255, 255, 255, 1);
    color: #2563eb;
}

.btn-map-info:active {
    scale: 0.9;
}

/* Position par défaut si non intégré */
.btn-map-info.absolute-pos {
    position: absolute;
    bottom: 1rem;
    /* Placé tout en bas à droite */
    right: 1rem;
}

/* Pile de contrôles côté droit - Correction mobile */
@media (max-width: 767px) {
    #saved-map-controls {
        top: auto !important;
        bottom: 4.5rem !important;
        /* Positionné juste au-dessus du bouton "i" */
        right: 1rem !important;
        transform: none !important;
    }
}

/* Desktop: Alignement et marges */
@media (min-width: 768px) {

    /* Le bouton "i" conserve sa taille de 48px pour l'alignement */
    .btn-map-info.absolute-pos {
        bottom: 1.5rem;
        right: 1.5rem;
        /* Alignement strict avec #saved-map-controls */
    }
}

/* Mobile: ajustement pour éviter les contrôles MapLibre natifs si présents */
@media (max-width: 480px) {
    .maplibregl-ctrl-attrib:not(.maplibregl-compact) {
        font-size: 9px !important;
        padding: 2px 4px !important;
    }
}

/* --- PHOTON SEARCH (Autocomplétion d'adresses) --- */
.photon-search-container {
    width: 100%;
}

.photon-search-input {
    width: 100%;
    padding: 8px 60px 8px 32px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    background: #f9fafb;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.photon-search-input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
    background: #fff;
}

.photon-search-input::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

.photon-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
}

.photon-clear-btn {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    z-index: 10;
}

.photon-clear-btn:hover {
    background: #d1d5db;
    color: #374151;
}

.photon-gps-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    color: #9333ea;
    /* Purple-600 */
    cursor: pointer;
    transition: all 0.2s;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.photon-gps-btn:hover {
    color: #7e22ce;
    /* Purple-700 */
    transform: translateY(-50%) scale(1.1);
}


/* Dropdown des suggestions */
.photon-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 260px;
    overflow-y: auto;
    z-index: 50;
    animation: photon-dropdown-in 0.15s ease-out;
}

@keyframes photon-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.photon-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.photon-suggestion-item:last-child {
    border-bottom: none;
}

.photon-suggestion-item:hover,
.photon-suggestion-item.active {
    background: #f5f3ff;
}

.photon-suggestion-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #f3e8ff;
    color: #9333ea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.photon-suggestion-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.photon-suggestion-name {
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photon-suggestion-context {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photon-no-results {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
}

.photon-suggestion-type {
    font-size: 9px;
    font-weight: 700;
    color: #a78bfa;
    text-transform: uppercase;
    flex-shrink: 0;
}