/* ============================================
   VEHICLE TRACKING DASHBOARD - Modern Theme
   ============================================ */

/* --- Layout Version Toggle (v1/v2) --- */
/* Por padrão (v1), esconde v2 e mostra v1 */
.layout-v2 { display: none !important; }
.layout-v1 { display: block !important; }

/* Quando body tem data-layout="v2", inverte */
body[data-layout="v2"] .layout-v1 { display: none !important; }
body[data-layout="v2"] .layout-v2 { display: block !important; }

/* --- Dashboard Header --- */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  margin-bottom: 0.5rem;
}

.dashboard-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-header h1::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.4em;
  background: linear-gradient(180deg, #3b82f6, #06b6d4);
  border-radius: 2px;
}

.dashboard-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.dashboard-stats .stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--color-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: var(--rounded-full);
  font-weight: 500;
}

/* --- Search Bar Modern --- */
.search-bar-modern {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--rounded-xl);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar-modern:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-bar-modern label {
  display: none;
}

.search-bar-modern .search-icon {
  width: 20px;
  height: 20px;
  opacity: 0.4;
  flex-shrink: 0;
}

.search-bar-modern .input {
  border: none;
  box-shadow: none;
  background: transparent;
  flex: 1;
  font-size: 0.9rem;
  outline: none;
  padding: 0;
}

.search-bar-modern .input:focus {
  outline: none;
  box-shadow: none;
}

/* --- Vehicle Cards Grid --- */
.vehicles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 0.2rem;
}

@media (max-width: 480px) {
  .vehicles-grid {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

/* --- Vehicle Card --- */
.vehicle-card {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--rounded-xl);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vehicle-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

/* Status accent bar at top of card */
.vehicle-card::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: background 0.3s;
}

.vehicle-card[data-status="online"]::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.vehicle-card[data-status="offline"]::before {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.vehicle-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
  gap: 0.75rem;
}

.vehicle-card__name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  line-height: 1.3;
}

.vehicle-card__name .vehicle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-lg);
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  flex-shrink: 0;
}

.vehicle-card__name .vehicle-icon svg {
  width: 18px;
  height: 18px;
  fill: white;
  stroke: white;
}

.vehicle-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem 0.75rem;
  flex-wrap: wrap;
}

.vehicle-card__speed {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-subtle);
  background: var(--color-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--rounded-full);
}

.vehicle-card__speed svg {
  width: 12px;
  height: 12px;
}

.vehicle-card__actions {
  padding: 0 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* --- Status Indicator Modern --- */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: var(--rounded-full);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.status-indicator--online {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.status-indicator--online .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

.status-indicator--offline {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.status-indicator--offline .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}

.status-timestamp {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--color-text-subtle);
  background: var(--color-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--rounded-full);
}

.status-timestamp img {
  width: 12px;
  height: 12px;
  opacity: 0.6;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* --- Turbo Frame Areas --- */
.vehicle-card__details-area {
  padding: 0 0.2rem;
}

/* --- Details Expanded Panel --- */
.details-panel {
  background: var(--color-secondary);
  border-radius: var(--rounded-lg);
  margin: 0.2rem 0.2rem 0.2rem;
  padding: 0.2rem;
  border: 1px solid var(--color-border);
}

.details-panel__status-msg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.details-panel__msg {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
}

.details-panel__actions-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* --- Telemetry Grid (Information) --- */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.telemetry-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg);
  border-radius: var(--rounded-lg);
  border: 1px solid var(--color-border);
  transition: background 0.15s;
  cursor: default;
  font-size: 0.8rem;
}

.telemetry-item:hover {
  background: var(--color-secondary);
}

.telemetry-item img {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.telemetry-item__label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  display: block;
  line-height: 1;
}

.telemetry-item__value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  display: block;
  line-height: 1.2;
}

.telemetry-section-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.5rem 0;
}

/* --- Map Toggle Modern --- */
.map-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.map-toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-subtle);
  font-weight: 500;
}

/* --- Events Section --- */
.events-section {
  margin: 0.5rem 1.25rem 1rem;
}

.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.events-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.events-table thead {
  background: var(--color-secondary);
}

.events-table thead th {
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  border-bottom: 1px solid var(--color-border);
}

.events-table thead th:first-child {
  border-radius: var(--rounded-lg) 0 0 0;
}

.events-table thead th:last-child {
  border-radius: 0 var(--rounded-lg) 0 0;
}

.events-table tbody tr {
  transition: background 0.15s;
}

.events-table tbody tr:hover {
  background: var(--color-secondary);
}

.events-table tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.events-table tbody td:first-child {
  font-weight: 500;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-subtle);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  opacity: 0.3;
}

.empty-state h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto;
}

/* --- Admin ID Badge --- */
.admin-debug-badge {
  position: absolute;
  bottom: 6px;
  right: 12px;
  font-size: 0.6rem;
  color: var(--color-text-subtle);
  opacity: 0.5;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* --- Pagination Modern --- */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

/* --- Buttons inside Vehicle Cards --- */
.vehicle-card .btn {
  font-size: 0.8rem;
}

/* --- Details Status Content --- */
.details-status-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
}

/* --- Close Button Events --- */
.events-close-btn {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

/* --- Responsive Adjustments --- */
@media (max-width: 480px) {
  .vehicle-card__header {
    padding: 0.75rem 1rem 0.5rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .vehicle-card__meta {
    padding: 0 1rem 0.5rem;
  }

  .vehicle-card__actions {
    padding: 0 1rem 0.75rem;
  }

  .details-panel {
    margin: 0.5rem 0.75rem 0.75rem;
    padding: 0.75rem;
  }

  .telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .events-section {
    margin: 0.5rem 0.75rem 0.75rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
  .vehicle-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
  }

  .status-indicator--online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
  }

  .status-indicator--offline {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
  }

  .vehicle-card__name .vehicle-icon {
    background: linear-gradient(135deg, #2563eb, #1e40af);
  }

  .telemetry-item {
    background: rgba(255, 255, 255, 0.03);
  }

  .telemetry-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* --- Highlight Flash (v1 - amarelo alaranjado) --- */
@keyframes highlight-flash {
  0%   { background-color: transparent !important; transform: scale(1); box-shadow: none; }
  15%  { background-color: #fbbf24 !important; transform: scale(1.02); box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
  35%  { background-color: #f59e0b !important; transform: scale(1.02); box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
  55%  { background-color: #fbbf24 !important; transform: scale(1.01); box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }
  75%  { background-color: #fcd34d !important; transform: scale(1); box-shadow: none; }
  100% { background-color: transparent !important; transform: scale(1); box-shadow: none; }
}

.btn.updated {
  animation: highlight-flash 2.5s ease-in-out !important;
  background-color: transparent !important;
}

.btn.updated span {
  font-weight: bold;
  color: #92400e;
}

/* --- Highlight Flash (v2 - azul forte) --- */
@keyframes highlight-flash-blue {
  0%   { background-color: transparent !important; transform: scale(1); box-shadow: none; }
  15%  { background-color: #60a5fa !important; transform: scale(1.02); box-shadow: 0 0 12px rgba(37, 99, 235, 0.6); }
  35%  { background-color: #3b82f6 !important; transform: scale(1.02); box-shadow: 0 0 10px rgba(37, 99, 235, 0.4); }
  55%  { background-color: #60a5fa !important; transform: scale(1.01); box-shadow: 0 0 6px rgba(37, 99, 235, 0.3); }
  75%  { background-color: #93c5fd !important; transform: scale(1); box-shadow: none; }
  100% { background-color: transparent !important; transform: scale(1); box-shadow: none; }
}

.telemetry-item.updated {
  animation: highlight-flash-blue 2.5s ease-in-out !important;
  background-color: transparent !important;
}

.telemetry-item.updated .telemetry-item__value {
  font-weight: bold;
  color: #1e40af;
}
