/* ================================================================
   BUS EN VIVO · v14 MapLibre GL
   Panel responsive PC / tablet / móvil
   ================================================================ */
:root {
  --bus-blue: #0056a4;
  --bus-blue-dark: #072b5a;
  --bus-red: #e30613;
  --bus-ink: #061e43;
  --bus-muted: #64748b;
  --bus-border: rgba(148, 163, 184, .42);
  --bus-panel: rgba(255,255,255,.94);
  --bus-bg: #eef4fb;
  --bus-shadow: 0 16px 36px rgba(15, 23, 42, .16);
  --bus-radius: 22px;
}

html,
body {
  min-height: 100%;
}

body:has(.bus-live-page-v14) {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(227,6,19,.08), transparent 30%),
    radial-gradient(circle at 90% 10%, rgba(0,86,164,.12), transparent 32%),
    linear-gradient(180deg, #f7fbff, #eef4fb 56%, #e9f0f8);
  color: var(--bus-ink);
}

.bus-live-page-v14 {
  width: min(1800px, calc(100vw - 28px));
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 18px;
  min-height: 100dvh;
  box-sizing: border-box;
}

.bus-live-topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  min-height: 88px;
  border-radius: 24px;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(115deg, rgba(45,26,63,.96) 0%, rgba(7,43,90,.98) 38%, rgba(0,86,164,.96) 100%);
  box-shadow: 0 18px 34px rgba(7,43,90,.26);
  isolation: isolate;
}
.bus-live-topbar::before,
.bus-live-topbar::after {
  content: "";
  position: absolute;
  inset: -30% auto -40% auto;
  width: 310px;
  transform: skewX(-28deg);
  background: rgba(255,255,255,.08);
  z-index: -1;
}
.bus-live-topbar::before { right: 24%; }
.bus-live-topbar::after { right: 4%; background: rgba(255,255,255,.045); }

.bus-live-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.bus-live-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 10px 24px rgba(0,0,0,.22);
}
.bus-live-logo img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
.bus-live-kicker {
  font-size: 11px;
  letter-spacing: .08em;
  font-weight: 950;
  opacity: .8;
}
.bus-live-brand h1 {
  margin: 2px 0 2px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.03em;
}
.bus-live-brand p {
  margin: 0;
  opacity: .9;
  font-size: 13px;
  font-weight: 700;
}
.bus-live-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bus-top-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.20);
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}
.bus-top-status.ok { background: rgba(22,163,74,.28); }
.bus-top-status.error { background: rgba(227,6,19,.34); }
.bus-top-status.loading { background: rgba(245,158,11,.30); }
.bus-back-link,
.bus-back-link:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-weight: 950;
  font-size: 13px;
  background: rgba(0,86,164,.68);
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  white-space: nowrap;
}
.bus-back-link:hover { transform: translateY(-1px); }

.bus-live-grid {
  display: grid;
  grid-template-columns: minmax(350px, 420px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  min-height: calc(100dvh - 132px);
}

.bus-live-sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}
.bus-panel {
  border-radius: var(--bus-radius);
  background: var(--bus-panel);
  border: 1px solid var(--bus-border);
  box-shadow: var(--bus-shadow);
  backdrop-filter: blur(10px);
  min-width: 0;
}
.bus-search-panel { padding: 16px; }
.bus-results-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}
.bus-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--bus-blue-dark);
  font-weight: 950;
  border-bottom: 1px solid rgba(0,86,164,.12);
  padding-bottom: 10px;
}
.bus-results-panel .bus-panel-title { padding: 14px 16px 10px; }
.bus-panel-title small {
  color: var(--bus-muted);
  font-size: 12px;
  font-weight: 900;
  margin-left: auto;
}

.bus-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.bus-field-wide { grid-column: 1 / -1; }
.bus-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.bus-field span {
  color: var(--bus-muted);
  font-size: 12px;
  font-weight: 950;
}
.bus-field input,
.bus-field select {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #fff;
  color: #0f172a;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 750;
  outline: none;
}
.bus-field input:focus,
.bus-field select:focus {
  border-color: var(--bus-blue);
  box-shadow: 0 0 0 4px rgba(0,86,164,.12);
}
.bus-action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.bus-btn {
  min-height: 40px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  padding: 0 15px;
  font-weight: 950;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.bus-btn:hover { transform: translateY(-1px); }
.bus-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--bus-red), #9f1239);
  box-shadow: 0 10px 20px rgba(227,6,19,.22);
}
.bus-btn-secondary {
  color: #fff;
  background: linear-gradient(135deg, var(--bus-blue), var(--bus-blue-dark));
  box-shadow: 0 10px 20px rgba(0,86,164,.22);
}
.bus-btn-ghost {
  color: var(--bus-blue-dark);
  background: #eef5ff;
  border: 1px solid rgba(0,86,164,.18);
}
.bus-options-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.bus-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
  color: var(--bus-blue-dark);
}
.bus-toggle input { accent-color: var(--bus-blue); }
.bus-auto-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--bus-muted);
  font-size: 11px;
  font-weight: 950;
}
.bus-live-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eef5ff;
  color: var(--bus-blue-dark);
  font-weight: 900;
  font-size: 13px;
  line-height: 1.35;
}
.bus-live-status.ok { background: #dcfce7; color: #065f46; }
.bus-live-status.error { background: #fee2e2; color: #7f1d1d; }
.bus-live-status.loading { background: #fef3c7; color: #854d0e; }
.bus-live-summary {
  margin-top: 8px;
  color: var(--bus-muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.38;
}

.bus-results-table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 240px;
  background: #fff;
}
.bus-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}
.bus-results-table th,
.bus-results-table td {
  padding: 10px 11px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
.bus-results-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg,#f8fafc,#eef2f7);
  color: var(--bus-blue-dark);
  font-weight: 950;
}
.bus-results-table tbody tr { cursor: pointer; }
.bus-results-table tbody tr:hover,
.bus-results-table tbody tr.is-selected {
  background: #eef5ff;
}
.bus-results-table tbody tr.is-selected td:first-child {
  box-shadow: inset 4px 0 0 #f59e0b;
}
.bus-results-table small {
  display: block;
  color: var(--bus-muted);
  font-size: 11px;
  margin-top: 2px;
  font-weight: 750;
}
.empty-cell {
  text-align: center !important;
  color: var(--bus-muted);
  padding: 26px !important;
}
.sentido-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
}
.sentido-pill.ida { background: var(--bus-blue); }
.sentido-pill.ret { background: var(--bus-red); }

.bus-map-shell {
  position: relative;
  min-width: 0;
  min-height: calc(100dvh - 132px);
  border-radius: var(--bus-radius);
  overflow: hidden;
  background: #dce9f7;
  border: 1px solid var(--bus-border);
  box-shadow: var(--bus-shadow);
  isolation: isolate;
}
.bus-map-toolbar {
  position: absolute;
  z-index: 4;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.bus-map-toolbar > div {
  pointer-events: auto;
}
.bus-map-toolbar > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(520px, 58vw);
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(148,163,184,.38);
  box-shadow: 0 10px 24px rgba(15,23,42,.14);
  backdrop-filter: blur(8px);
}
#bus-map-title {
  color: var(--bus-blue-dark);
  font-weight: 950;
  line-height: 1.1;
}
#bus-map-subtitle {
  color: var(--bus-muted);
  font-size: 12px;
  font-weight: 850;
}
.bus-map-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bus-map-tool {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,86,164,.18);
  background: rgba(255,255,255,.94);
  color: var(--bus-blue-dark);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15,23,42,.12);
}
.bus-map-tool:hover { transform: translateY(-1px); }
.bus-map-v14 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.bus-map-v14 canvas {
  outline: none;
}
.bus-map-loading {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(7,43,90,.94);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 14px 30px rgba(15,23,42,.26);
}
.bus-map-legend {
  position: absolute;
  z-index: 4;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(148,163,184,.36);
  box-shadow: 0 10px 22px rgba(15,23,42,.12);
  font-size: 12px;
  font-weight: 950;
  color: var(--bus-blue-dark);
  backdrop-filter: blur(8px);
}
.bus-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bus-map-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
}
.bus-map-legend .dot.ida { background: var(--bus-blue); }
.bus-map-legend .dot.ret { background: var(--bus-red); }
.bus-map-legend .dot.sel { background: #f59e0b; }

.maplibregl-popup-content {
  border-radius: 16px !important;
  padding: 0 !important;
  box-shadow: 0 16px 34px rgba(15,23,42,.22) !important;
  border: 1px solid rgba(148,163,184,.38);
  overflow: hidden;
}
.maplibregl-popup-close-button {
  color: #fff;
  font-size: 18px;
  right: 8px !important;
  top: 6px !important;
}
.bus-popup-v14 {
  min-width: 245px;
  color: #0f172a;
  font-family: "Segoe UI", Tahoma, sans-serif;
  line-height: 1.42;
  font-size: 12px;
  padding: 12px 14px 13px;
}
.bus-popup-v14 .popup-title {
  margin: -12px -14px 10px;
  padding: 11px 38px 11px 14px;
  background: linear-gradient(135deg, var(--bus-blue-dark), var(--bus-blue));
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}
.popup-route-text {
  margin-top: 7px;
  color: var(--bus-muted);
  font-size: 11px;
  font-weight: 750;
}

@media (max-width: 1220px) {
  .bus-live-page-v14 {
    width: min(100vw - 18px, 100%);
  }
  .bus-live-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 58dvh) auto;
    min-height: auto;
  }
  .bus-live-sidebar {
    display: contents;
  }
  .bus-search-panel { order: 1; }
  .bus-map-shell {
    order: 2;
    min-height: 58dvh;
    height: 58dvh;
  }
  .bus-results-panel {
    order: 3;
    min-height: 330px;
  }
  .bus-results-table-wrap {
    max-height: 430px;
  }
}

@media (max-width: 760px) {
  .bus-live-page-v14 {
    width: calc(100vw - 10px);
    padding-top: 8px;
  }
  .bus-live-topbar {
    border-radius: 18px;
    padding: 14px;
    align-items: flex-start;
    flex-direction: column;
  }
  .bus-live-brand {
    align-items: flex-start;
  }
  .bus-live-logo {
    width: 48px;
    height: 48px;
  }
  .bus-live-logo img {
    width: 39px;
    height: 39px;
  }
  .bus-live-brand h1 {
    font-size: 25px;
  }
  .bus-live-brand p {
    font-size: 12px;
  }
  .bus-live-top-actions {
    width: 100%;
    justify-content: stretch;
  }
  .bus-top-status,
  .bus-back-link {
    flex: 1 1 auto;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
  .bus-live-grid {
    gap: 10px;
    grid-template-rows: auto 56dvh auto;
    margin-top: 10px;
  }
  .bus-panel,
  .bus-map-shell {
    border-radius: 18px;
  }
  .bus-search-panel {
    padding: 13px;
  }
  .bus-form-grid {
    grid-template-columns: 1fr;
  }
  .bus-action-row .bus-btn {
    flex: 1 1 110px;
  }
  .bus-map-shell {
    min-height: 56dvh;
    height: 56dvh;
  }
  .bus-map-toolbar {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-direction: column;
    align-items: stretch;
  }
  .bus-map-toolbar > div:first-child {
    max-width: none;
    padding: 9px 11px;
  }
  .bus-map-tools {
    justify-content: flex-start;
  }
  .bus-map-tool {
    flex: 1 1 120px;
  }
  .bus-map-legend {
    left: 10px;
    right: 10px;
    bottom: 10px;
    justify-content: center;
    border-radius: 16px;
  }
  .bus-results-table th,
  .bus-results-table td {
    padding: 9px 8px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .bus-live-kicker { font-size: 10px; }
  .bus-live-brand h1 { font-size: 22px; }
  .bus-live-grid { grid-template-rows: auto 54dvh auto; }
  .bus-map-shell { min-height: 54dvh; height: 54dvh; }
  .bus-results-table-wrap { max-height: 360px; }
  .bus-results-table th:nth-child(4),
  .bus-results-table td:nth-child(4),
  .bus-results-table th:nth-child(5),
  .bus-results-table td:nth-child(5) {
    display: none;
  }
}

/* =========================
   v15 ajustes operativos
   ========================= */
.bus-btn-geo {
  color: #065f46;
  background: #dcfce7;
  border: 1px solid rgba(22, 163, 74, .28);
}
.bus-map-limit-note {
  color: #0f766e;
  font-size: 11px;
  font-weight: 950;
  margin-top: 2px;
}
.bus-results-table-wrap {
  max-height: min(58dvh, 520px);
  overflow: auto;
}
.bus-results-table th:nth-child(6),
.bus-results-table td:nth-child(6),
.bus-results-table th:nth-child(7),
.bus-results-table td:nth-child(7) {
  text-align: right;
}
.bus-results-table tbody tr.is-selected {
  background: #fff7ed;
}
.bus-popup-v15 {
  min-width: 255px;
  color: #0f172a;
  font-family: "Segoe UI", Tahoma, sans-serif;
  line-height: 1.42;
  font-size: 12px;
  padding: 12px 14px 13px;
}
.bus-popup-v15 .popup-title {
  margin: -12px -14px 10px;
  padding: 11px 38px 11px 14px;
  background: linear-gradient(135deg, var(--bus-blue-dark), var(--bus-blue));
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}
@media (min-width: 1221px) {
  .bus-results-panel {
    min-height: 390px;
  }
}
@media (max-width: 760px) {
  .bus-map-limit-note { font-size: 10px; }
  .bus-results-table th:nth-child(5),
  .bus-results-table td:nth-child(5) { display: none; }
}
@media (max-width: 480px) {
  .bus-results-table th:nth-child(3),
  .bus-results-table td:nth-child(3) { display: none; }
  .bus-results-table th:nth-child(6),
  .bus-results-table td:nth-child(6) { display: none; }
}
