/* ===== CONFIGURATION MODIFIABLE ===== */
/* Hauteur de la carte (en px) */
:root {
    --map-height: 600px;
    --tooltip-width: 400px;
    --header-height: 50px;
    
    /* Couleurs mode clair */
    --bg-primary: #fafafa;
    --bg-secondary: white;
    --bg-tertiary: #f8fafc;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #e2e8f0;
    --header-bg: white;
    --header-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --control-bg: rgba(255,255,255,0.97);
    --control-border: #2563eb;
    --panel-bg: rgba(255,255,255,0.98);
    --input-bg: white;
    --input-border: #2563eb;
    --hover-bg: #f0f9ff;
}

html.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --header-bg: #1e293b;
    --header-shadow: 0 2px 4px rgba(0,0,0,0.3);
    --control-bg: rgba(30, 41, 59, 0.95);
    --control-border: #3b82f6;
    --panel-bg: rgba(30, 41, 59, 0.98);
    --input-bg: #0f172a;
    --input-border: #3b82f6;
    --hover-bg: #1e3a8a;
}

/* Styles spécifiques pour le mode nuit */
html.dark-mode .rating-instruction {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

html.dark-mode .rating-value {
    background: #1e3a8a !important;
    color: #e0f2fe !important;
}

html.dark-mode .rating-comment::placeholder {
    color: #ffffff !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

header {
    background: var(--header-bg);
    height: 60px;
    padding: 0 2rem;
    box-shadow: var(--header-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 2rem;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.logo {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--control-border);
    white-space: nowrap;
    flex-shrink: 0;
}

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

nav button {
    background: none;
    border: 2px solid transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

nav button:hover {
    background-color: var(--hover-bg);
}

nav button.active {
    background-color: var(--control-border);
    color: white;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.section {
    display: none;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background-color 0.3s;
}

.section.active {
    display: block;
}

/* Section carte-existantes en plein écran */
#carte-existantes {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 1;
    background: transparent;
}

#carte-existantes.active {
    display: block;
}

/* Carte remplit tout l'espace après le header */
#carte-existantes #map-existantes {
    width: 100vw !important;
    height: calc(100vh - var(--header-height)) !important;
    position: fixed !important;
    top: var(--header-height) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.section h2 {
    color: var(--control-border);
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.placeholder {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    margin-top: 1rem;
}

/* Styles pour le système de notation */
.rating-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 1200;
    background: rgba(255,255,255,0.98);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    width: 300px;
    font-family: 'DM Sans', sans-serif;
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.rating-panel.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.rating-panel h4 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.rating-criteria {
    margin-bottom: 15px;
}

.rating-criteria label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.rating-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    outline: none;
    margin: 4px 0;
    cursor: pointer;
}

/* Supprimer les contours bleus d'interaction Leaflet */
.leaflet-interactive:focus {
    outline: none !important;
}
.leaflet-control:focus {
    outline: none !important;
}

/* Désactiver le contour bleu au survol sur les éléments Leaflet */
.leaflet-interactive {
    outline: none !important;
}

/* Très important : enlever la bordure au survol */
.leaflet-path:hover {
    stroke: inherit !important;
    stroke-width: inherit !important;
}

.rating-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.rating-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Styles pour les tooltips personnalisés */
.custom-tooltip {
    background: white !important;
    border: 2px solid #2563eb !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    max-width: 300px !important;
}

.custom-tooltip::before {
    border-top-color: #2563eb !important;
}

.rating-value {
    display: inline-block;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.rating-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn.primary {
    background: #2563eb;
    color: white;
}

.btn.primary:hover {
    background: #1d4ed8;
}

.btn.secondary {
    background: var(--text-secondary);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: var(--hover-bg);
}

.rating-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 10px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    transition: background-color 0.3s, color 0.3s;
}

/* Styles pour les boîtes d'info dans les sections */
.info-box {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    transition: background-color 0.3s;
}

/* Styles pour le panneau flottant hamburger (Rate Your Track style) */
.leaflet-control-floating-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 1000;
}

.floating-panel-btn {
    width: 50px;
    height: 50px;
    background: white;
    border: 2px solid #2563eb;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

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

.floating-panel-btn span {
    width: 24px;
    height: 3px;
    background: var(--control-border);
    border-radius: 2px;
    transition: all 0.3s;
}

.floating-panel-label {
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--control-bg);
    padding: 8px 12px;
    border: 2px solid var(--control-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--control-border);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.floating-panel-btn:hover + .floating-panel-label {
    opacity: 1;
}

.floating-panel-content {
    position: absolute;
    top: 0;
    left: 70px;
    background: var(--panel-bg);
    border: 2px solid var(--control-border);
    border-radius: 12px;
    padding: 20px;
    width: 320px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: none;
    font-family: 'DM Sans', sans-serif;
}

.floating-panel-content.show {
    display: block;
}

.floating-panel-content h4 {
    margin: 0 0 20px 0;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
}

/* Bouton croix de fermeture du panneau */
#close-floating-panel:hover {
    background: var(--hover-bg) !important;
    transform: scale(1.05);
}

#close-floating-panel span {
    transition: all 0.2s;
}

.view-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, var(--control-bg) 0%, var(--control-bg) 100%);
    border: 2px solid var(--control-border);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-family: 'DM Sans', sans-serif;
}

.view-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.view-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.view-selector select:hover {
    border-color: var(--control-border);
    background: var(--bg-tertiary);
}

.view-selector select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Curseur pour le mode dessin */
.leaflet-container.drawing-mode {
    cursor: crosshair !important;
}

/* Marker personnalisé pour les points de l'itinéraire */
.route-marker {
    background: white;
    border: 3px solid #2563eb;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.route-marker:hover {
    background: #fee2e2;
    border-color: #dc2626;
    transform: scale(1.2);
}

/* Styles pour les contrôles Leaflet (zoom + layers) */
.leaflet-top.leaflet-right {
    top: 175px !important; /* Positionner sous le sélecteur de vue */
}

.leaflet-control-zoom,
.leaflet-control-layers {
    border: 2px solid var(--control-border) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12) !important;
    margin-bottom: 8px !important;
    background: var(--control-bg) !important;
    transition: background-color 0.3s, border-color 0.3s;
}

.leaflet-control-layers-toggle:hover {
    background: var(--hover-bg) !important;
}

.leaflet-control-zoom a {
    border: none !important;
    border-radius: 0px !important;
    background: transparent !important;
    color: var(--control-border) !important;
}

.leaflet-control-zoom a:hover {
    background: transparent !important;
}

.leaflet-control-layers-toggle:hover {
    background: var(--hover-bg) !important;
}

.leaflet-control-layers-expanded {
    border: 2px solid var(--control-border) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    background: var(--bg-tertiary) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2) !important;
    min-width: 200px !important;
}

.leaflet-control-layers-base {
    padding-bottom: 8px !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 8px !important;
}

.leaflet-control-layers-overlays {
    padding-top: 2px !important;
}

.leaflet-control-layers-base::before {
    content: attr(data-i18n-title) !important;
    display: block !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    font-size: 12px !important;
    margin-bottom: 6px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-family: 'DM Sans', sans-serif !important;
}

/* Fallback pour navigateurs qui ne supportent pas attr() */
html[lang="fr"] .leaflet-control-layers-base::before {
    content: "🗺️ Fonds de carte" !important;
}

html[lang="es"] .leaflet-control-layers-base::before {
    content: "🗺️ Mapa base" !important;
}

/* Appliquer DM Sans à tous les éléments de la carte */
#map-existantes,
#map-existantes * ,
.leaflet-container,
.leaflet-control,
.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-control-layers-expanded,
.leaflet-popup,
.leaflet-tooltip,
#view-controls,
#view-controls *,
#floating-rating-panel,
#floating-rating-panel *,
#floating-panel-btn,
#floating-panel-label {
    font-family: 'DM Sans', sans-serif !important;
    color: var(--text-primary) !important;
}

/* Taille de police normale pour les contrôles */
.leaflet-control-zoom a,
.leaflet-control-layers {
    font-size: 14px !important;
}

/* Harmoniser les labels et inputs du panneau */
#floating-rating-panel label {
    font-weight: 500;
    color: var(--text-primary) !important;
    font-size: 14px !important;
}

#floating-rating-panel h4 {
    color: var(--text-primary) !important;
    font-size: 16px !important;
}

#floating-rating-panel .rating-value {
    background: var(--bg-tertiary);
    color: var(--text-primary) !important;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px !important;
}

#floating-rating-panel input[type="range"] {
    margin-top: 4px;
}

#floating-rating-panel div {
    color: var(--text-primary) !important;
    font-size: 13px !important;
}

#segment-info {
    font-weight: 500;
    color: var(--text-primary) !important;
    font-size: 13px !important;
}

/* Style du sélecteur de vue */
#view-controls {
    color: var(--text-primary) !important;
    font-size: 15px !important;
    transition: background-color 0.3s, color 0.3s;
}

#view-controls select {
    font-family: 'DM Sans', sans-serif !important;
    color: var(--text-primary) !important;
    background-color: var(--input-bg) !important;
    font-size: 14px !important;
    transition: background-color 0.3s, color 0.3s;
}

#view-controls div {
    color: var(--text-primary) !important;
}

/* Style des contrôles Leaflet */
.leaflet-control-layers label {
    font-family: 'DM Sans', sans-serif !important;
    font-weight: 500;
    color: var(--text-primary) !important;
    font-size: 13px !important;
    margin-bottom: 6px !important;
    display: flex !important;
    align-items: center !important;
}

.leaflet-control-layers input {
    margin-right: 8px !important;
    margin-bottom: 2px !important;
    accent-color: #2563eb !important;
}

.leaflet-control-layers-list {
    padding: 0 !important;
}

/* Effets hover sur les boutons du panneau */
#floating-rating-panel .btn.primary:hover {
    background: #1d4ed8 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
}

#floating-rating-panel .btn.warn:hover {
    background: #e67e22 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
    transition: all 0.2s;
}

#segment-info strong {
    color: var(--text-primary) !important;
}

/* Style du titre du panneau */
#floating-rating-panel h4 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Harmoniser les tooltips et popups */
.leaflet-popup-content,
.leaflet-tooltip {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 15px !important;
    color: var(--text-primary) !important;
    background-color: var(--control-bg) !important;
    border: 2px solid var(--control-border) !important;
    border-radius: 8px !important;
    padding: 14px 16px !important;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.2) !important;
    max-width: var(--tooltip-width) !important;
    width: var(--tooltip-width) !important;
    line-height: 1.6 !important;
    transition: background-color 0.3s, color 0.3s;
}

.leaflet-tooltip-right::before {
    border-right-color: var(--control-border) !important;
}

/* Boutons avec texte blanc obligatoire */
#floating-rating-panel .btn {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: white !important;
}

#floating-rating-panel .btn.primary {
    background: #2563eb !important;
    color: white !important;
}

#floating-rating-panel .btn.warn {
    background: #f39c12 !important;
    color: white !important;
}

/* ===== TOOLTIPS ADAPTATIFS ===== */
/* Largeur des bulles d'informations */
.leaflet-tooltip {
    max-width: var(--tooltip-width) !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    padding: 8px !important;
    line-height: 1.5 !important;
}

/* Style des commentaires dans les tooltips */
.leaflet-tooltip em {
    font-style: italic;
    color: #555;
    display: block;
    margin-top: 4px;
    word-break: break-word;
}

html.dark-mode .leaflet-tooltip em {
    color: #aaa;
}

/* Style pour les tooltips de segments (rate-your-track) */
.segment-tooltip {
    width: 400px;
    max-width: 400px;
    font-size: 15px;
    padding: 10px 14px;
    line-height: 1.5;
    background: #fff;
    color: #222;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    border: 1px solid #1976d2;
    z-index: 1200;
}

.segment-tooltip ul {
    margin: 2px 0 2px 12px;
    padding: 0;
    list-style: disc inside;
    word-break: break-word;
    white-space: normal;
    width: 380px;
    max-width: 380px;
}

.segment-tooltip li {
    word-break: break-word;
    white-space: normal;
    width: 380px;
    max-width: 380px;
}

/* Tablettes en mode paysage */
@media (min-width: 769px) and (max-width: 1024px) {
    #rating-panel {
        max-width: 500px;
    }

    .nav-btn {
        font-size: 14px;
        padding: 8px 14px;
    }
}

/* ===== SÉLECTEUR DE LANGUE ===== */
.language-selector {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.lang-btn {
    padding: 6px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: var(--panel-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    border-color: #4CAF50;
    background: var(--bg-secondary);
}

.lang-btn.active {
    border-color: #4CAF50;
    background: #4CAF50;
    color: white;
}
