/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #2ecc71;
  --green-dark: #27ae60;
  --blue: #2980b9;
  --red: #e74c3c;
  --grey-bg: #f4f6f8;
  --grey-border: #dce1e7;
  --grey-text: #555;
  --white: #fff;
  --shadow: 0 2px 8px rgba(0,0,0,.10);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Eurovelo route colors (must match ROUTE_COLORS in app/constants.py) */
  --route-EV3:  #e74c3c;
  --route-EV4:  #3498db;
  --route-EV5:  #e67e22;
  --route-EV6:  #9b59b6;
  --route-EV8:  #1abc9c;
  --route-EV15: #f39c12;
  --route-EV19: #2ecc71;
  --route-VEL:  #e91e63;
  --route-VIA:  #00bcd4;
}

body { font-family: var(--font); background: var(--grey-bg); color: #2c3e50; font-size: 14px; height: 100vh; display: flex; flex-direction: column; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--green-dark);
  color: var(--white);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.logo { font-size: 1.2rem; font-weight: 700; }
.tagline { font-size: 0.9rem; opacity: .85; }

/* Header nav links */
.header-nav {
  display: flex;
  gap: 8px;
}
.btn-header-link {
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
  color: var(--white);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 15px;
  font-family: var(--font);
  transition: background .15s;
}
.btn-header-link:hover { background: rgba(255,255,255,.15); }

/* Settings button in header */
.btn-settings {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
  color: var(--white);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-settings:hover { background: rgba(255,255,255,.15); }

/* Settings panel (proxy URL) */
.settings-panel {
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
  padding: 12px 20px;
  flex-shrink: 0;
}
.settings-inner { max-width: 480px; }
.settings-hint { font-size: 13px; color: var(--grey-text); margin: 4px 0 8px; }
.settings-inner input[type="text"] { margin-bottom: 8px; }
.btn-save-proxy {
  padding: 6px 14px;
  background: var(--green-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.btn-save-proxy:hover { background: var(--green); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left panel */
.panel-left {
  width: 340px;
  min-width: 280px;
  background: var(--white);
  border-right: 1px solid var(--grey-border);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

/* Right panel */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-container {
  flex: 0 0 auto;
  max-height: 32vh;
  overflow-y: auto;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
}

.map-container {
  flex: 1;
  min-height: 200px;
}

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group > label { display: block; font-weight: 600; margin-bottom: 6px; color: #2c3e50; font-size: 0.85rem; }

input[type="text"],
input[type="date"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--white);
  color: #2c3e50;
}
input[type="text"]:focus, select:focus, input[type="date"]:focus {
  outline: none;
  border-color: var(--green);
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  list-style: none;
  position: absolute;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  width: 290px;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}
.autocomplete-item:hover,
.autocomplete-item.active { background: #eaf7f0; }

/* Rhythm radio buttons */
.rhythm-options { display: flex; flex-direction: column; gap: 6px; }
.rhythm-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: border-color .15s;
}
.rhythm-label:hover { border-color: var(--grey-border); }
.rhythm-label input[type="radio"] { 
  accent-color: var(--green); 
  margin: 0;
  flex-shrink: 0;
}
.rhythm-text { 
  display: flex; 
  flex-direction: row; 
  align-items: center; 
  gap: 8px;
}
.rhythm-name { font-weight: 600; font-size: 13px; }
.rhythm-detail { font-size: 12px; color: var(--grey-text); }

/* Route checkboxes */
.route-select-all {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--grey-text);
}
.route-checkboxes { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.route-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
}
.route-label:hover { background: #f0f0f0; }
.route-label input[type="checkbox"] { accent-color: var(--green); }

/* Booking link button (train reservation) */
.btn-book {
  display: inline-block;
  padding: 5px 10px;
  background: var(--green-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-book:hover { background: var(--green); }
.journey-book { margin-top: 6px; }
.housing-null { font-style: italic; color: var(--grey-text); }

/* Search button */
.btn-search {
  width: 100%;
  padding: 10px;
  background: var(--green-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-search:hover { background: var(--green); }
.btn-search:disabled { background: #aaa; cursor: not-allowed; }

.form-group.housing-toggle {
  margin-top: 20px;
  margin-bottom: 24px;
}

.housing-legend {
  margin-top: 8px;
  margin-left: 20px;
  font-size: 13px;
  color: var(--grey-text);
  line-height: 1.4;
}

/* Status message */
.search-status { margin-top: 8px; font-size: 14px; padding: 6px 8px; border-radius: 4px; }
.status-info { background: #eaf7f0; color: var(--green-dark); }
.status-error { background: #fdecea; color: var(--red); }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-placeholder, .no-results { color: var(--grey-text); padding: 4px 0; font-size: 15px; }

.results-heading { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: #2c3e50; }

.itinerary-card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.itinerary-card:hover { box-shadow: var(--shadow); border-color: var(--green); }
.itinerary-card.expanded { border-color: var(--green-dark); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px 6px;
}
.card-title { display: flex; align-items: center; gap: 8px; }
.route-badge {
  background: var(--green-dark);
  color: var(--white);
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.route-name { font-weight: 600; font-size: 13px; }

/* Per-route badge colors */
.route-badge[data-route="EV3"]  { background: var(--route-EV3); }
.route-badge[data-route="EV4"]  { background: var(--route-EV4); }
.route-badge[data-route="EV5"]  { background: var(--route-EV5); }
.route-badge[data-route="EV6"]  { background: var(--route-EV6); }
.route-badge[data-route="EV8"]  { background: var(--route-EV8); }
.route-badge[data-route="EV15"] { background: var(--route-EV15); }
.route-badge[data-route="EV19"] { background: var(--route-EV19); }
.route-badge[data-route="VEL"]  { background: var(--route-VEL); }
.route-badge[data-route="VIA"]  { background: var(--route-VIA); }
.card-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--grey-text); }
.meta-km { font-weight: 600; color: var(--green-dark); }
.card-expand-icon { font-size: 10px; }

.card-journeys { padding: 0 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.journey-summary { font-size: 13px; color: var(--grey-text); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.journey-label { font-weight: 600; color: #2c3e50; min-width: 42px; }
.journey-stations { color: #2c3e50; }
.journey-time { color: var(--blue); }
.journey-duration { color: var(--grey-text); }
.journey-unknown { font-size: 13px; color: #aaa; font-style: italic; }

/* Expanded card detail */
.card-detail { padding: 10px 12px 12px; border-top: 1px solid var(--grey-border); }
.detail-section { margin-bottom: 12px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #2c3e50; }
.day-list { list-style: disc; padding-left: 18px; font-size: 13px; color: var(--grey-text); line-height: 1.7; }
.detail-section p { font-size: 13px; line-height: 1.6; color: var(--grey-text); }
.detail-section strong { color: #2c3e50; }
.journey-detail { font-size: 13px; margin-bottom: 6px; line-height: 1.6; }
.journey-missing { color: #aaa; font-style: italic; }

/* ── Map tile greyscale filter ───────────────────────────────────────────── */
/* Applied to OSM France tiles to desaturate the background while keeping    */
/* French labels readable. Route color overlays are unaffected (different    */
/* layer pane).                                                               */
.map-tiles-greyscale {
  filter: grayscale(100%) brightness(1.05);
}

/* ── Station markers on map ──────────────────────────────────────────────── */
.station-emoji-marker {
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.station-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ── Route hover floating panel ──────────────────────────────────────────── */
.route-hover-panel {
  position: fixed;
  z-index: 9999;
  width: 280px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  color: #2c3e50;
  pointer-events: auto;
}
.route-panel-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.route-panel-body { padding: 10px 12px; }
.route-panel-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}
.route-panel-desc {
  color: var(--grey-text);
  line-height: 1.5;
  margin-bottom: 8px;
}
.route-panel-meta {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--grey-text);
  line-height: 1.9;
}
.route-panel-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
}
.route-panel-link:hover { text-decoration: underline; }

/* ── Help button ─────────────────────────────────────────────────────────── */
.btn-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--blue);
  background: transparent;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1;
  padding: 0;
  transition: background .15s, color .15s;
}
.btn-help:hover { background: var(--blue); color: var(--white); }

/* ── Help modal ──────────────────────────────────────────────────────────── */
.help-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-modal[hidden] { display: none; }
.help-modal-box {
  position: relative;
  width: 50vw;
  min-width: 320px;
  max-width: 720px;
  height: 88vh;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.help-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--grey-border);
  flex-shrink: 0;
}
.help-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--grey-text);
  line-height: 1;
}
.help-modal-close:hover { color: var(--red); }
.help-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  font-size: 15px;
  line-height: 1.65;
  color: #2c3e50;
}
.help-modal-content h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-dark);
  margin: 16px 0 6px;
}
.help-modal-content h3:first-child { margin-top: 0; }
.help-modal-content p { margin-bottom: 8px; }
.help-modal-content ol,
.help-modal-content ul { padding-left: 20px; margin-bottom: 8px; }
.help-modal-content li { margin-bottom: 5px; }

/* ── Shared overlay modal (roadmap & credits) ────────────────────────────── */
.overlay-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay-modal[hidden] { display: none; }
.overlay-modal-box {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlay-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--grey-border);
  flex-shrink: 0;
}
.overlay-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--grey-text);
  line-height: 1;
}
.overlay-modal-close:hover { color: var(--red); }
.overlay-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  font-size: 14px;
  line-height: 1.65;
  color: #2c3e50;
}
.overlay-modal-content h3 {
  font-size: 15px;
  font-weight: 700;
  /* color: var(--green-dark); */
  margin: 16px 0 6px;
}
.overlay-modal-content h3:first-child { margin-top: 0; }
.overlay-modal-content p { margin-bottom: 16px; }
.overlay-modal-content ul { padding-left: 20px; margin-bottom: 8px; }
.overlay-modal-content li { margin-bottom: 5px; }
.overlay-modal-content a { color: var(--blue); }
.overlay-modal-content a:hover { text-decoration: underline; }

/* Roadmap modal — wide */
.roadmap-modal-box {
  width: 80vw;
  max-width: 1100px;
  height: 88vh;
}

/* Roadmap accordion */
.roadmap-item {
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.roadmap-summary {
  font-weight: 600;
  font-size: 13px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--grey-bg);
  user-select: none;
}
.roadmap-summary::-webkit-details-marker { display: none; }
.roadmap-summary::after {
  content: "▶";
  font-size: 10px;
  color: var(--grey-text);
  transition: transform .2s;
}
details[open] > .roadmap-summary::after { transform: rotate(90deg); }
.roadmap-summary:hover { background: #eaf7f0; }
.roadmap-detail {
  padding: 16px 14px;
  border-top: 1px solid var(--grey-border);
}
.roadmap-img-placeholder {
  width: 100%;
  height: 200px;
  background: var(--grey-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-text);
  font-size: 12px;
}
.roadmap-img-placeholder::after { content: "Image à venir"; }
.roadmap-detail p { margin-bottom: 16px; font-size: 14px; color: var(--grey-text); }
.roadmap-detail p:last-child { margin-bottom: 0; }

.impact-co2-wrapper {
  max-width: 1000px;
  margin: 0 auto 16px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  max-height: 907px; /* Force container height to match scaled iframe height */
}
.impact-co2-wrapper iframe {
  width: 100% !important;
  transform: scale(0.8);
  transform-origin: top center;
}

/* Credits modal — auto height */
.credits-modal-box {
  width: 50vw;
  min-width: 320px;
  max-width: 600px;
  height: auto;
  max-height: 80vh;
}
.credits-separator {
  border: none;
  border-top: 1px solid var(--grey-border);
  margin: 14px 0;
}

/* ── Restaurant emoji marker ─────────────────────────────────────────────── */
.restaurant-marker {
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

/* ── Housing dot markers (L.marker + divIcon, cluster-compatible) ─────────── */
.housing-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid;
}
.housing-dot--osm { background: #AED6F1; border-color: #5DADE2; }
.housing-dot--av  { background: #A9DFBF; border-color: #1E8449; }

/* ── Cluster bubble ───────────────────────────────────────────────────────── */
.cluster-bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  text-align: center;
  line-height: 1;
}

/* ── Scrollbar styling (webkit) ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey-border); border-radius: 4px; }

/* ── Site footer ─────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--grey-text);
  padding: 8px 16px;
  background: var(--grey-panel);
  border-top: 1px solid var(--grey-border);
}
.site-footer a { color: var(--grey-text); text-decoration: underline; }
