/* =========================================================
   RotaSafe - UI Base
   ========================================================= */

:root {
  --bd: #e9ecef;
  --muted: #6c757d;
  --shadow: 0 12px 35px rgba(0, 0, 0, .18);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, .08);
}

/* ====== Shell ====== */
.rs-shell {
  display: flex;
  height: calc(100vh - 56px);
  /* navbar ~56px */
  overflow: hidden;
}

.rs-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  /* overlays */
}

/* =========================================================
   MAPA
   ========================================================= */
.rs-map-wrap {
  position: relative;
  height: 55vh;
  min-height: 360px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--bd);
}

.rs-map {
  position: absolute;
  inset: 0;
}

/* Leaflet: remove bordas/offset estranhos */
.leaflet-container {
  background: #f8f9fa;
}

.leaflet-control-attribution {
  font-size: 11px;
}

/* =========================================================
   KPIs flutuantes - CENTRALIZADOS
   ========================================================= */
.rs-kpis {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 650;
  flex-wrap: nowrap;
  overflow: auto;
  padding-bottom: 2px;
}

.kpi {
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 120px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-value {
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

/* =========================================================
   Ações flutuantes (ESQUERDA - mais à direita para evitar controles do Leaflet)
   ========================================================= */
.rs-floating-actions {
  position: absolute;
  top: 10px;
  left: 70px; /* Mover para a direita para evitar controles do Leaflet */
  display: flex;
  gap: 8px;
  z-index: 660;
}

.rs-floating-actions .btn {
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  background: #fff;
  border: 1px solid var(--bd);
}

.rs-floating-actions .btn:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}

/* =========================================================
   Painel de filtros (ESQUERDA - abaixo do botão, mais à direita)
   ========================================================= */
.rs-filter-panel {
  position: absolute;
  left: 70px; /* Alinhado com o botão */
  top: 54px; /* Abaixo do botão de filtros */
  width: 320px;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 12px;
  z-index: 670;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rs-filter-panel.collapsed {
  display: none;
}

.fp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bd);
  background: #f8f9fa;
}

.fp-head b {
  color: #212529;
  font-size: 14px;
}

.fp-body {
  padding: 10px 12px;
}

.fp-body .form-label {
  font-size: 12px;
  margin-bottom: 4px;
  color: #495057;
  font-weight: 500;
}

/* =========================================================
   FEED de alertas (DIREITA)
   ========================================================= */
.rs-feed {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 380px;
  max-width: calc(100% - 20px);
  height: calc(55vh - 20px);
  /* acompanha altura do mapa */
  min-height: 320px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 655;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.rs-feed-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bd);
  background: #fff;
}

.rs-feed-title {
  font-weight: 900;
  font-size: 16px;
  line-height: 1.1;
}

.rs-feed-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.rs-feed-body {
  padding: 10px;
  overflow: auto;
}

/* Cards do feed */
.feed-item {
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
}

.feed-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.feed-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.feed-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--bd);
  background: #f8f9fa;
  font-weight: 600;
}

.feed-title {
  font-weight: 800;
  font-size: 13px;
  margin: 0;
  color: #212529;
}

.feed-meta {
  font-size: 12px;
  color: var(--muted);
}

.feed-desc {
  font-size: 12px;
  margin-top: 6px;
  color: #212529;
  line-height: 1.4;
}

/* =========================================================
   GRID - CABEÇALHO COM PESQUISA E BOTÃO
   ========================================================= */
.rs-grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  position: relative;
}

.rs-grid-head {
  padding: 6px 10px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  min-height: 40px;
  gap: 10px;
}

.rs-grid-search {
  flex: 1;
  max-width: 280px;
}

.rs-grid-search .input-group {
  border-radius: 8px;
  overflow: hidden;
}

.rs-grid-search .input-group-text {
  background-color: #f8f9fa;
  border-right: none;
  padding: 4px 10px;
  font-size: 12px;
}

.rs-grid-search .form-control {
  border-left: none;
  font-size: 12px;
  padding: 4px 8px;
  height: 28px;
}

.rs-grid-search .form-control:focus {
  box-shadow: none;
  border-color: #dee2e6;
}

.rs-grid-actions {
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rs-grid-actions .btn {
  padding: 4px 8px !important;
  font-size: 12px !important;
}

.rs-grid-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 8px 8px;
  position: relative;
}

/* Overlay do grid sobre o mapa */
.rs-grid-wrap.overlay {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  bottom: 10px;
  z-index: 10000; /* Aumentado para ficar acima de tudo */
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #fff;
}

/* Quando o grid está expandido, esconde os controles do Leaflet */
.rs-grid-wrap.overlay ~ .rs-map-wrap .leaflet-control-container {
  display: none !important;
}

/* Quando o grid está expandido, desabilita interações com o mapa por baixo */
.rs-grid-wrap.overlay ~ .rs-map-wrap {
  pointer-events: none;
}

/* Mas mantém o scroll da tabela funcionando */
.rs-grid-wrap.overlay .rs-grid-body {
  pointer-events: auto;
}

/* Esconde KPIs, feed, filtros e ações flutuantes quando grid está expandido */
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-kpis,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-floating-actions,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-filter-panel,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-feed {
  display: none !important;
}

/* =========================================================
   SPINNER DE CARREGAMENTO
   ========================================================= */
.rs-table-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 10;
}

.rs-spinner {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  color: #495057;
  font-size: 14px;
}

.rs-spinner i {
  font-size: 28px;
  color: #0d6efd;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =========================================================
   ESTADO VAZIO
   ========================================================= */
.rs-table-empty {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  z-index: 10;
}

.rs-empty-state {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  color: #6c757d;
  font-size: 14px;
  text-align: center;
}

.rs-empty-state i {
  font-size: 32px;
  color: #adb5bd;
  opacity: 0.7;
}

/* =========================================================
   TABELA COM ALINHAMENTO CORRETO
   ========================================================= */

/* Remove todos os estilos padrões do DataTable que podem causar desalinhamento */
.dataTables_wrapper {
  position: relative;
  clear: both;
}

.dataTables_scroll {
  clear: both;
}

.dataTables_scrollHead {
  background: #f8f9fa;
}

/* Garante que o cabeçalho e corpo da tabela tenham o mesmo alinhamento */
.dataTables_scrollHeadInner {
  width: 100% !important;
  padding-right: 0 !important;
}

.dataTables_scrollHeadInner table {
  width: 100% !important;
  margin-bottom: 0 !important;
}

.dataTables_scrollBody {
  -webkit-overflow-scrolling: touch;
}

/* Estilos específicos para a tabela principal */
#tblVehicles {
  font-size: 12px;
  border-collapse: separate !important;
  border-spacing: 0;
  width: 100% !important;
  table-layout: auto;
}

/* Cabeçalho da tabela - estilo corrigido */
#tblVehicles thead th {
  padding: 8px 8px !important;
  white-space: nowrap;
  background-color: #f8f9fa;
  position: relative;
  border-bottom: 1px solid var(--bd);
  text-align: left;
  font-weight: 600;
  color: #495057;
  vertical-align: middle;
}

/* Remove o sorting padrão do DataTable se não estiver sendo usado */
#tblVehicles thead th.sorting,
#tblVehicles thead th.sorting_asc,
#tblVehicles thead th.sorting_desc {
  cursor: pointer;
  position: relative;
}

/* Corpo da tabela - alinhamento corrigido */
#tblVehicles tbody td {
  padding: 6px 8px !important;
  vertical-align: middle;
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Garante que as colunas específicas tenham largura adequada */
#tblVehicles tbody td:nth-child(1) { /* Placa */
  min-width: 100px;
  max-width: 120px;
}

#tblVehicles tbody td:nth-child(2) { /* Frota */
  min-width: 100px;
  max-width: 120px;
}

#tblVehicles tbody td:nth-child(3) { /* Condutor */
  min-width: 120px;
  max-width: 150px;
}

#tblVehicles tbody td:nth-child(4), /* Data Posição */
#tblVehicles tbody td:nth-child(5) { /* Data Servidor */
  min-width: 140px;
  max-width: 160px;
}

#tblVehicles tbody td:nth-child(6) { /* Endereço */
  min-width: 200px;
  max-width: 300px;
}

#tblVehicles tbody td:nth-child(7) { /* Ignição */
  min-width: 80px;
  max-width: 100px;
}

#tblVehicles tbody td:nth-child(8) { /* Vel */
  min-width: 80px;
  max-width: 100px;
}

#tblVehicles tbody td:nth-child(9) { /* Odom */
  min-width: 100px;
  max-width: 120px;
}

#tblVehicles tbody td:nth-child(10) { /* Ações */
  min-width: 140px;
  max-width: 160px;
}

/* Ações na última coluna */
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  justify-content: flex-start;
}

.actions .btn {
  padding: 4px 8px !important;
  line-height: 1 !important;
  font-size: 11px !important;
  transition: all 0.2s;
}

.actions .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Badge para ignição */
#tblVehicles .badge {
  font-size: 11px;
  padding: 3px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
}

/* Remove as bordas duplas do Bootstrap */
.table>:not(caption)>*>* {
  padding: inherit !important;
  background-color: inherit !important;
  border-bottom-width: inherit !important;
  box-shadow: inherit !important;
}

/* Garante que o scroll mantenha o alinhamento */
.dataTables_scrollBody table {
  border-top: none;
  margin-top: 0 !important;
}

.dataTables_scrollBody thead th {
  height: 0 !important;
  padding: 0 !important;
  border: none !important;
  visibility: hidden;
}

/* =========================================================
   PAGINAÇÃO CUSTOMIZADA - CENTRALIZADA
   ========================================================= */
.rs-dt-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--bd);
  background: #fff;
  display: flex;
  justify-content: center;
}

.rs-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
}

.rs-page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rs-page-controls .btn {
  padding: 4px 8px !important;
  font-size: 12px !important;
  line-height: 1;
  border-radius: 6px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dee2e6;
  background-color: #fff;
  color: #6c757d;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Efeito hover para os botões de paginação */
.rs-page-controls .btn:hover:not(:disabled) {
  background-color: #f8f9fa;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Efeito ativo para os botões de paginação */
.rs-page-controls .btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

/* Efeito overlay no hover (para melhor visibilidade) */
.rs-page-controls .btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.03);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.rs-page-controls .btn:hover:not(:disabled)::after {
  opacity: 1;
}

/* Botões desabilitados */
.rs-page-controls .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f8f9fa;
}

/* Efeito para o ícone dentro do botão */
.rs-page-controls .btn i {
  transition: transform 0.2s ease;
}

.rs-page-controls .btn:hover:not(:disabled) i {
  transform: scale(1.1);
}

/* Botões específicos - primeiro e último */
.rs-page-controls .btn:first-child,
.rs-page-controls .btn:last-child {
  background-color: #f8f9fa;
}

.rs-page-controls .btn:first-child:hover:not(:disabled),
.rs-page-controls .btn:last-child:hover:not(:disabled) {
  background-color: #e9ecef;
}

.rs-page-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #495057;
  margin: 0 8px;
  white-space: nowrap;
}

.rs-page-current {
  font-weight: 700;
  color: #212529;
  min-width: 24px;
  text-align: center;
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.rs-page-sep {
  color: var(--muted);
  font-weight: 500;
}

.rs-page-total {
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  color: #495057;
}

/* Remove o paginador padrão do DataTable */
.dataTables_paginate {
  display: none !important;
}

/* =========================================================
   Markers (carrinho)
   ========================================================= */
.mk {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
  transition: transform 0.3s;
}

.mk:hover {
  transform: scale(1.1);
  z-index: 1000;
}

.mk-on {
  background: #22c55e;
}

/* verde */
.mk-off {
  background: #6b7280;
}

/* cinza */
.mk-car {
  font-size: 14px;
  color: #fff;
  line-height: 1;
}

/* Popup */
.rs-popup {
  min-width: 280px;
}

.rs-popup .p-title {
  font-weight: 900;
  margin-bottom: 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rs-popup .p-line {
  font-size: 12px;
  color: #212529;
  margin: 2px 0;
  line-height: 1.4;
}

.rs-popup .p-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.rs-popup .p-actions a,
.rs-popup .p-actions button {
  font-size: 12px;
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* =========================================================
   Modal de Compartilhamento
   ========================================================= */
#shareModal .modal-content {
  border: 1px solid var(--bd);
  box-shadow: var(--shadow);
  border-radius: 12px;
}

#shareModal .modal-header {
  background: #f8f9fa;
  border-bottom: 1px solid var(--bd);
  border-radius: 12px 12px 0 0;
}

#shareModal .modal-title {
  color: #212529;
  font-weight: 700;
  font-size: 16px;
}

#shareModal .form-text {
  font-size: 11px;
  color: var(--muted);
}

#shareModal .alert-info {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
}

#shareModal .input-group {
  border-radius: 8px;
  overflow: hidden;
}

#shareModal #modalLink {
  font-size: 12px;
  background: #f8f9fa;
  border: 1px solid var(--bd);
}

#shareModal #btnCopyLink:hover {
  background: #e9ecef;
}

/* Estilo para quando o botão de cópia é clicado */
#shareModal #btnCopyLink.copied {
  background: #198754;
  color: white;
  border-color: #198754;
}

/* =========================================================
   Cores para badges de severidade
   ========================================================= */
.sev-critical { 
  background-color: #dc3545 !important; 
  color: white !important; 
  border-color: #dc3545 !important;
}

.sev-high { 
  background-color: #fd7e14 !important; 
  color: white !important; 
  border-color: #fd7e14 !important;
}

.sev-medium { 
  background-color: #ffc107 !important; 
  color: #212529 !important; 
  border-color: #ffc107 !important;
}

.sev-low { 
  background-color: #6c757d !important; 
  color: white !important; 
  border-color: #6c757d !important;
}

/* =========================================================
   Responsivo
   ========================================================= */
@media (max-width: 1200px) {
  /* Ajusta posição dos elementos no mapa */
  .rs-filter-panel {
    width: 300px;
  }
  
  .rs-feed {
    width: 350px;
  }
  
  /* Ajusta KPI para telas menores */
  .kpi {
    min-width: 110px;
  }
}

@media (max-width: 1100px) {
  /* Ajusta os elementos para não sobrepor */
  .rs-kpis {
    left: 50%;
    transform: translateX(-50%);
    max-width: 90%;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .rs-filter-panel {
    top: 60px;
  }
  
  /* Ajusta posição dos filtros em telas médias */
  .rs-floating-actions {
    left: 60px;
  }
  
  .rs-filter-panel {
    left: 60px;
  }
}

@media (max-width: 900px) {
  .rs-shell {
    flex-direction: column;
    height: auto;
  }

  .rs-map-wrap {
    height: 45vh;
  }

  /* Ajusta posição dos elementos no mobile */
  .rs-kpis {
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    flex-wrap: nowrap;
    overflow-x: auto;
    width: calc(100% - 20px);
  }
  
  .kpi {
    min-width: 100px;
    flex-shrink: 0;
  }
  
  /* Ajusta posição dos filtros em mobile */
  .rs-floating-actions {
    left: 10px; /* Volta para perto da borda em mobile */
  }
  
  .rs-filter-panel {
    left: 10px; /* Volta para perto da borda em mobile */
    width: 300px;
  }
  
  /* Ajusta paginação para mobile */
  .rs-pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  
  .rs-page-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  /* Ajusta tabela para mobile */
  #tblVehicles tbody td {
    padding: 5px 6px !important;
  }
  
  /* Ajusta feed para mobile */
  .rs-feed {
    width: 320px;
    height: 40vh;
  }
}

@media (max-width: 768px) {
  /* Ajusta cabeçalho do grid para mobile */
  .rs-grid-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .rs-grid-search {
    max-width: 100%;
    order: 1;
    width: 100%;
  }
  
  .rs-grid-actions {
    order: 2;
    align-self: flex-end;
  }
  
  /* Para telas muito pequenas, permite que os KPIs quebrem linha */
  .rs-kpis {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90%;
  }
  
  .kpi {
    min-width: 100px;
  }
  
  /* Ajusta o cabeçalho do grid em mobile */
  .rs-grid-head {
    justify-content: flex-end;
    padding: 8px 10px;
  }
  
  .rs-grid-actions {
    align-self: flex-end;
  }
  
  /* Ajusta o feed para telas menores */
  .rs-feed {
    width: 300px;
    right: 5px;
    top: 5px;
  }
  
  .rs-feed-head {
    padding: 8px 10px;
  }
  
  .feed-item {
    padding: 8px;
  }
  
  /* Ajusta o painel de filtros para mobile */
  .rs-filter-panel {
    left: 5px;
    right: 5px;
    width: auto;
    max-width: 95%;
  }
  
  /* Ajusta o modal para telas pequenas */
  #shareModal .modal-dialog {
    margin: 10px;
  }
  
  /* Ajusta paginação em telas menores */
  .rs-page-controls {
    gap: 6px;
  }
  
  .rs-page-info {
    margin: 0 4px;
  }
  
  /* Ajusta larguras das colunas em mobile */
  #tblVehicles tbody td:nth-child(4),
  #tblVehicles tbody td:nth-child(5) {
    min-width: 120px;
    max-width: 140px;
  }
  
  #tblVehicles tbody td:nth-child(6) {
    min-width: 150px;
    max-width: 200px;
  }
  
  #tblVehicles tbody td:nth-child(10) {
    min-width: 120px;
    max-width: 140px;
  }
  
  /* Ajustes para spinner em mobile */
  .rs-spinner {
    font-size: 12px;
    gap: 8px;
  }
  
  .rs-spinner i {
    font-size: 22px;
  }
  
  .rs-empty-state {
    font-size: 12px;
    gap: 8px;
  }
  
  .rs-empty-state i {
    font-size: 24px;
  }
  
  /* Ajusta paginação em mobile */
  .rs-page-controls .btn {
    min-width: 30px;
    padding: 3px 6px !important;
  }
  
  .rs-page-info {
    font-size: 12px;
  }
  
  .rs-page-current {
    padding: 1px 4px;
  }
}

@media (max-width: 576px) {
  /* Para telas muito pequenas, reduz o tamanho dos KPIs */
  .rs-kpis {
    gap: 6px;
    top: 3px;
  }
  
  .kpi {
    min-width: 90px;
    padding: 5px 8px;
  }
  
  .kpi-label {
    font-size: 10px;
  }
  
  .kpi-value {
    font-size: 14px;
  }
  
  /* Ajusta cabeçalho do grid em telas muito pequenas */
  .rs-grid-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .rs-grid-search {
    width: 100%;
  }
  
  .rs-grid-actions {
    align-self: flex-end;
    width: 100%;
    justify-content: flex-end;
  }
  
  /* Ajusta ações na tabela */
  .actions {
    gap: 4px;
  }
  
  .actions .btn {
    padding: 3px 6px !important;
    font-size: 10px !important;
  }
  
  /* Ajusta cabeçalho do grid em telas muito pequenas */
  .rs-grid-head {
    justify-content: flex-end;
    padding: 8px 6px;
  }
  
  .rs-grid-actions {
    align-self: flex-end;
  }
  
  /* Ajusta feed para telas muito pequenas */
  .rs-feed {
    width: calc(100% - 10px);
    right: 5px;
    left: 5px;
    height: 35vh;
  }
  
  .feed-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .feed-badge {
    align-self: flex-start;
  }
  
  /* Ajusta painel de filtros para telas muito pequenas */
  .rs-filter-panel {
    top: 50px;
  }
  
  /* Modal em telas muito pequenas */
  #shareModal .row.g-3 {
    flex-direction: column;
  }
  
  #shareModal .col-md-6 {
    width: 100%;
  }
  
  /* Ajusta paginação para telas muito pequenas */
  .rs-page-controls {
    gap: 4px;
  }
  
  .rs-page-controls .btn {
    min-width: 28px;
    padding: 3px 5px !important;
    font-size: 11px !important;
  }
  
  .rs-page-info {
    font-size: 11px;
    gap: 4px;
    margin: 0 2px;
  }
  
  .rs-page-current {
    font-size: 11px;
    padding: 1px 3px;
    min-width: 20px;
  }
  
  /* Ajustes finos para tabela em telas muito pequenas */
  #tblVehicles thead th,
  #tblVehicles tbody td {
    padding: 4px 5px !important;
    font-size: 11px;
  }
  
  /* Reduz larguras mínimas para mobile */
  #tblVehicles tbody td:nth-child(1),
  #tblVehicles tbody td:nth-child(2),
  #tblVehicles tbody td:nth-child(3),
  #tblVehicles tbody td:nth-child(4),
  #tblVehicles tbody td:nth-child(5),
  #tblVehicles tbody td:nth-child(7),
  #tblVehicles tbody td:nth-child(8),
  #tblVehicles tbody td:nth-child(9) {
    min-width: 70px;
    max-width: 100px;
  }
  
  #tblVehicles tbody td:nth-child(6) {
    min-width: 100px;
    max-width: 150px;
  }
  
  #tblVehicles tbody td:nth-child(10) {
    min-width: 100px;
    max-width: 120px;
  }
  
  /* Ajustes finos para spinner em telas muito pequenas */
  .rs-spinner {
    font-size: 11px;
    gap: 6px;
  }
  
  .rs-spinner i {
    font-size: 20px;
  }
  
  .rs-empty-state {
    font-size: 11px;
    gap: 6px;
  }
  
  .rs-empty-state i {
    font-size: 20px;
  }
}

/* =========================================================
   CORREÇÕES ESPECÍFICAS PARA GRID EXPANDIDO
   ========================================================= */

/* Esconde todos os controles do Leaflet quando o grid está expandido */
.rs-grid-wrap.overlay ~ .rs-map-wrap .leaflet-control-container {
  display: none !important;
}

/* Garante que o grid expandido fique acima de tudo */
.rs-grid-wrap.overlay {
  z-index: 10000 !important;
}

/* Esconde os KPIs, feed, filtros e ações flutuantes quando o grid está expandido */
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-kpis,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-floating-actions,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-filter-panel,
.rs-grid-wrap.overlay ~ .rs-map-wrap .rs-feed {
  display: none !important;
}

/* Melhorias específicas para botões de paginação em hover */
.rs-page-controls .btn:hover:not(:disabled) {
  z-index: 1; /* Garante que o botão fique sobre outros elementos */
}

/* Adiciona um efeito de "lift" mais sutil nos botões */
.rs-page-controls .btn {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Garante que os ícones dentro dos botões sejam sempre visíveis */
.rs-page-controls .btn i {
  filter: none !important;
  opacity: 1 !important;
}

/* Remove qualquer transparência que possa estar afetando a visibilidade */
.rs-page-controls .btn,
.rs-page-controlps .btn:hover,
.rs-page-controls .btn:focus {
  opacity: 1;
}

/* Garante contraste adequado para os ícones */
.rs-page-controls .btn i {
  color: #6c757d;
}

.rs-page-controls .btn:hover:not(:disabled) i {
  color: #495057;
}

/* Efeito de borda no hover */
.rs-page-controls .btn:hover:not(:disabled) {
  border-color: #6c757d;
}

/* Adiciona um efeito de "press" quando clicado */
.rs-page-controls .btn:active:not(:disabled) {
  background-color: #e9ecef;
  border-color: #adb5bd;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* =========================================================
   CORREÇÕES ADICIONAIS PARA COMPATIBILIDADE
   ========================================================= */

/* Garante que o mapa mantenha seu z-index baixo */
.rs-map-wrap {
  z-index: 1;
}

/* Corrige qualquer overlap indesejado */
.leaflet-top,
.leaflet-bottom {
  z-index: 1000 !important;
}

/* Quando o grid está expandido, desabilita interações com o mapa por baixo */
.rs-grid-wrap.overlay ~ .rs-map-wrap {
  pointer-events: none;
}

/* Mas mantém o scroll da tabela funcionando */
.rs-grid-wrap.overlay .rs-grid-body {
  pointer-events: auto;
}

/* =========================================================
   ESTILOS PARA HISTÓRICO (CORRIGIDO - BORDA AZUL VISÍVEL)
   ========================================================= */

/* Estilos para o histórico */
.history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.history-on {
    background-color: #22c55e; /* verde */
}

.history-off {
    background-color: #6b7280; /* cinza */
}

.history-popup {
    font-size: 12px;
    min-width: 180px;
}

.history-popup strong {
    display: block;
    margin-bottom: 4px;
    color: #212529;
}

.history-popup small {
    color: #6c757d;
    display: block;
    line-height: 1.4;
}

.history-item {
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 4px solid transparent;
    padding: 8px 12px !important;
    margin: 4px 0;
    background-color: #fff;
    border: 1px solid var(--bd);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    width: 100%;
    box-sizing: border-box;
}

.history-item:hover {
    background-color: #f8f9fa;
    border-left-color: #0d6efd;
    transform: translateX(2px);
}

.history-item.active {
    background-color: #e7f1ff;
    border-left: 4px solid #0d6efd !important;
    border-color: #0d6efd;
    box-shadow: 0 0 0 1px #0d6efd; /* Adiciona um outline sutil */
}

/* Modal de histórico específico */
#historyMap {
    background: #f8f9fa;
    min-height: 300px;
}

/* Para telas pequenas, ajusta a altura do mapa */
@media (max-width: 768px) {
    #historyMap {
        height: 300px;
    }
    
    #historyList {
        max-height: 300px !important;
    }
}

/* Ajuste para modal fullscreen em mobile */
@media (max-width: 768px) {
    .modal-fullscreen-md-down {
        width: 100%;
        max-width: none;
        height: 100%;
        margin: 0;
    }
    
    .modal-fullscreen-md-down .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* Ajustes para cards no modal de histórico */
#historySummary .card {
    border: 1px solid var(--bd);
    box-shadow: var(--shadow-soft);
}

#historySummary .card-title {
    font-size: 14px;
    color: #495057;
}

/* Estilo para a lista de posições */
.list-group-flush .list-group-item:first-child {
    border-top: 0;
}

.list-group-flush .list-group-item:last-child {
    border-bottom: 0;
}


/* =========================================================
   ESTILOS PARA ABAS DE HISTÓRICO
   ========================================================= */

/* Estilo para as abas dinâmicas */
#dynamicTabs .nav-item {
  margin-right: 2px;
}

#dynamicTabs .nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

#dynamicTabs .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(255, 255, 255, 0.5);
}

#dynamicTabs .nav-link.active {
  background-color: rgba(255, 255, 255, 0.25);
  border-bottom-color: #fff;
  font-weight: 500;
}

#dynamicTabs .close-tab {
  opacity: 0.6;
  font-size: 0.8rem;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-left: 6px;
}

#dynamicTabs .close-tab:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.2);
}

/* Conteúdo das abas */
.tab-content {
  height: calc(100vh - 56px); /* Altura total menos a navbar */
  overflow: hidden;
  position: relative;
}

.tab-pane {
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Estilo para o conteúdo do histórico dentro da aba */
.history-tab-content {
  position: relative;
  min-height: 100%;
  background-color: #f8f9fa;
  height: 100%;
  overflow: hidden;
}

.history-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Ajustes para o mapa dentro da aba */
.history-tab-content .history-map {
  width: 100%;
  height: 400px;
  background-color: #e9ecef;
}

/* Estilo para a lista de posições */
.history-tab-content .history-positions-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-tab-content .history-item {
  cursor: pointer;
  transition: background-color 0.2s;
  border-left: 3px solid transparent;
}

.history-tab-content .history-item:hover {
  background-color: #f8f9fa;
  border-left-color: #0d6efd;
}

.history-tab-content .history-item.active {
  background-color: #e7f1ff;
  border-left-color: #0d6efd;
}

/* Marcadores do histórico */
.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.history-on {
  background-color: #22c55e;
}

.history-off {
  background-color: #6b7280;
}

.history-popup {
  font-size: 12px;
  min-width: 180px;
}

.history-popup strong {
  display: block;
  margin-bottom: 4px;
  color: #212529;
}

.history-popup small {
  color: #6c757d;
  display: block;
  line-height: 1.4;
}

/* Responsividade para as abas */
@media (max-width: 768px) {
  #dynamicTabs .nav-link {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  
  .history-tab-content .history-map {
    height: 300px;
  }
  
  .history-tab-content .history-positions-list {
    max-height: 300px;
  }
}

@media (max-width: 576px) {
  #dynamicTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100vw - 100px);
  }
  
  #dynamicTabs .nav-item {
    flex: 0 0 auto;
  }
  
  .history-tab-content .container-fluid {
    padding: 0.5rem;
  }
}


/* =========================================================
   HISTÓRICO EM TELA CHEIA - ABAS (VERSÃO CORRIGIDA - BORDA AZUL VISÍVEL)
   ========================================================= */

/* Container principal das abas */
.tab-content {
  height: calc(100vh - 56px);
  overflow: hidden;
  position: relative;
}

/* Cada painel de aba */
.tab-pane {
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Conteúdo da aba de histórico */
.history-tab-content {
  height: 100%;
  overflow: hidden;
  background-color: #f8f9fa;
  position: relative;
}

/* Container flexível para o conteúdo */
.history-full-height {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Cabeçalho com título e controles */
.history-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #fff;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--bd);
  box-shadow: var(--shadow-soft);
}

.history-header h4 {
  margin: 0;
  font-size: 1.3rem;
  color: #212529;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.history-header h4 i {
  color: #0d6efd;
}

/* Controles de data */
.history-date-controls {
  display: flex;
  gap: 0.5rem;
}

.history-date-controls .input-group {
  width: auto;
  min-width: 300px;
}

.history-date-controls .form-control {
  border-radius: 6px 0 0 6px;
  border: 1px solid var(--bd);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.history-date-controls .btn {
  border-radius: 0 6px 6px 0;
  padding: 0.5rem 1rem;
  background-color: #0d6efd;
  color: white;
  border: none;
  font-weight: 500;
  transition: all 0.2s;
}

.history-date-controls .btn:hover {
  background-color: #0b5ed7;
  transform: translateY(-1px);
}

/* Área principal com mapa e lista */
.history-main-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
  overflow: hidden;
  width: 100%;
}

/* Container do mapa - 70% */
.history-map-container {
  flex: 7;
  position: relative;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-map-header {
  padding: 0.75rem 1.25rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--bd);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-map-header .badge {
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  background-color: #0d6efd;
  color: white;
  border-radius: 20px;
}

.history-map {
  flex: 1;
  min-height: 0;
  background: #e9ecef;
  width: 100%;
}

/* Container da lista - 30% */
.history-list-container {
  flex: 3;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.history-list-header {
  padding: 0.75rem 1.25rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--bd);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-list-header span:last-child {
  font-size: 0.85rem;
  color: #6c757d;
  background: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--bd);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 0.75rem; /* Aumentado para dar espaço */
  width: 100%;
}

/* Itens da lista - CORRIGIDO PARA MOSTRAR BORDA AZUL COMPLETA */
.history-item {
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
  padding: 0.6rem 0.8rem !important; /* Padding reduzido nas laterais */
  margin: 0 0 0.4rem 0; /* Margem apenas inferior, remove margem lateral */
  font-size: 0.85rem;
  background-color: #fff;
  border: 1px solid var(--bd);
  border-radius: 6px;
  width: calc(100% - 2px); /* Ajuste fino para não cortar */
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  position: relative;
}

.history-item:last-child {
  margin-bottom: 0;
}

.history-item:hover {
  background-color: #f8f9fa;
  border-left-color: #0d6efd;
  transform: translateX(2px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.05);
}

.history-item.active {
  background-color: #e7f1ff;
  border-left: 4px solid #0d6efd !important;
  border-color: #0d6efd;
  box-shadow: 0 0 0 1px #0d6efd; /* Outline azul sutil */
  /* Garante que a borda esquerda fique visível */
  margin-left: 0;
  margin-right: 0;
  width: 100%;
}

/* Header do item */
.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  gap: 0.5rem;
  width: 100%;
}

.history-time {
  font-weight: 700;
  color: #212529;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.history-time i {
  font-size: 0.7rem;
  margin-right: 0.3rem;
  color: #6c757d;
}

.history-ignition-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.history-item-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #6c757d;
  font-size: 0.8rem;
  gap: 0.5rem;
  width: 100%;
}

.history-address {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 2;
  min-width: 0;
}

.history-address i {
  font-size: 0.7rem;
  margin-right: 0.3rem;
  color: #0d6efd;
  opacity: 0.7;
}

.history-speed {
  white-space: nowrap;
  font-weight: 600;
  background: #e9ecef;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #212529;
}

.history-speed i {
  font-size: 0.65rem;
  color: #0d6efd;
}

/* Mensagem quando não há dados */
.history-message {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: #6c757d;
  font-size: 0.95rem;
  background: #fff;
  border-radius: 8px;
  border: 1px dashed var(--bd);
  margin: 1rem;
}

.history-message i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
  color: #0d6efd;
}

/* Loading overlay */
.history-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.history-loading-overlay .spinner-border {
  width: 2.5rem;
  height: 2.5rem;
}

/* Responsividade */
@media (max-width: 1400px) {
  .history-main-area {
    gap: 1.25rem;
  }
  
  .history-map-container {
    flex: 6.5;
  }
  
  .history-list-container {
    flex: 3.5;
  }
}

@media (max-width: 1200px) {
  .history-full-height {
    padding: 1.25rem;
    gap: 1.25rem;
  }
  
  .history-main-area {
    gap: 1rem;
  }
  
  .history-map-container {
    flex: 6;
  }
  
  .history-list-container {
    flex: 4;
  }
  
  .history-item {
    padding: 0.5rem 0.7rem !important;
  }
}

@media (max-width: 992px) {
  .history-main-area {
    gap: 1rem;
  }
  
  .history-map-container {
    flex: 5.5;
  }
  
  .history-list-container {
    flex: 4.5;
  }
  
  .history-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  
  .history-ignition-badge {
    align-self: flex-start;
  }
}

@media (max-width: 768px) {
  .history-full-height {
    padding: 1rem;
    gap: 1rem;
  }
  
  .history-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  
  .history-header h4 {
    font-size: 1.1rem;
  }
  
  .history-date-controls .input-group {
    width: 100%;
  }
  
  .history-main-area {
    flex-direction: column;
    gap: 1rem;
  }
  
  .history-map-container {
    flex: none;
    height: 350px;
  }
  
  .history-list-container {
    flex: none;
    height: 300px;
    width: 100%;
  }
  
  .history-item {
    padding: 0.5rem 0.7rem !important;
    font-size: 0.8rem;
    width: 100%;
  }
  
  .history-time {
    font-size: 0.8rem;
  }
  
  .history-item-details {
    font-size: 0.75rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  
  .history-address {
    width: 100%;
  }
  
  .history-speed {
    align-self: flex-start;
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .history-full-height {
    padding: 0.75rem;
    gap: 0.75rem;
  }
  
  .history-header h4 {
    font-size: 1rem;
  }
  
  .history-map-container {
    height: 300px;
  }
  
  .history-list-container {
    height: 280px;
  }
  
  .history-list {
    padding: 0.5rem;
  }
  
  .history-item {
    padding: 0.4rem 0.6rem !important;
    margin-bottom: 0.3rem;
    width: 100%;
  }
  
  .history-item-header {
    margin-bottom: 0.2rem;
  }
  
  .history-time {
    font-size: 0.75rem;
  }
  
  .history-ignition-badge {
    font-size: 0.65rem;
  }
  
  .history-item-details {
    font-size: 0.7rem;
  }
  
  .history-speed {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
  }
}



/* =========================================================
   AJUSTES PARA VELOCIDADE COM LIMITE
   ========================================================= */
#tblVehicles tbody td:nth-child(8) { /* Coluna Vel */
    min-width: 120px; /* Aumenta um pouco para acomodar a informação extra */
    max-width: 150px;
}

.history-speed {
    white-space: normal !important; /* Permite quebra de linha se necessário */
    line-height: 1.3;
}

.history-speed small {
    font-size: 0.65rem;
    color: #6c757d;
}

/* Para telas muito pequenas, ajusta a coluna de velocidade */
@media (max-width: 576px) {
    #tblVehicles tbody td:nth-child(8) {
        min-width: 100px;
        max-width: 120px;
    }
}

/* =========================================================
   FILTRO DE EVENTOS DENTRO DA LISTA DE HISTÓRICO
   ========================================================= */

.history-filter-inside {
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--bd);
}

.history-filter-inside .form-select-sm {
  font-size: 0.8rem;
  padding: 0.2rem 1.5rem 0.2rem 0.4rem;
  background-position: right 0.3rem center;
  background-size: 10px;
  border-color: #dee2e6;
}

.history-filter-inside .btn-clear-event-filter {
  line-height: 1.2;
  color: #6c757d;
}

.history-filter-inside .btn-clear-event-filter:hover {
  background-color: #e9ecef;
  border-color: #ced4da;
  color: #495057;
}

/* Ajuste na altura da lista para acomodar o filtro */
.history-list {
  height: calc(100% - 85px) !important;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Responsividade */
@media (max-width: 768px) {
  .history-filter-inside .d-flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
  
  .history-filter-inside .form-select-sm {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .history-filter-inside .btn-clear-event-filter {
    width: 100%;
  }
  
  .history-list {
    height: calc(100% - 100px) !important;
  }
}

@media (max-width: 576px) {
  .history-filter-inside {
    padding: 0.5rem !important;
  }
  
  .history-filter-inside .form-select-sm {
    font-size: 0.75rem;
  }
}

/* =========================================================
   COMPARTILHAMENTO - PÁGINA PÚBLICA
   ========================================================= */

/* Container principal */
.share-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Mapa */
#shareMap {
  width: 100%;
  height: 100%;
  background: #f8f9fa;
}

/* Card flutuante */
.share-card {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  width: 340px;
  max-width: calc(100% - 40px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
  border: 1px solid #e9ecef;
  overflow: hidden;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

.share-card-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.share-card-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-card-header h5 i {
  font-size: 1.2rem;
}

.share-card-body {
  padding: 16px 20px;
}

/* Info do veículo */
.share-vehicle-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.share-plate {
  font-size: 1.4rem;
  font-weight: 700;
  color: #212529;
  letter-spacing: 1px;
}

.share-time {
  font-size: 0.8rem;
  color: #6c757d;
  margin-top: 2px;
}

.share-ignition {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.share-ignition.on {
  background: #22c55e;
  color: white;
}

.share-ignition.off {
  background: #6c7280;
  color: white;
}

/* Divisor */
.share-divider {
  margin: 12px 0;
  border-top: 1px solid #e9ecef;
}

/* Detalhes */
.share-detail {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #495057;
}

.share-detail i {
  width: 18px;
  color: #0d6efd;
  font-size: 0.9rem;
  margin-top: 3px;
}

.share-detail .share-label {
  min-width: 60px;
  color: #6c757d;
}

.share-detail .share-value {
  flex: 1;
  word-break: break-word;
}

/* Endereço com destaque */
.share-address {
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 0.9rem;
  border-left: 3px solid #0d6efd;
}

/* Footer do card */
.share-card-footer {
  padding: 12px 20px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  font-size: 0.8rem;
  color: #6c757d;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.share-poll-info {
  display: flex;
  align-items: center;
  gap: 5px;
}

.share-poll-info i {
  color: #0d6efd;
}

.share-expires {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Marcador personalizado */
.share-marker {
  background: transparent;
  border: none;
}

.share-car {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s;
}

.share-car:hover {
  transform: scale(1.1);
}

.share-car i {
  font-size: 16px;
  color: white;
}

.share-car.share-on {
  background: #22c55e;
}

.share-car.share-off {
  background: #6b7280;
}

/* Popup do marcador */
.share-popup {
  min-width: 200px;
  font-size: 0.85rem;
}

.share-popup .fw-bold {
  color: #0d6efd;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.share-popup i {
  width: 16px;
  color: #6c757d;
}

/* Loading state */
.share-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  flex-direction: column;
  gap: 15px;
  color: #6c757d;
}

.share-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e9ecef;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error state */
.share-error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  flex-direction: column;
  gap: 15px;
  color: #dc3545;
  text-align: center;
}

.share-error i {
  font-size: 3rem;
  opacity: 0.5;
}

/* Responsividade */
@media (max-width: 768px) {
  .share-card {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
  }
  
  .share-card-header {
    padding: 12px 16px;
  }
  
  .share-card-body {
    padding: 12px 16px;
  }
  
  .share-plate {
    font-size: 1.2rem;
  }
  
  .share-detail {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .share-card {
    max-width: calc(100% - 20px);
  }
  
  .share-card-footer {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* =========================================================
   COMPARTILHAMENTO - MÚLTIPLAS POSIÇÕES
   ========================================================= */

/* Marcador da posição atual */
.share-latest {
  width: 36px;
  height: 36px;
  background: #0d6efd;
  border: 2px solid white;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.3);
  z-index: 1000;
}

.share-latest i {
  font-size: 22px !important;
}

/* Marcadores históricos */
.history-marker {
  background: transparent;
  border: none;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.history-dot:hover {
  transform: scale(1.5);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.history-on {
  background-color: #22c55e;
}

.history-off {
  background-color: #6b7280;
}

/* Popup do histórico */
.history-popup {
  font-size: 11px;
  min-width: 160px;
  padding: 4px;
}

.history-popup strong {
  display: block;
  margin-bottom: 4px;
  color: #212529;
  font-size: 11px;
}

.history-popup hr {
  margin: 4px 0;
  opacity: 0.2;
}

.history-popup div {
  margin: 2px 0;
  color: #6c757d;
}

/* Linha da rota */
.leaflet-polyline {
  stroke-dasharray: 5, 5;
  animation: dash 30s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -100;
  }
}

/* Setas de direção */
.direction-arrow {
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translateX(-50%) scale(1.1);
  }
}

/* Responsividade para os marcadores */
@media (max-width: 768px) {
  .share-latest {
    width: 30px;
    height: 30px;
  }
  
  .share-latest i {
    font-size: 18px !important;
  }
  
  .history-dot {
    width: 6px;
    height: 6px;
  }
  
  .direction-arrow {
    display: none; /* Esconde setas em mobile para não poluir */
  }
}

@media (max-width: 480px) {
  .share-latest {
    width: 26px;
    height: 26px;
  }
  
  .share-latest i {
    font-size: 16px !important;
  }
}
