/* ══════════════════════════════════════════════════════
   COMPONENTS — Éléments UI réutilisables
══════════════════════════════════════════════════════ */

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity .55s ease, visibility .55s;
}

#loader.out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-wm {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.8px;
  color: var(--ink);
}

.loader-wm em {
  color: var(--primary-dark);
  font-style: normal;
}

.loader-track {
  width: 160px;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  animation: lbar 1.4s ease-in-out infinite;
}

.loader-sub {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}

/* Icon Button */
.icon-btn {
  width: 48px;
  height: 48px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink-2);
  transition: border-color .2s, background .2s, transform .15s;
  position: relative;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

#compassBtn svg,
#locateBtn svg {
  width: 22px;
  height: 22px;
}

#compassBtn {
  overflow: hidden;
  color: #334155;
}

#compassNeedle {
  transform-origin: 12px 12px;
  transition: transform .18s ease-out;
}

#compassBtn .compass-shell {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 1.1;
}

#compassBtn .compass-face {
  fill: #f8fafc;
  stroke: #e2e8f0;
  stroke-width: .75;
}

#compassBtn .compass-core,
#locateBtn .locate-core {
  fill: currentColor;
  stroke: none;
}

#compassBtn .compass-mark {
  stroke: #0f172a;
  stroke-width: 1.7;
}

#compassBtn .compass-north {
  fill: #ef4444;
  stroke: none;
}

#compassBtn .compass-south {
  fill: #64748b;
  opacity: .82;
  stroke: none;
}

#compassBtn.active {
  color: #0f172a;
  border-color: #fca5a5;
  background: #fff7f7;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
}

#locateBtn .locate-core {
  opacity: .92;
}

#locateBtn.active .locate-core {
  opacity: 1;
}

#locateBtn.active::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1.5px solid color-mix(in srgb, var(--primary-dark) 28%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
  transform: translateY(-1px);
}

.icon-btn.active {
  border-color: var(--primary-dark);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.ndot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg-card);
  display: none;
}

.ndot.vis {
  display: block;
}

/* Search Pill */
.search-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 0 14px;
  height: 52px;
  transition: border-color .2s;
}

.search-pill:focus-within {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.search-ico {
  flex-shrink: 0;
  color: var(--ink-3);
  display: flex;
}

.search-ico svg {
  width: 17px;
  height: 17px;
}

#searchInput {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 0;
  height: 100%;
}

#searchInput::placeholder {
  color: var(--ink-4);
  font-weight: 500;
}

#searchInput.hidden-inp {
  flex: 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  pointer-events: none;
}

#searchModeBtn {
  border: 1.5px solid var(--border);
  background: var(--bg-subtle);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  height: 28px;
  min-width: 58px;
  padding: 0 10px;
  transition: all .15s;
  flex-shrink: 0;
}

#searchModeBtn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--ink);
}

#searchModeBtn[data-mode="bus"] {
  background: #ecfeff;
  border-color: #67e8f9;
  color: #0e7490;
}

#searchModeBtn[data-mode="line"] {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

#clearBtn {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  align-self: center;
  transition: color .15s;
  margin-top: -5px;
}

#clearBtn:hover {
  color: var(--ink);
}

#clearBtn.vis {
  display: flex;
}

/* Search Tag (selected line) */
.search-tag {
  display: none;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.search-tag.vis {
  display: flex;
}

.search-tag-chip {
  background: var(--primary);
  color: var(--ink);
  font-weight: 800;
  font-size: 12px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-tag-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search Dropdown */
#searchDrop {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 560px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-l);
  z-index: 499;
  max-height: 50vh;
  overflow-y: auto;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-dark) transparent;
}

#searchDrop::-webkit-scrollbar {
  width: 4px;
}

#searchDrop::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 4px;
}

#searchDrop.vis {
  display: block;
  animation: dropIn .2s var(--ease-spring);
}

.res-row {
  display: grid;
  grid-template-columns: 54px 1fr 36px;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1.5px solid var(--border);
  transition: background .12s;
}

.res-row:last-child {
  border-bottom: none;
}

.res-row:hover {
  background: var(--bg-subtle);
}

.rchip {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
  font-family: var(--mono);
  padding: 5px 8px;
  border-radius: var(--r-s);
  white-space: nowrap;
}

.rchip.fav {
  background: #ff6ddb;
  color: white;
}

.rchip.bus {
  background: #ecfeff;
  color: #0e7490;
}

.rinfo .rn {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.rinfo .rs {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}

.star-btn {
  background: none;
  border: none;
  font-size: 19px;
  line-height: 1;
  color: var(--primary-dark);
  padding: 4px;
  transition: transform .18s;
}

.star-btn:hover {
  transform: scale(1.3);
}

.bus-row {
  grid-template-columns: 78px 1fr 24px;
}

.res-go {
  font-size: 16px;
  color: var(--ink-3);
  text-align: right;
  font-weight: 700;
}

/* Empty State */
.empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--ink-3);
}

.empty svg {
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  opacity: .28;
}

.empty p {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}
