/* ═══════════════════════════════════════════════════════════
   AGORAH — Composants UI
   ═══════════════════════════════════════════════════════════ */

/* ── SECTION PANEL ────────────────────────────────────────── */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  padding: 0 2px;
}

/* ── LAYER TOGGLES ────────────────────────────────────────── */
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: white;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  user-select: none;
}

.layer-toggle:hover {
  border-color: var(--agorah-teal-light);
  background: var(--agorah-teal-pale);
}

.layer-toggle.active {
  border-color: var(--agorah-teal-light);
  background: var(--agorah-teal-pale);
}

.layer-toggle.inactive {
  opacity: 0.55;
  background: var(--gray-50);
}

.layer-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.layer-icon.traffic  { background: rgba(239,68,68,0.1);    color: var(--congestion-color); }
.layer-icon.alerts   { background: rgba(217,119,6,0.1);    color: var(--alert-hazard); }
.layer-icon.buses    { background: rgba(245,166,35,0.1);   color: var(--carjaune-dark); }

.layer-info {
  flex: 1;
  min-width: 0;
}

.layer-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.2;
}

.layer-meta {
  font-size: 10px;
  color: var(--gray-400);
  font-family: var(--font-mono);
}

.layer-switch {
  width: 32px; height: 18px;
  border-radius: 9px;
  background: var(--gray-300);
  position: relative;
  transition: background var(--dur-fast) var(--ease);
  flex-shrink: 0;
}

.layer-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.layer-toggle.active .layer-switch {
  background: var(--agorah-teal-light);
}

.layer-toggle.active .layer-switch::after {
  transform: translateX(14px);
}

/* ── ROUTE SEARCH ─────────────────────────────────────────── */
.route-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.route-search-icon {
  position: absolute;
  left: 9px;
  color: var(--gray-400);
  pointer-events: none;
  flex-shrink: 0;
}

.route-search {
  width: 100%;
  padding: 7px 10px 7px 28px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--gray-800);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  box-sizing: border-box;
}

.route-search::placeholder { color: var(--gray-400); }

.route-search:focus {
  border-color: var(--agorah-teal-light);
  background: white;
  box-shadow: 0 0 0 2px rgba(21,73,90,0.08);
}

/* Masquer le bouton natif "×" des inputs type=search */
.route-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.route-search-empty {
  font-size: 11px;
  color: var(--gray-400);
  padding: 10px 4px;
  text-align: center;
  font-style: italic;
}

/* ── SCORE CARD ───────────────────────────────────────────── */
.score-card {
  background: linear-gradient(135deg, var(--agorah-teal-dark) 0%, var(--agorah-teal) 100%);
  border-radius: var(--radius-md);
  padding: 12px;
  color: white;
  position: relative;
  overflow: hidden;
}

.score-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.score-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.score-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
}

.score-badge {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-badge.live {
  background: rgba(16,185,129,0.25);
  color: var(--fluide-color);
  border: 1px solid rgba(16,185,129,0.4);
}

.score-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 3px;
}

.score-unit { font-size: 16px; font-weight: 600; opacity: 0.7; }

.score-sub {
  font-size: 10px;
  opacity: 0.55;
  margin-bottom: 10px;
}

.score-bars {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  gap: 1px;
}

.score-bar { height: 100%; border-radius: 2px; transition: width 0.5s var(--ease); }
.score-bar.fluide     { background: var(--fluide-color); }
.score-bar.dense      { background: var(--dense-color); }
.score-bar.congestion { background: var(--congestion-color); }
.score-bar.sature     { background: var(--sature-color); }

.score-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.score-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.score-stat-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: white;
}

.score-stat-lbl {
  font-size: 8px;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── FILTER ROUTE LIST ────────────────────────────────────── */
.filter-bulk-actions {
  display: flex;
  gap: 6px;
}

.btn-bulk {
  flex: 1;
  padding: 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all var(--dur-fast) var(--ease);
  font-family: var(--font-ui);
}

.btn-bulk:hover { background: var(--agorah-teal-pale); border-color: var(--agorah-teal-light); color: var(--agorah-teal); }

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
}

.filter-list::-webkit-scrollbar { width: 3px; }
.filter-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── Groupe d'axe ── */
.route-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 4px;
  margin-top: 4px;
  border-bottom: 1px solid var(--gray-200);
}

.route-group-check {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.route-group-check input[type="checkbox"] {
  appearance: none;
  width: 13px; height: 13px;
  border: 1.5px solid var(--gray-300);
  border-radius: 3px;
  background: white;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease);
}

.route-group-check input[type="checkbox"]:checked {
  background: var(--agorah-teal);
  border-color: var(--agorah-teal);
}

.route-group-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 3px;
  width: 4px; height: 6px;
  border: 1.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.route-group-label {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--agorah-teal);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.route-group-count {
  font-size: 9px;
  color: var(--gray-400);
  flex: 1;
}

.route-group-chip {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.route-group-chip.fluide     { background: rgba(16,185,129,0.1); color: var(--fluide-color); }
.route-group-chip.dense      { background: rgba(245,158,11,0.1); color: var(--dense-color); }
.route-group-chip.congestion { background: rgba(239,68,68,0.1);  color: var(--congestion-color); }
.route-group-chip.sature     { background: rgba(26,26,26,0.08);  color: var(--sature-color); }

.route-group-collapse {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--gray-400);
  padding: 0 2px;
  line-height: 1;
  transition: color var(--dur-fast);
}
.route-group-collapse:hover { color: var(--agorah-teal); }

.route-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 0 4px 0;
}

.route-group-items.collapsed { display: none; }

/* ── Item riche ── */
.filter-item-rich {
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
  overflow: hidden;
}

.filter-item-rich:hover { background: var(--gray-100); }

.fir-main {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 2px;
}

.fir-check {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.fir-check input[type="checkbox"] {
  appearance: none;
  width: 13px; height: 13px;
  border: 1.5px solid var(--gray-300);
  border-radius: 3px;
  background: white;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease);
}

.fir-check input[type="checkbox"]:checked {
  background: var(--agorah-teal);
  border-color: var(--agorah-teal);
}

.fir-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 3px;
  width: 4px; height: 6px;
  border: 1.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.fir-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fir-name {
  font-size: 11px;
  color: var(--gray-700);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fir-open {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--gray-300);
  padding: 0 2px;
  line-height: 1;
  transition: color var(--dur-fast);
  flex-shrink: 0;
}

.filter-item-rich:hover .fir-open { color: var(--agorah-teal); }

.fir-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 5px 28px;
  flex-wrap: wrap;
}

.fir-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.fir-chip.fluide     { background: rgba(16,185,129,0.12); color: var(--fluide-color); }
.fir-chip.dense      { background: rgba(245,158,11,0.12); color: var(--dense-color); }
.fir-chip.congestion { background: rgba(239,68,68,0.12);  color: var(--congestion-color); }
.fir-chip.sature     { background: rgba(26,26,26,0.1);    color: var(--sature-color); }

.fir-speed {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--gray-500);
}

.fir-direction {
  font-size: 9px;
  color: var(--gray-400);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fir-lost {
  font-size: 9px;
  font-weight: 600;
  color: var(--congestion-color);
  background: rgba(239,68,68,0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Compatibilité ancien .filter-item (non supprimé) */
.filter-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.filter-name { color: var(--gray-700); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.filter-tti { font-family: var(--font-mono); font-size: 9px; color: var(--gray-400); flex-shrink: 0; }

/* ── ALERT COUNT BADGES ───────────────────────────────────── */
.alert-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.alert-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}

.alert-badge.accident { background: rgba(220,38,38,0.1); color: var(--alert-accident); border-color: rgba(220,38,38,0.2); }
.alert-badge.hazard   { background: rgba(217,119,6,0.1); color: var(--alert-hazard);   border-color: rgba(217,119,6,0.2); }
.alert-badge.closed   { background: rgba(124,58,237,0.1); color: var(--alert-closed);  border-color: rgba(124,58,237,0.2); }
.alert-badge.police   { background: rgba(29,78,216,0.1); color: var(--alert-police);   border-color: rgba(29,78,216,0.2); }
.alert-badge.jam      { background: rgba(234,88,12,0.1); color: var(--alert-jam);      border-color: rgba(234,88,12,0.2); }

.alert-badge.inactive {
  opacity: 0.4;
  filter: grayscale(0.8);
}

/* ── BUS STATS MINI ───────────────────────────────────────── */
.bus-stats-mini {
  display: flex;
  gap: 8px;
}

.bus-stat {
  flex: 1;
  background: var(--carjaune-bg);
  border: 1px solid rgba(245,166,35,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  text-align: center;
}

.bus-stat-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--carjaune-dark);
  line-height: 1;
}

.bus-stat-lbl {
  font-size: 8px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--gray-800);
  color: white;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  max-width: 300px;
  animation: toast-in var(--dur-mid) var(--ease-spring);
  border-left: 3px solid transparent;
}

.toast.success { border-left-color: var(--fluide-color); }
.toast.error   { border-left-color: var(--congestion-color); }
.toast.info    { border-left-color: var(--agorah-teal-mid); }
.toast.warning { border-left-color: var(--dense-color); }

.toast.fade-out {
  animation: toast-out var(--dur-mid) var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ── SPINNING LOADER ──────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ── CUSTOM ALERT MARKERS (Leaflet DivIcon) ───────────────── */
.alert-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 13px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}

.alert-marker:hover { transform: scale(1.15); }

.alert-marker.ACCIDENT  { background: var(--alert-accident); }
.alert-marker.HAZARD    { background: var(--alert-hazard); }
.alert-marker.ROAD_CLOSED { background: var(--alert-closed); }
.alert-marker.POLICE    { background: var(--alert-police); }
.alert-marker.JAM       { background: var(--alert-jam); }

/* ── BUS MARKER ───────────────────────────────────────────── */
.bus-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--carjaune-color);
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 11px;
  font-weight: 700;
  color: white;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}

.bus-marker:hover { transform: scale(1.15); }
.bus-marker.late  { background: var(--bus-late); }
.bus-marker.very-late { background: var(--bus-very-late); }

/* ── CORRELATION BADGE ON MAP ─────────────────────────────── */
.corr-badge {
  position: absolute;
  top: -6px; right: -6px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--alert-accident);
  border: 2px solid white;
  font-size: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  color: var(--gray-400);
  text-align: center;
}

.empty-state-icon { font-size: 24px; opacity: 0.5; }
.empty-state-text { font-size: 11px; }

/* ── SPINNER (data loading) ───────────────────────────────── */
.data-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--agorah-teal-pale);
  font-size: 11px;
  color: var(--agorah-teal);
}
