/* ══════════════════════════════════════════════════════
   MAP & MAPLIBRE GL STYLES
══════════════════════════════════════════════════════ */

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #e8eaef;
}

.maplibregl-map {
  z-index: 0 !important;
  font-family: var(--font) !important;
}

/* Attribution */
.maplibregl-ctrl-attrib {
  font-family: var(--font) !important;
  font-size: 11px !important;
}

/* Zoom Control */
.maplibregl-ctrl-group {
  border: 1.5px solid var(--border-dark) !important;
  border-radius: var(--r-m) !important;
  box-shadow: var(--shadow-m) !important;
  overflow: hidden;
  background: transparent !important;
}

.maplibregl-ctrl-group button {
  background: var(--bg-card) !important;
  color: var(--ink-2) !important;
  border: none !important;
  border-bottom: 1.5px solid var(--border) !important;
  width: 40px !important;
  height: 40px !important;
  transition: background .15s !important;
}

.maplibregl-ctrl-group button:last-child {
  border-bottom: none !important;
}

.maplibregl-ctrl-group button:hover {
  background: var(--bg-hover) !important;
  color: var(--ink) !important;
}

.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon,
.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
  filter: invert(0.4);
}

/* Popups */
.maplibregl-popup-content {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-l) !important;
  box-shadow: var(--shadow-l);
  padding: 0 !important;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
}

.maplibregl-popup-tip {
  display: none !important;
}

.maplibregl-popup-close-button {
  color: var(--ink-3) !important;
  font-size: 20px !important;
  top: 10px !important;
  right: 12px !important;
  z-index: 10;
  background: none;
  border: none;
  line-height: 1;
  padding: 0;
}

.maplibregl-popup-close-button:hover {
  color: var(--ink) !important;
  background: none !important;
}

/* Popup au-dessus de tous les marqueurs */
.maplibregl-popup {
  z-index: 10 !important;
}

/* Z-index des marqueurs custom */
.lf-bus-wrap {
  width: 34px;
  height: 34px;
  display: block;
  cursor: pointer;
  z-index: 2;
}

.lf-stop-wrap {
  z-index: 1;
}

.track-stop-icon {
  z-index: 3;
}

.disruption-stop-icon {
  z-index: 3;
}

.usrm {
  z-index: 5;
  pointer-events: none;
}



.lf-bus-wrap img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  transition: transform .18s var(--ease);
  pointer-events: none;
}

.lf-bus-wrap:hover img {
  transform: scale(1.15);
}

.lf-num {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  border: 1.5px solid rgba(0,0,0,.15);
  color: #fff;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  font-family: var(--font);
  letter-spacing: .01em;
  line-height: 1.55;
}

.lf-num.is-fav {
  background: #ff6ddb;
  border-color: #ebb01c;
  color: #fff;
}

/* Stop Markers */
/* Outer wrap — MapLibre positionne cet élément, on ne touche pas à son transform */
.lf-stop-wrap {
  width: 32px;
  height: 32px;
}

/* Inner div — animations/transforms appliqués ici, isolés du transform MapLibre */
.lf-stop-inner {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
}

.lf-stop-wrap::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--primary-dark);
  opacity: 0;
  transform: scale(.8);
  animation: stopRing 2.4s ease-out infinite;
  pointer-events: none;
}

.lf-stop-wrap img {
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
}

.lf-stop-inner.pre {
  opacity: 0;
  transform: scale(.5);
}

/* User Marker */
.usrm {
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   TRACK/ITINERARY STYLES
══════════════════════════════════════════════════════ */

/* Stop Markers pour itinéraire */
.track-stop-wrap {
  width: 32px;
  height: 32px;
}

.track-stop-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform-origin: center;
  transition: transform .15s var(--ease);
}

.track-stop-icon:hover {
  transform: scale(1.2);
}

.track-stop-icon .marker-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  border: 2.5px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* État des marqueurs */
.track-marker-normal .marker-number {
  background: linear-gradient(135deg, #ffcc00 0%, #e0b400 100%);
  color: #222;
}

.track-marker-next .marker-number {
  background: linear-gradient(135deg, #ffcc00 0%, #e0b400 100%);
  color: #222;
  border-color: rgba(255, 255, 255, 0.8);
}

.track-marker-now .marker-number {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: pulse-now 1s ease-in-out infinite;
}

.track-marker-past .marker-number {
  background: linear-gradient(135deg, #a1a1a1 0%, #808080 100%);
  opacity: 0.6;
}

/* Flèches de direction */
.route-arrow {
  pointer-events: none;
  font-size: 16px;
  font-weight: bold;
  color: #FF6B6B;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.route-arrow-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow-symbol {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffcc00;
  font-weight: bold;
  font-size: 16px;
  text-shadow: 0 1px 4px rgba(255, 204, 0, 0.45), 0 0 8px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  animation: routeArrowPulse 1.6s ease-in-out infinite;
}

/* Polyline */
.route-polyline {
  pointer-events: none;
}

.route-polyline-base {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.route-polyline-flow {
  animation: routeFlow 1.4s linear infinite;
}

.disruption-closed-base {
  filter: drop-shadow(0 3px 8px rgba(153, 27, 27, 0.45));
}

.disruption-closed-flow {
  animation: disruptionFlow 0.9s linear infinite;
}

.disruption-stop-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid #d3d7e0;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: disruptionStopBlink 1.25s ease-in-out infinite;
}

.disruption-pulse-marker {
  animation: disruptionPulseFade 1.2s ease-out 1;
}

/* Popup pour les arrêts */
.track-popup {
  padding: 8px 12px;
}

.track-popup .stop-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-popup .stop-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.track-popup .stop-time-popup {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stop-time-past,
.stop-time-now,
.stop-time-soon {
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.stop-time-past {
  background: rgba(160, 160, 160, 0.2);
  color: #666;
}

.stop-time-now {
  background: rgba(22, 163, 74, 0.2);
  color: #16a34a;
}

.stop-time-soon {
  background: rgba(255, 215, 0, 0.2);
  color: #b8860b;
}

/* Animations */
@keyframes pulse-marker {
  0%, 100% {
    box-shadow: 0 0 0 0px rgba(255, 215, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
}

@keyframes pulse-now {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
}

@keyframes routeFlow {
  from {
    stroke-dashoffset: 32;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes disruptionFlow {
  from {
    stroke-dashoffset: 24;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes disruptionStopBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

@keyframes disruptionPulseFade {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

@keyframes routeArrowPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════════════
   TRACK TOOLBAR
══════════════════════════════════════════════════════ */

#track-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  animation: slideUp .3s var(--ease-spring);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.track-toolbar-inner {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-l);
  padding: 12px 16px;
  box-shadow: var(--shadow-l);
  align-items: center;
}

.track-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px solid transparent;
  border-radius: var(--r-s);
  background: linear-gradient(135deg, #f0f1f4 0%, #f7f8fa 100%);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s var(--ease);
  font-family: var(--font);
}

.track-btn:hover {
  background: linear-gradient(135deg, #e8e9ed 0%, #eff0f3 100%);
  border-color: var(--border-dark);
}

.track-btn svg {
  width: 16px;
  height: 16px;
}

.track-btn-exit:hover {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: var(--red);
  border-color: var(--red);
}

.track-btn-follow {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: var(--green);
  border-color: rgba(22, 163, 74, 0.3);
}

.track-btn-follow:hover {
  background: linear-gradient(135deg, #bbf7d0 0%, #86efac 100%);
  border-color: var(--green);
}

.track-btn-follow.active {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white;
  border-color: var(--green);
}

/* Marqueur du bus courant */
.current-bus-marker {
  cursor: pointer;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
  transition: filter .15s var(--ease);
}

.current-bus-marker:hover {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

/* ══════════════════════════════════════════════════════
   TRACK LOADING OVERLAY
══════════════════════════════════════════════════════ */

#track-loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  animation: fadeIn .2s var(--ease);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.track-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--r-l);
  box-shadow: var(--shadow-l);
}

.track-loading-content .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.track-loading-content p {
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}
