/* ==========================================================================
   EPT Maricá Lite - Estilos do Mapa em Tempo Real (mapa.css)
   Mobile-First, moderno, clean e focado em usabilidade no smartphone
   ========================================================================== */

.map-page-body {
  padding-bottom: var(--nav-height);
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
}

.map-wrapper {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--header-height) - var(--nav-height));
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  flex: 1;
  z-index: 10;
  background: #E5E7EB;
}

/* Painel Superior: Seletor Moderno de Linha (Diretriz 20 e 23) */
.map-top-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 25;
  pointer-events: none;
}

.linha-selector-card {
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.linha-selector-card:active {
  transform: scale(0.99);
}

.linha-selector-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.linha-badge-pill {
  background: var(--color-primary);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(211, 19, 30, 0.3);
}

.linha-names-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.linha-main-name {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linha-sub-itinerary {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linha-chevron-icon {
  font-size: 1.1rem;
  color: var(--text-light);
  flex-shrink: 0;
}

/* Seletor de Sentido da Linha (Problema 8) */
.sentido-selector-bar {
  pointer-events: auto;
  display: flex;
  gap: 6px;
  margin-top: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sentido-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: all 0.15s ease;
}

.sentido-btn.active {
  background: #0284C7;
  color: #FFFFFF;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.3);
}

.sentido-btn:not(.active):hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

/* Modal Bottom-Sheet para Selecionar Linha (Fase 10.3.2) */
.selector-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 30, 0.70);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.selector-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.selector-modal-sheet {
  background: #0B132B !important;
  color: #FFFFFF !important;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-sizing: border-box;
}

.selector-modal-backdrop.open .selector-modal-sheet {
  transform: translateY(0);
}

.selector-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selector-sheet-header h3 {
  color: #FFFFFF !important;
  font-family: var(--font-display, sans-serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

/* Botão de Fechar com Touch Target Mínimo de 48x48 */
.selector-sheet-header .modal-close-btn {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  border-radius: 14px !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: background 0.15s ease, transform 0.1s ease !important;
  padding: 0 !important;
  outline: none;
}

.selector-sheet-header .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #FFFFFF !important;
}

.selector-sheet-header .modal-close-btn:active {
  transform: scale(0.95);
}

/* Campo de Pesquisa: Texto Branco de Alto Contraste */
.selector-search-box {
  width: 100% !important;
  padding: 12px 16px !important;
  border-radius: 14px !important;
  border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
  background: #070D1E !important;
  color: #FFFFFF !important;
  -webkit-text-fill-color: #FFFFFF !important;
  font-size: 0.95rem !important;
  font-weight: 500 !important;
  outline: none !important;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif) !important;
  caret-color: #D3131E !important;
  box-sizing: border-box !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.selector-search-box:focus {
  border-color: #0284C7 !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(2, 132, 199, 0.35) !important;
}

/* Placeholder claro e distinto */
.selector-search-box::placeholder {
  color: rgba(255, 255, 255, 0.55) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.55) !important;
  opacity: 1 !important;
}

/* Autofill Mobile / Chrome Android */
.selector-search-box:-webkit-autofill,
.selector-search-box:-webkit-autofill:hover,
.selector-search-box:-webkit-autofill:focus,
.selector-search-box:-webkit-autofill:active {
  -webkit-text-fill-color: #FFFFFF !important;
  -webkit-box-shadow: 0 0 0px 1000px #070D1E inset !important;
  box-shadow: 0 0 0px 1000px #070D1E inset !important;
  transition: background-color 5000s ease-in-out 0s !important;
  caret-color: #FFFFFF !important;
}

/* Botão nativo de cancelar (X) no campo search */
.selector-search-box::-webkit-search-cancel-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  height: 24px !important;
  width: 24px !important;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'></line><line x1='6' y1='6' x2='18' y2='18'></line></svg>") no-repeat center center !important;
  background-size: 16px 16px !important;
  cursor: pointer !important;
  opacity: 0.8 !important;
  padding: 12px !important;
}

/* Lista e Itens de Linha: Alto Contraste, sem texto preto */
.selector-lines-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 55vh;
  box-sizing: border-box;
  padding-right: 2px;
}

.selector-line-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #111A35;
  color: #FFFFFF;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  box-sizing: border-box;
}

.selector-line-item:hover,
.selector-line-item:focus,
.selector-line-item:active {
  background: #182245;
  border-color: #0284C7;
  transform: translateY(-1px);
}

.selector-line-item strong {
  color: #FFFFFF !important;
}

.selector-line-item span {
  color: #CBD5E1;
}

.selector-line-item .linha-badge-pill {
  background: #D3131E !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
}

/* Painel de Status Flutuante Inferior (Diretriz 21) */
.map-status-floating-panel {
  position: absolute;
  bottom: 18px;
  left: 14px;
  z-index: 25;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
}

/* Botões Flutuantes de Ação Rápida (Itens 1, 2 e 4) */
.map-floating-controls {
  position: absolute;
  right: 16px;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-floating-controls button {
  width: 54px;
  height: 54px;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--bg-surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-main);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  outline: none;
}

.map-floating-controls button:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.map-floating-controls button:active {
  transform: scale(0.95);
}

/* Marcador Moderno de Ônibus (Diretriz 12) */
.ept-bus-marker-container {
  background: transparent !important;
  border: none !important;
}

.modern-bus-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modern-bus-pin:hover {
  transform: scale(1.15) translateY(-2px);
}

.bus-badge-circle {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #E30613 0%, #A70C15 100%);
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(211, 19, 30, 0.4);
  position: relative;
}

.modern-bus-pin.is-stopped .bus-badge-circle {
  background: linear-gradient(135deg, #991B1B 0%, #6B7280 100%);
  opacity: 0.92;
}

/* Indicador de Rumo / Bússola do Ônibus */
.bus-direction-indicator {
  position: absolute;
  top: -10px;
  left: 50%;
  margin-left: -6px;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center 26px; /* Gira ao redor do centro do círculo do ônibus */
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
  z-index: 2;
}

/* Ponto luminoso de status */
.bus-status-pulse {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #FFFFFF;
}

.bus-status-pulse.moving {
  background-color: #10B981;
  box-shadow: 0 0 6px #10B981;
}

.bus-status-pulse.stopped {
  background-color: #F59E0B;
}

.bus-line-tag {
  background: #111827;
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  margin-top: -4px;
}

/* Marcador Simplificado de Ônibus (Problema 17) */
.clean-bus-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.clean-bus-pin:hover {
  transform: scale(1.15);
}

.clean-bus-circle {
  width: 28px;
  height: 28px;
  background: #D3131E;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.clean-bus-pin.stopped .clean-bus-circle {
  background: #64748B;
}

.clean-bus-tag {
  background: #111827;
  color: #FFFFFF;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: -3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  letter-spacing: 0.2px;
}

/* Status Operacional dos Veículos (Diretrizes 7 e 8) */
.clean-bus-pin.off-route .clean-bus-circle {
  border-color: #F59E0B;
}

.clean-bus-pin.off-route .clean-bus-tag {
  background: #B45309;
}

.clean-bus-pin.inactive {
  opacity: 0.60;
  filter: grayscale(35%);
}

.clean-bus-pin.inactive .clean-bus-circle {
  background: #64748B;
  border-color: #94A3B8;
}

.clean-bus-pin.inactive .clean-bus-tag {
  background: #475569;
}

.clean-bus-pin.stale {
  opacity: 0.50;
  filter: grayscale(80%);
}

/* Marcador do Usuário (Diretriz 19 e Problema 6) */
.user-marker-pin {
  width: 16px;
  height: 16px;
  background: #0284C7;
  border: 3px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(2, 132, 199, 0.25), 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}

.user-marker-pin.approximate {
  background: #D97706;
  box-shadow: 0 0 0 6px rgba(217, 119, 6, 0.25), 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Toast de Feedback de Geolocalização */
.gps-feedback-toast {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 30;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 7px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.gps-feedback-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Destaque do Ônibus Mais Próximo (Item 5)
   ========================================================================== */
.clean-bus-pin.nearest-bus .clean-bus-circle {
  border-color: #FACC15 !important;
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.45), 0 0 16px rgba(250, 204, 21, 0.6) !important;
  animation: pulse-nearest-bus 1.8s infinite ease-in-out;
}

.clean-bus-pin.nearest-bus .clean-bus-tag {
  background: #FACC15 !important;
  color: #111827 !important;
  font-weight: 900 !important;
}

@keyframes pulse-nearest-bus {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.5), 0 0 10px rgba(250, 204, 21, 0.4);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 7px rgba(250, 204, 21, 0.25), 0 0 20px rgba(250, 204, 21, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.5), 0 0 10px rgba(250, 204, 21, 0.4);
  }
}

/* ==========================================================================
   Card Flutuante: Ônibus Mais Próximo do Passageiro (Item 4 e 6)
   ========================================================================== */
.nearest-bus-card {
  position: absolute;
  left: 14px;
  bottom: 54px;
  right: 84px;
  max-width: 320px;
  z-index: 950;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: slideUpCard 0.3s ease-out;
}

.nearest-bus-card.is-hidden {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

@keyframes slideUpCard {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nearest-bus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nearest-bus-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nearest-bus-icon {
  font-size: 1rem;
}

.nearest-bus-heading {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nearest-bus-close {
  background: transparent;
  border: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease, background 0.15s ease;
}

.nearest-bus-close:hover {
  color: var(--color-primary);
  background: rgba(211, 19, 30, 0.08);
}

.nearest-bus-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nearest-bus-main-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nearest-bus-line-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.nearest-bus-code {
  background: var(--color-primary);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.nearest-bus-dot {
  color: var(--text-muted);
}

.nearest-bus-vehicle {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearest-bus-distance-badge {
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-shrink: 0;
}

.distance-number {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0284C7;
  font-family: var(--font-display);
}

.distance-text {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.nearest-bus-sub-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.nearest-bus-sentido {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.nearest-bus-accuracy-tag {
  font-size: 0.68rem;
  font-weight: 600;
  flex-shrink: 0;
}

.nearest-bus-accuracy-tag.precise {
  color: #059669;
}

.nearest-bus-accuracy-tag.approx {
  color: #D97706;
}

.btn-ver-onibus {
  margin-top: 4px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(211, 19, 30, 0.25);
  transition: all 0.18s ease;
}

.btn-ver-onibus:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(211, 19, 30, 0.35);
}

.btn-ver-onibus:active {
  transform: scale(0.98);
}

.btn-ver-onibus .arrow {
  font-size: 1.1rem;
  line-height: 1;
}

.nearest-bus-empty-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-main);
  padding: 4px 0;
}

.nearest-bus-empty-msg .icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.nearest-bus-empty-msg.warning strong {
  color: #D97706;
  font-size: 0.8rem;
}

