/* ═══════════════════════════════════════════════════════════════════════
   GPX Trail Viewer v2.1 — Styles front-end
   Profil altimétrique pleine largeur (bord à bord du widget)
═══════════════════════════════════════════════════════════════════════ */

:root {
    --gpx-primary:  #2c6e49;
    --gpx-accent:   #52b788;
    --gpx-dark:     #1a1f2e;
    --gpx-text:     #2d3748;
    --gpx-muted:    #718096;
    --gpx-border:   #e2e8f0;
    --gpx-bg:       #f7fafc;
    --gpx-white:    #ffffff;
    --gpx-shadow:   0 8px 32px rgba(0,0,0,.12);
    --gpx-radius:   14px;
    --gpx-radius-sm:8px;
    --gpx-font:     'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Widget wrapper ──────────────────────────────────────────────────── */
.gpx-trail-widget {
    font-family: var(--gpx-font);
    color: var(--gpx-text);
    margin: 2em 0;
    border-radius: var(--gpx-radius);
    overflow: hidden;
    box-shadow: var(--gpx-shadow);
    background: var(--gpx-white);
}

/* ── Header ──────────────────────────────────────────────────────────── */
.gpx-header {
    padding: 1.4rem 1.8rem 1.7rem;
    background: linear-gradient(135deg, #1e3c28 0%, var(--gpx-primary) 60%, #40916c 100%);
    color: #fff;
}
.gpx-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.gpx-title-block { flex: 1; min-width: 0; }
.gpx-title {
    margin: 0 0 .3rem !important;
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    color: #fff !important;
    border: none !important;
    padding: 0 !important;
    line-height: 1.3 !important;
}
.gpx-desc { margin: 0 !important; opacity: .8; font-size: .88rem; }

/* ── Badge IBP ───────────────────────────────────────────────────────── */
.gpx-ibp-badge {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: rgba(0,0,0,.25);
    border: 2px solid var(--ibp-color, #52b788);
    border-radius: var(--gpx-radius-sm);
    padding: .5rem .9rem;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    flex-shrink: 0;
}
.gpx-ibp-emoji { font-size: 1.5rem; line-height: 1; }
.gpx-ibp-info  { display: flex; flex-direction: column; align-items: flex-start; }
.gpx-ibp-score {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--ibp-color, #52b788);
    line-height: 1;
}
.gpx-ibp-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--ibp-color, #52b788);
    line-height: 1.3;
}
.gpx-ibp-sub {
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.45);
    margin-top: .1rem;
}

.gpx-header-excerpt {
    font-size: .88rem;
    opacity: .85;
    margin: .5rem 0 0 !important;
    line-height: 1.5;
    color: #fff;
}

/* ── Boutons action ──────────────────────────────────────────────────── */
.gpx-action-buttons {
    display: flex;
    gap: .65rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.gpx-btn {
    display: inline-flex;
    flex: 1 1 auto;
    min-width: 140px;
    justify-content: center;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: all .18s ease;
    cursor: pointer;
    border: none;
    line-height: 1;
}
.gpx-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.gpx-btn-download {
    background: rgba(255,255,255,.15);
    color: #fff !important;
    border: 1.5px solid rgba(255,255,255,.4) !important;
}
.gpx-btn-download:hover { background: rgba(255,255,255,.28); border-color: rgba(255,255,255,.7); }
.gpx-btn-download svg { fill: #fff; }

.gpx-btn-pdf {
    background: rgba(255,255,255,.12);
    color: #fff !important;
    border: 1.5px solid rgba(255,165,0,.5) !important;
}
.gpx-btn-pdf:hover { background: rgba(255,165,0,.2); border-color: rgba(255,165,0,.8); }
.gpx-btn-pdf svg { fill: #ffb347; }

.gpx-btn-gmaps {
    background: #fff;
    color: var(--gpx-primary) !important;
    border: 1.5px solid rgba(255,255,255,.6) !important;
}
.gpx-btn-gmaps:hover { background: #e8f5ee; }
.gpx-btn-gmaps svg { fill: var(--gpx-primary); }

/* ══════════════════════════════════════════════════════════════════════
   BLOC MÉTÉO — style façon Météo France
══════════════════════════════════════════════════════════════════════ */
.gpx-trail-widget .gpx-weather-block {
    background: linear-gradient(135deg, #e8f4fd 0%, #dbeeff 100%);
    border-top: 1px solid rgba(255,255,255,.4);
    border-bottom-left-radius:  var(--gpx-radius);
    border-bottom-right-radius: var(--gpx-radius);
    padding: 1rem 1.4rem 1.1rem;
}

/* ── En-tête : emoji + condition/temp + lien Meteoblue ──────────── */
.gpx-trail-widget .gpx-weather-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: .9rem;
}
.gpx-trail-widget .gpx-weather-main-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.gpx-trail-widget .gpx-weather-emoji {
    font-size: 2.6rem;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.15));
}
.gpx-trail-widget .gpx-weather-primary {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.gpx-trail-widget .gpx-weather-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 700;
    color: #1a4f7a;
}
.gpx-trail-widget .gpx-weather-condition-temp {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
}
.gpx-trail-widget .gpx-weather-condition {
    font-size: 1rem;
    font-weight: 700;
    color: #1a3a5c;
}
.gpx-trail-widget .gpx-weather-temp {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0d2d47;
}
.gpx-trail-widget .gpx-weather-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .75rem;
    font-weight: 700;
    color: #1a5276 !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
    transition: color .15s;
    white-space: nowrap;
    border-bottom: none !important; /* neutralise TEC */
}
.gpx-trail-widget .gpx-weather-link:hover { color: #0d2d47 !important; }
.gpx-trail-widget .gpx-weather-link svg {
    width: 13px; height: 13px;
    fill: #1a5276;
    flex-shrink: 0;
}

/* ── Grille des tuiles de détail ────────────────────────────────── */
.gpx-trail-widget .gpx-weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .55rem;
}
.gpx-trail-widget .gpx-wd-item {
    background: rgba(255,255,255,.65);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 8px;
    padding: .55rem .65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    text-align: center;
    backdrop-filter: blur(4px);
    transition: background .15s;
}
.gpx-trail-widget .gpx-wd-item:hover {
    background: rgba(255,255,255,.85);
}

/* Pictogramme SVG */
.gpx-trail-widget .gpx-wd-icon {
    width: 26px;
    height: 26px;
    fill: #2471a3;
    flex-shrink: 0;
}

/* Libellé de la tuile */
.gpx-trail-widget .gpx-wd-label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #2471a3;
    font-weight: 700;
    line-height: 1.2;
}

/* Valeur */
.gpx-trail-widget .gpx-wd-val {
    font-size: .95rem;
    font-weight: 800;
    color: #0d2d47;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Alerte (rafales, précip élevées) */
.gpx-trail-widget .gpx-wd-alert {
    color: #c0392b !important;
}

/* Label UV en italique discret */
.gpx-trail-widget .gpx-wd-uv-label {
    font-size: .65rem;
    font-style: normal;
    font-weight: 600;
    opacity: .85;
}

/* ── Graphique météo horaire ─────────────────────────────────────────── */
.gpx-trail-widget .gpx-wx-chart-wrap {
    margin-top: .9rem;
    background: rgba(255,255,255,.55);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 8px;
    padding: .7rem .8rem .5rem;
}
.gpx-trail-widget .gpx-wx-chart-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 700;
    color: #1a4f7a;
    margin-bottom: .5rem;
}
.gpx-trail-widget .gpx-wx-chart-outer {
    position: relative;
    height: 140px;
}
.gpx-trail-widget .gpx-wx-chart-outer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 600px) {
    .gpx-trail-widget .gpx-wx-chart-outer { height: 110px; }
}
/* .tribe-events-content .gpx-trail-widget a {
    border-bottom: none !important;
} */
.tribe-events-content a {
	border-bottom: 1px solid var(--tec-color-link-accent);
}

@media (max-width: 600px) {
    .gpx-trail-widget .gpx-weather-block  { padding: .8rem 1rem; }
    .gpx-trail-widget .gpx-weather-top    { flex-direction: column; align-items: flex-start; }
    .gpx-trail-widget .gpx-weather-details {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Barre de statistiques ───────────────────────────────────────────── */
.gpx-stats-bar {
    display: flex;
    flex-wrap: wrap;
    background: var(--gpx-dark);
}
.gpx-stat-item {
    flex: 1 1 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .9rem .6rem;
    border-right: 1px solid rgba(255,255,255,.06);
    transition: background .18s;
    min-width: 0;
}
.gpx-stat-item:last-child { border-right: none; }
.gpx-stat-item:hover      { background: rgba(255,255,255,.04); }
.gpx-stat-item.gpx-stat-highlight {
    background: rgba(82,183,136,.08);
    border-top: 2px solid var(--gpx-accent);
    margin-top: -2px;
}
.gpx-stat-item svg {
    width: 18px; height: 18px;
    fill: var(--gpx-accent);
    margin-bottom: .3rem;
    flex-shrink: 0;
}
.gpx-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    text-align: center;
}
.gpx-stat-label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.45);
    margin-top: .2rem;
    text-align: center;
    line-height: 1.3;
}

/* ── Carte ───────────────────────────────────────────────────────────── */
.gpx-map-container { position: relative; }
.gpx-map           { width: 100%; z-index: 1; }

.gpx-map-controls {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.gpx-ctrl-btn {
    width: 34px; height: 34px;
    border: 2px solid rgba(0,0,0,.2);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 5px rgba(0,0,0,.25);
    transition: background .15s, transform .1s;
}
.gpx-ctrl-btn:hover { background: #f0f0f0; transform: scale(1.05); }
.gpx-ctrl-btn svg   { width: 18px; height: 18px; fill: #444; }

/* Bouton géolocalisation : bleu quand actif, rouge bref si erreur */
.gpx-ctrl-btn.active            { background: #4285f4; border-color: #4285f4; }
.gpx-ctrl-btn.active svg        { fill: #fff; }
.gpx-ctrl-btn.error             { background: #e74c3c; border-color: #e74c3c; }
.gpx-ctrl-btn.error svg         { fill: #fff; }

/* ══════════════════════════════════════════════════════════════════════
   PROFIL ALTIMÉTRIQUE — PLEINE LARGEUR (bord à bord)
   Pas de padding latéral : le graphique occupe toute la largeur du widget.
══════════════════════════════════════════════════════════════════════ */
.gpx-chart-wrap {
    background: var(--gpx-bg);
    border-top: 1px solid var(--gpx-border);
    /* Pas de padding horizontal → pleine largeur */
}
.gpx-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    padding: .75rem 1.2rem .4rem; /* padding uniquement pour le header texte */
}
.gpx-chart-title {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    color: var(--gpx-muted);
}
.gpx-chart-smoothed {
    font-weight: 400;
    font-style: italic;
    color: var(--gpx-accent);
}
.gpx-chart-hint {
    font-size: .78rem;
    color: var(--gpx-primary);
    font-weight: 600;
    text-align: right;
}
/* Conteneur du canvas : padding latéral léger, hauteur paramétrable */
.gpx-chart-outer {
    position: relative;
    width: 100%;
    padding: 0 0.5rem 1rem; /* 0 1.2rem 1rem; */
    box-sizing: border-box;
    /* height fixé inline depuis PHP */
}
/* Canvas lui-même : display block supprime l'espace sous canvas */
.gpx-chart-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── Marqueur curseur carte ──────────────────────────────────────────── */
.gpx-cursor-marker {
    width: 14px !important;
    height: 14px !important;
    background: var(--gpx-white);
    border: 3px solid #3366CC; /* sera surchargé dynamiquement en JS */
    border-radius: 50%;
    margin-top: -7px;
    margin-left: -7px;
}

/* ── Point de géolocalisation live (façon Google Maps / Visiorando) ──── */
.gpx-geoloc-marker  { position: relative; }
.gpx-geoloc-dot {
    position: absolute;
    top: 50%; left: 50%;
    width: 14px; height: 14px;
    margin: -7px 0 0 -7px;
    background: #4285f4;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.gpx-geoloc-pulse {
    position: absolute;
    top: 50%; left: 50%;
    width: 14px; height: 14px;
    margin: -7px 0 0 -7px;
    background: rgba(66,133,244,.35);
    border-radius: 50%;
    animation: gpx-geoloc-pulse-anim 2s ease-out infinite;
}
@keyframes gpx-geoloc-pulse-anim {
    0%   { transform: scale(1);   opacity: .7; }
    100% { transform: scale(2.6); opacity: 0;  }
}

/* ── Popups Leaflet ──────────────────────────────────────────────────── */
.gpx-trail-widget .leaflet-popup-content-wrapper {
    border-radius: var(--gpx-radius-sm);
    box-shadow: var(--gpx-shadow);
    font-family: var(--gpx-font);
}
.gpx-trail-widget .leaflet-popup-content { margin: .65rem 1rem; }
.gpx-wpt-popup h4 { margin: 0 0 .2rem; font-size: .9rem; color: var(--gpx-primary); }
.gpx-wpt-popup p  { margin: .15rem 0 0; font-size: .8rem; color: var(--gpx-muted); }

/* ── Marqueurs D / A ─────────────────────────────────────────────────── */
.gpx-marker-s, .gpx-marker-e {
    border-radius: 50%;
    border: 3px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .68rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    font-family: var(--gpx-font);
}
.gpx-marker-s { background: var(--gpx-accent); }
.gpx-marker-e { background: #e74c3c; }

/* ── Erreur ──────────────────────────────────────────────────────────── */
.gpx-error {
    padding: 1rem 1.4rem;
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
    color: #c0392b;
    border-radius: 0 var(--gpx-radius-sm) var(--gpx-radius-sm) 0;
    margin: 1rem 0;
    font-family: var(--gpx-font);
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .gpx-header         { padding: 1rem; }
    .gpx-ibp-badge      { padding: .4rem .7rem; }
    .gpx-ibp-score      { font-size: 1rem; }
    .gpx-stat-item      { flex: 1 1 80px; padding: .7rem .4rem; }
    .gpx-stat-value     { font-size: .85rem; }
    .gpx-action-buttons { gap: .45rem; }
    .gpx-btn            { font-size: .78rem; padding: .45rem .8rem; }
    .gpx-chart-header   { padding: .6rem .8rem .3rem; }
}
@media (max-width: 420px) {
    .gpx-title    { font-size: 1.1rem !important; }
    .gpx-stat-item{ flex: 1 1 70px; }
}

/* ══════════════════════════════════════════════════════════════════════
   CARTE — sélecteur de fonds, échelle, message deux doigts (v3.5)
══════════════════════════════════════════════════════════════════════ */
.gpx-trail-widget .leaflet-control-layers {
    border: 2px solid rgba(0,0,0,.2);
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
/* Bouton du sélecteur à la taille des boutons de zoom (Leaflet le fait
   en 44 px sur écran tactile, 36 px sinon). */
.gpx-trail-widget .leaflet-control-layers-toggle,
.gpx-trail-widget.gpx-trail-widget .leaflet-touch .leaflet-control-layers-toggle {
    width: 30px;
    height: 30px;
    background-size: 18px 18px;
}
.gpx-trail-widget .leaflet-control-layers-expanded {
    padding: .4rem .7rem .4rem .5rem;
    font-size: .85rem;
    line-height: 1.5;
    color: #333;
}
.gpx-trail-widget .leaflet-control-layers-base label { margin: .15rem 0; cursor: pointer; }
.gpx-trail-widget .leaflet-control-layers-selector { margin-right: .35rem; }
.gpx-trail-widget .leaflet-control-scale-line {
    border-color: #444;
    background: rgba(255,255,255,.8);
    color: #333;
    font-size: 11px;
}
/* Message « deux doigts » : taille adaptée aux petites cartes */
.gpx-trail-widget .leaflet-container:after {
    font-size: 1.15rem;
    text-align: center;
    line-height: 1.4;
}
@media (max-width: 680px) {
    .gpx-trail-widget .leaflet-container:after { font-size: 1rem; }
}

/* ── Haut de la page d'un parcours : retour aux cartes + dates ───────── */
.gpx-single-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    margin: 0 0 1rem;
    font-family: var(--gpx-font);
}
.gpx-back-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--gpx-primary) !important;
    text-decoration: none !important;
}
.gpx-back-link:hover, .gpx-back-link:focus-visible { text-decoration: underline !important; }
.gpx-back-link svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.gpx-single-dates {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
    font-size: .85rem;
    line-height: 1.4;
    color: var(--gpx-muted);
}
.gpx-single-date { display: flex; align-items: center; gap: .3rem; }
.gpx-single-date strong { color: var(--gpx-text); font-weight: 600; }
.gpx-single-date svg { width: 14px; height: 14px; fill: var(--gpx-accent); flex-shrink: 0; }
.gpx-single-date-next svg { fill: var(--gpx-primary); }
.gpx-single-date-never svg { fill: var(--gpx-muted); }
