* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --danger-color: #e74c3c;
  --light-gray: #ecf0f1;
  --dark-gray: #7f8c8d;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--light-gray);
  color: var(--primary-color);
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Cabeçalho */
.header {
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  );
  color: var(--white);
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.update-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.update-info span {
  font-size: 0.9rem;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--white);
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.btn-refresh i {
  margin-right: 0.5rem;
}

/* Conteúdo principal */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--white);
  box-shadow: var(--shadow);
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Painel de busca */
.search-panel {
  background: var(--light-gray);
  padding: 1.5rem;
  border-radius: 10px;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-box input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 0.95rem;
  transition: border-color 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--secondary-color);
}

.btn-clear {
  background: var(--danger-color);
  border: none;
  color: var(--white);
  padding: 0.75rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-clear:hover {
  background: #c0392b;
  transform: scale(1.05);
}

.search-results {
  max-height: 300px;
  overflow-y: auto;
}

.vehicle-item {
  background: var(--white);
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.vehicle-item:hover {
  transform: translateX(5px);
  box-shadow: var(--shadow);
}

.vehicle-item.green {
  border-left-color: var(--success-color);
}

.vehicle-item.yellow {
  border-left-color: #f1c40f;
}

.vehicle-item.orange {
  border-left-color: var(--warning-color);
}

.vehicle-item.red {
  border-left-color: var(--danger-color);
}

.vehicle-placa {
  font-weight: bold;
  font-size: 1rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.vehicle-info {
  font-size: 0.85rem;
  color: var(--dark-gray);
}

.vehicle-time {
  font-size: 0.8rem;
  color: var(--dark-gray);
  margin-top: 0.25rem;
}

/* Legenda */
.legend-panel {
  background: var(--light-gray);
  padding: 1.5rem;
  border-radius: 10px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.legend-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--white);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.legend-marker.green {
  background-color: var(--success-color);
}

.legend-marker.yellow {
  background-color: #f1c40f;
}

.legend-marker.orange {
  background-color: var(--warning-color);
}

.legend-marker.red {
  background-color: var(--danger-color);
}

/* Estatísticas */
.stats-panel {
  background: var(--light-gray);
  padding: 1.5rem;
  border-radius: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-item {
  background: var(--white);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--secondary-color);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--dark-gray);
  margin-top: 0.5rem;
}

/* Mapa */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  height: 100%;
  width: 100%;
}

/* Loading */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  padding: 2rem 3rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
  z-index: 1000;
}

.loading.hidden {
  display: none;
}

.spinner {
  border: 4px solid var(--light-gray);
  border-top: 4px solid var(--secondary-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Popup do Leaflet customizado */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  padding: 0;
}

.leaflet-popup-content {
  margin: 0;
  min-width: 250px;
}

.popup-content {
  padding: 1rem;
}

.popup-header {
  background: var(--secondary-color);
  color: var(--white);
  padding: 0.75rem 1rem;
  font-weight: bold;
  font-size: 1.1rem;
  border-radius: 8px 8px 0 0;
}

.popup-body {
  padding: 1rem;
}

.popup-row {
  display: flex;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.popup-label {
  font-weight: bold;
  color: var(--primary-color);
  min-width: 100px;
}

.popup-value {
  color: var(--dark-gray);
}

/* Scrollbar customizada */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
  background: var(--light-gray);
}

.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
  background: var(--dark-gray);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Responsivo */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 40vh;
  }

  .main-content {
    flex-direction: column;
  }

  .header-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
