/* ================================
   VARIABLES & BASE
   ================================ */
:root {
    --green-dark: #1B5E20;
    --green-main: #2E7D32;
    --green-mid: #388E3C;
    --green-light: #4CAF50;
    --green-pale: #E8F5E9;
    --green-border: #C8E6C9;
    --red: #E53935;
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --bg: #F4F6F8;
    --white: #FFFFFF;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --radius: 14px;
    --radius-lg: 20px;
    --radius-pill: 50px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg);
}

body {
    display: flex;
    flex-direction: column;
}

/* ================================
   NAVIGATION & ECRANS
   ================================ */
.hidden {
    display: none !important;
}

.ecran {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ================================
   ECRANS CONNEXION & INSCRIPTION
   ================================ */
#ecran-connexion,
#ecran-inscription {
    justify-content: center;
    align-items: center;
    background: linear-gradient(155deg, var(--green-dark) 0%, var(--green-mid) 60%, #66BB6A 100%);
    padding: 30px 20px;
}

.form-container {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 36px 28px 28px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.app-logo {
    font-size: 52px;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.form-container h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.app-tagline {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px !important;
}

.input-group {
    position: relative;
    margin-bottom: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #E5E7EB;
    border-radius: var(--radius);
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    background: #FAFAFA;
    color: var(--text-primary);
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    border-color: var(--green-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

input::placeholder {
    color: #9CA3AF;
    font-size: 14px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    font-size: 13.5px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    text-align: left;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--green-light);
    cursor: pointer;
    margin: 0;
}

.switch-text {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ================================
   BOUTONS
   ================================ */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--green-light), var(--green-main));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.35);
    transition: transform 0.15s, box-shadow 0.15s, background-color 0.3s;
    letter-spacing: 0.3px;
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.25);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn-text {
    background: none;
    border: none;
    color: var(--green-light);
    font-weight: 600;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    margin-top: 4px;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.btn-text:active {
    color: var(--green-main);
}

.btn-correct {
    background: linear-gradient(135deg, #43A047, #2E7D32) !important;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.4) !important;
}

.btn-incorrect {
    background: linear-gradient(135deg, #EF5350, #C62828) !important;
    box-shadow: 0 4px 15px rgba(198, 40, 40, 0.4) !important;
}

/* ================================
   TOP BARS
   ================================ */
#top-bar-accueil,
#top-bar-details,
#top-bar-question {
    height: 64px;
    background: var(--white);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    flex-shrink: 0;
}

#top-bar-accueil {
    justify-content: space-between;
}

#top-bar-details,
#top-bar-question {
    justify-content: center;
    position: relative;
}

.app-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--green-main);
    letter-spacing: -0.3px;
}

#btn-logout {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
}

#btn-logout:active {
    background: var(--green-pale);
}

/* ================================
   MAP & ECRAN ACCUEIL
   ================================ */
#map-container {
    flex: 1;
    background-color: #e5e3df;
    z-index: 1;
}

/* ================================
   BOTTOM BAR
   ================================ */
#bottom-bar {
    min-height: 72px;
    height: auto;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.07);
    z-index: 1000;
    padding-top: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

#bottom-bar button {
    background: none;
    border: none;
    font-size: 26px;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 12px;
    transition: background 0.2s, transform 0.15s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#bottom-bar button:active {
    transform: scale(0.88);
    background: var(--green-pale);
}

/* ================================
   PANEL JEU
   ================================ */
#panel-jeu {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    z-index: 2000;
    border-radius: 28px 28px 0 0;
    padding: 24px 24px calc(32px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 35px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#jeu-etape-titre {
    font-size: 18px;
    font-weight: 700;
    color: var(--green-main);
}

#jeu-etape-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
}

#btn-quitter-jeu {
    background: #FFEBEE;
    border: none;
    color: var(--red);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    padding: 6px 12px;
    border-radius: 10px;
    transition: background 0.2s, transform 0.15s;
}

#btn-quitter-jeu:active {
    transform: scale(0.95);
    background: #FFCDD2;
}

/* ================================
   CONTENU DES ÉCRANS (DÉTAILS & QUESTION)
   ================================ */
.ecran-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    background-color: var(--white);
    display: flex;
    flex-direction: column;
}

.btn-retour {
    position: absolute;
    left: 16px;
    background: var(--bg);
    border: none;
    font-size: 20px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-retour:active {
    background: #E5E7EB;
}

#top-bar-details h2,
#top-bar-question h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Fiche parcours */
#details-titre {
    font-size: 26px;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 18px;
    line-height: 1.25;
}

.details-badges {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--green-main);
    background: var(--green-pale);
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--green-border);
    box-shadow: var(--shadow-sm);
}

.details-desc-container {
    flex: 1;
    margin-bottom: 24px;
}

.details-desc-container h3 {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-weight: 700;
}

#details-desc {
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 15px;
}

/* Écran Question */
.question-step-title {
    color: var(--green-main);
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.question-card {
    background: var(--bg);
    padding: 22px;
    border-radius: var(--radius-lg);
    border: 1px solid #E5E7EB;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

#question-texte {
    font-size: 17px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.5;
}

.reponse-container {
    margin-bottom: 24px;
}

.reponse-container input {
    background: var(--white);
    border: 2px solid #E5E7EB;
    font-size: 16px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.reponse-container input:focus {
    border-color: var(--green-main);
    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.15);
}

.btn-bottom {
    margin-top: auto;
    font-size: 16px;
    padding: 16px;
}

/* ================================
   SCORE BADGE
   ================================ */
.score-badge {
    position: absolute;
    right: 16px;
    background: linear-gradient(135deg, var(--green-pale), #D0F0D6);
    color: var(--green-main);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--green-border);
    box-shadow: var(--shadow-sm);
    font-family: 'Poppins', sans-serif;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.95);
    color: var(--white);
    padding: 14px 24px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ================================
   CUSTOM MODAL CONFIRMATION
   ================================ */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.custom-modal-box {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    width: 100%;
    text-align: center;
}

.custom-modal-box h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.custom-modal-box p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.custom-modal-actions {
    display: flex;
    gap: 12px;
}

.custom-modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    background: #E5E7EB;
    color: var(--text-primary);
    border: none;
    transition: background 0.2s, transform 0.15s;
}

.btn-secondary:active {
    background: #D1D5DB;
    transform: scale(0.97);
}

/* ================================
   ONGLETS ET CONTENU (HISTORIQUE & PROFIL)
   ================================ */
#bottom-bar button.active {
    background: var(--green-pale);
    transform: scale(1.05);
}

.historique-liste {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.historique-item {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.historique-item h4 {
    font-size: 16px;
    color: var(--text-primary);
}

.historique-item span {
    font-size: 14px;
    font-weight: 700;
    color: var(--green-main);
}

.profil-card {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 15px;
    color: var(--text-primary);
}

/* ================================
   PWA & NETWORK STATUS BADGE
   ================================ */
.network-badge {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    transition: all 0.3s ease;
}

.network-badge.offline {
    background: #DC2626;
    /* Rouge pour hors-ligne */
}

.network-badge.online {
    background: var(--green-main);
}

/* ================================
   SAFE AREAS iOS (encoche / Dynamic Island / barre du bas)
   ================================ */
#top-bar-accueil,
#top-bar-details,
#top-bar-question,
#top-bar-resultats {
    padding-top: env(safe-area-inset-top) !important;
    height: calc(64px + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
}

#ecran-connexion,
#ecran-inscription {
    padding-top: calc(30px + env(safe-area-inset-top));
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
}

.network-badge {
    top: calc(16px + env(safe-area-inset-top));
}

.toast-container {
    top: calc(20px + env(safe-area-inset-top));
}