/* Style global et importations */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Palette Éco-Premium */
    --bg-dark: #FAF9F8;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --primary: #001eb3; /* Emeraude */
    --primary-glow: rgba(0, 30, 179, 0.15);
    --primary-hover: #001580;
    --accent: #f95335;
    --accent-gold: #f95335;
    --text-main: #050038;
    --text-muted: #64748b;
    --border-color: rgba(0, 30, 179, 0.1);
    --border-active: rgba(0, 30, 179, 0.4);
    --font-title: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass: backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-dark);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* En-tête / Navigation */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--border-color);
    var(--glass);
    transition: var(--transition);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.logo-icon {
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary));
}

nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-title);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    color: var(--text-main);
    background: rgba(0, 30, 179, 0.05);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-glow);
    border-color: rgba(0, 30, 179, 0.2);
}

/* Conteneur principal */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

.page {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
}

.page.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page d'Itinéraire */
.itinerary-container {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 2rem;
    height: calc(100vh - 180px);
    min-height: 550px;
}

/* Section de la carte */
.map-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    height: 100%;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #e2e8f0;
    z-index: 1;
}

/* Suppression du filtre pour afficher les couleurs originales de Google Maps */
.leaflet-tile-container {
    /* filter: invert(90%) hue-rotate(110deg) brightness(85%) contrast(110%); */
}

.leaflet-container {
    background: #001eb3 !important;
}

.leaflet-popup-content-wrapper {
    background: #FFFFFF !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color);
    border-radius: 12px !important;
    padding: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-popup-tip {
    background: #FFFFFF !important;
}

.map-popup-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.map-popup-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Liste des étapes */
.steps-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.steps-header {
    margin-bottom: 1.5rem;
}

.steps-title {
    font-family: var(--font-title);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    -webkit-background-clip: text;
    
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.steps-badge {
    background: var(--primary-glow);
    border: 1px solid rgba(0, 30, 179, 0.3);
    color: var(--primary);
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-family: var(--font-body);
}

.steps-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Carte d'étape individuelle */
.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    gap: 1.25rem;
    flex-shrink: 0;
}

.step-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    transition: var(--transition);
}

.step-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.3);
}

.step-card.active {
    background: rgba(0, 30, 179, 0.05);
    border-color: var(--border-active);
    box-shadow: 0 0 25px -5px rgba(0, 30, 179, 0.1);
}

.step-card.active::before {
    background: var(--primary);
}

.step-number {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.step-card.active .step-number {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

.step-info {
    flex: 1;
}

.step-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.35rem;
}

.step-name {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.step-card.active .step-name {
    color: var(--primary);
}

.step-distance {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.step-address {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.step-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.step-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-weight: 600;
}

/* Page Défi / Code */
.challenge-container {
    max-width: 600px;
    margin: 3rem auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2rem;
}

.challenge-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    width: 100%;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    var(--glass);
}



.challenge-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 15px rgba(0, 30, 179, 0.4));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.challenge-title {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.challenge-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.code-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center;
    width: 100%;
}

.input-group {
    width: 100%;
    position: relative;
}

.code-input {
    width: 100%;
    background: rgba(0, 30, 179, 0.6);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.1rem 1.5rem;
    font-family: var(--font-title);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: var(--transition);
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 30, 179, 0.2);
    background: rgba(0, 30, 179, 0.8);
}

.code-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    letter-spacing: 0;
    font-size: 1.1rem;
}

.shake {
    animation: shake 0.4s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2) !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.hint-box {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hint-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
}

.hint-text {
    display: none;
    background: #F8FAFC;
    border: 1px dashed var(--border-color);
    padding: 0.75rem;
    border-radius: 8px;
    animation: fadeIn 0.3s ease-out;
}

.hint-text.visible {
    display: block;
}

.submit-btn {
    width: 100%;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 12px;
    padding: 1.1rem;
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(0, 30, 179, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.submit-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 30, 179, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Écran de Victoire */
.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 30, 179, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.victory-overlay.active {
    display: flex;
    opacity: 1;
}

.victory-content {
    background: #FFFFFF;
    border: 1px solid var(--border-active);
    border-radius: 30px;
    max-width: 600px;
    width: 100%;
    padding: 4rem 3rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 50px rgba(0, 30, 179, 0.2);
    transform: scale(0.9);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    var(--glass);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.victory-overlay.active .victory-content {
    transform: scale(1);
}

.victory-badge {
    font-size: 5rem;
    color: var(--accent-gold);
    margin-bottom: 2rem;
    filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.3));
    display: inline-block;
    animation: scalePop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scalePop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.victory-title {
    font-family: var(--font-title);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--primary);
    -webkit-background-clip: text;
    
}

.victory-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 2.5rem;
}

.victory-card {
    background: #F8FAFC;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    text-align: left;
}

.victory-card-title {
    font-family: var(--font-title);
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.victory-actions {
    display: flex;
    gap: 1rem;
}

.victory-btn {
    flex: 1;
    padding: 1rem;
    border-radius: 10px;
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.victory-btn.primary {
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
}

.victory-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.victory-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.victory-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

/* Pied de page */
footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
}

/* Responsivité */
@media (max-width: 1024px) {
    .itinerary-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    .map-wrapper {
        height: 400px;
    }

    .steps-list {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .challenge-card, .victory-content {
        padding: 2.5rem 1.5rem;
    }
    
    .victory-actions {
        flex-direction: column;
    }
}

/* Styles pour les marqueurs personnalisés de la carte */
.custom-marker {
    background: none !important;
    border: none !important;
}

.marker-pin-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    background: var(--primary);
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), 0 0 8px var(--primary-glow);
    border: 2px solid var(--text-main);
    transition: var(--transition);
}

.marker-pin-wrapper span {
    transform: rotate(45deg);
    color: var(--bg-dark);
    font-weight: 800;
    font-family: var(--font-title);
    font-size: 0.9rem;
    display: block;
    text-align: center;
}

.custom-marker.active .marker-pin-wrapper {
    background: var(--accent-gold);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(251, 191, 36, 0.8);
    transform: rotate(-45deg) scale(1.18);
    border-color: var(--text-main);
}

.custom-marker.active .marker-pin-wrapper span {
    color: #000;
}

/* Écran de Démarrage */
.start-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 30, 179, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center; justify-content: center;
    padding: 2rem;
    backdrop-filter: blur(8px);
    transition: opacity 0.5s ease-out;
}

.start-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    max-width: 500px; width: 100%;
    padding: 3rem 2rem;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.start-title {
    font-family: var(--font-title);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.start-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.start-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

.start-btn {
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    padding: 1.2rem 2rem;
    border-radius: 12px;
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 30, 179, 0.3);
}

.start-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Bouton Pause dans l'étape */
.pause-btn {
    margin-top: 1rem;
    width: 100%;
    background: rgba(251, 191, 36, 0.1);
    color: var(--accent-gold);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pause-btn:hover {
    background: rgba(251, 191, 36, 0.2);
}

.pause-btn.paused {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: rgba(0, 30, 179, 0.3);
}

.pause-btn.paused:hover {
    background: rgba(0, 30, 179, 0.2);
}

/* Bouton Centrer sur moi */
.locate-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    color: var(--primary);
    transition: var(--transition);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

.locate-btn:hover {
    background: var(--bg-card-hover);
    transform: scale(1.05);
}

/* Point GPS de l'utilisateur */
.user-location-marker {
    background: none !important;
    border: none !important;
}

.user-dot {
    width: 16px;
    height: 16px;
    background-color: #3b82f6; /* Bleu vif */
    border: 3px solid #fff;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

.user-dot::after {
    content: '';
    position: absolute;
    top: -12px;
    left: -12px;
    width: 34px;
    height: 34px;
    background-color: rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    animation: pulseGps 2s infinite ease-out;
    pointer-events: none;
}

@keyframes pulseGps {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}
