/* Sendel — Main Styles */

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --bg: #f5f5f5;
    --sidebar-bg: #fff;
    --text: #333;
    --text-light: #666;
    --border: #ddd;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.header {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.home-link {
    display: inline-block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.home-link:hover h1 {
    opacity: 0.85;
}

.main {
    display: flex;
    height: calc(100vh - 80px);
}

.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem;
}

.search-form {
    flex-shrink: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

.checkbox-group small {
    font-size: 0.75rem;
    color: var(--text-light);
    opacity: 0.8;
}

.form-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-group input,
.form-group select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    cursor: progress;
}

/* Bouton secondaire : sert notamment de bascule du mode « ajout de point de
   passage ». L'état actif (mode enclenché) est rendu en surbrillance. */
.btn-secondary {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    width: 100%;
}

.btn-secondary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-secondary.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.25);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.25rem 0;
    text-decoration: underline;
}

.btn-link.danger {
    color: #c0392b;
}

.btn-link:hover {
    text-decoration: none;
}

/* Pendant la recherche, un petit point (tête) glisse le long du pourtour
   intérieur du bouton, suivi d'un point plus pâle (traînée) décalé en phase.
   offset-path suit le chemin rectangulaire arrondi, indépendamment du
   libellé ; la couleur blanche contraste sur le fond rouge du bouton. */
.btn-primary.loading {
    position: relative;
    cursor: progress;
}

.btn-primary.loading::after,
.btn-primary.loading::before {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    /* Chemin rétracté : le point circule à l'intérieur du bouton. */
    offset-path: xywh(4px 4px calc(100% - 8px) calc(100% - 8px)
                      round calc(var(--radius) - 4px));
    offset-rotate: 0deg;
    animation: spinner-glow 1.2s linear infinite;
}

/* Tête : blanc vif. Traînée : juste derrière, blanche translucide. */
.btn-primary.loading::after {
    background: #fff;
}

.btn-primary.loading::before {
    background: rgba(255, 255, 255, 0.4);
    /* Juste derrière la tête (~6% du chemin en retard). */
    animation-delay: -1.13s;
}

@keyframes spinner-glow {
    to { offset-distance: 100%; }
}

.results-panel {
    flex: 0 0 340px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem;
}

.result-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-card.selected {
    border-color: var(--primary);
    background: rgba(231, 76, 60, 0.06);
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.25);
}

.result-card.dimmed {
    opacity: 0.6;
    filter: grayscale(0.6);
    background: #f0f0f0;
    border-color: #ccc;
    border-style: dashed;
}

.result-card.dimmed h3 {
    text-decoration: line-through;
}

.dimmed-tag {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--text-light);
    color: #fff;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
}

.result-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.result-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.result-stats .unpaved-stat {
    color: var(--text-light);
    font-style: italic;
    white-space: nowrap;
}

.result-stats .traffic-stat {
    color: var(--text-light);
    font-style: italic;
    white-space: nowrap;
}

.result-stats .trail-stat {
    color: var(--text-light);
    font-style: italic;
    white-space: nowrap;
}

.route-type-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.route-type-badge.road { background: #3498db22; color: #3498db; }
.route-type-badge.trail { background: #27ae6022; color: #27ae60; }
.route-type-badge.mixed { background: #f39c1222; color: #f39c12; }

.map-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#map {
    flex: 1;
}

.elevation-chart {
    height: 120px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
}

.route-detail {
    flex-shrink: 0;
    height: 120px;
    overflow-y: auto;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text);
}

.route-detail-empty {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.route-detail-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.route-detail-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.route-detail-ok {
    color: #27ae60;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}

.route-detail-fail {
    color: #e67e22;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: underline wavy;
    text-underline-offset: 3px;
}

.route-detail-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.route-detail-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.no-data,
.no-results {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.start-marker {
    background: none;
    border: none;
}

.marker-inner {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Marqueur de point de passage : même gabarit que le départ mais en bleu,
   pour distinguer visuellement les étapes imposées du point de départ. */
.waypoint-marker {
    background: none;
    border: none;
}

.waypoint-marker .marker-inner {
    width: 26px;
    height: 26px;
    background: #2980b9;
    font-size: 13px;
    border: 2px solid #fff;
}

.form-group small {
    color: var(--text-light);
    font-size: 0.75rem;
}

.time-inputs {
    display: flex;
    gap: 0.5rem;
}

.time-field {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.time-field input {
    width: 100%;
    min-width: 0;
}

.time-unit {
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
}

.range-duo {
    display: flex;
    gap: 1rem;
}

.range-duo-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.range-duo-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.range-unit {
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
}

.range-duo-field output {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.waypoints-list {
    list-style: none;
    margin: 0.5rem 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 150px;
    overflow-y: auto;
}

.waypoint-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.waypoint-index {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2980b9;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.waypoint-coords {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-light);
}

.waypoint-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #c0392b;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
}

.waypoint-remove:hover {
    color: #922b21;
}

.debug-toggle {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.debug-toggle label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.debug-sub {
    margin-left: 1.2rem;
}

.debug-info {
    position: absolute;
    left: 0;
    bottom: 240px;
    right: 0;
    z-index: 500;
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crit-fail {
    color: #e67e22;
    font-weight: 700;
    text-decoration: underline wavy;
    text-underline-offset: 3px;
}

.hidden {
    display: none !important;
}
