/* ========================================= */
/* ESTILOS GLOBAIS                           */
/* ========================================= */
body {
  background-color: #121212;
  color: #e0e0e0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
}

h1 {
  text-align: center;
  color: #ffffff;
  margin-bottom: 20px;
}

/* ========================================= */
/* MENU DE NAVEGAÇÃO                         */
/* ========================================= */
.nav {
  background-color: #1e1e1e;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
}

.nav a {
  color: #4caf50;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
}

.nav a:hover {
  text-decoration: underline;
}

.nav a.ativo {
  color: #ffd700;
  border-bottom: 2px solid #ffd700;
}

/* ========================================= */
/* CARDS E INFORMAÇÕES (Dashboard)           */
/* ========================================= */
.info-global {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

.card {
  background-color: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px 25px;
  text-align: center;
  min-width: 150px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.card span {
  display: block;
  font-size: 1.5em;
  font-weight: bold;
  color: #4caf50;
  margin-top: 10px;
}

/* ========================================= */
/* DESTAQUES DO LIVE TIMING                  */
/* ========================================= */
.melhor-volta-roxa {
  color: #c084fc !important;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.6);
}

/* ========================================= */
/* TABELAS                                   */
/* ========================================= */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: #1e1e1e;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  font-size: 0.9em;
}

th, td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #333;
}

th {
  background-color: #2c2c2c;
  color: #ffffff;
  text-transform: uppercase;
}

tr:hover {
  background-color: #2a2a2a;
}

/* ========================================= */
/* PAINÉIS, FORMULÁRIOS E BOTÕES             */
/* ========================================= */
.painel-form, .painel-vinculos {
  background-color: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.painel-form h2, .painel-vinculos h2 {
  margin-top: 0;
  color: #ffd700;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: span 2;
}

.acoes-form {
  grid-column: span 2;
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

label {
  margin-bottom: 5px;
  font-weight: bold;
  color: #aaa;
  font-size: 0.9em;
}

input, select {
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #444;
  background-color: #2c2c2c;
  color: white;
  font-size: 1em;
}

input:focus, select:focus {
  outline: none;
  border-color: #4caf50;
}

/* select usado em paradas.html - mais largo, visual levemente distinto do input padrão */
select {
  width: 100%;
  border-radius: 4px;
  border: 1px solid #555;
  background: #333;
  margin-bottom: 10px;
}

button {
  padding: 12px 20px;
  border-radius: 5px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  font-size: 1em;
  transition: background 0.3s;
  color: white;
}

.btn-salvar { background-color: #4caf50; color: white; }
.btn-salvar:hover { background-color: #45a049; }

.btn-cancelar { background-color: #555; color: white; }
.btn-cancelar:hover { background-color: #777; }

.btn-editar { background-color: #ffd700; color: #000; padding: 6px 12px; font-size: 0.85em; }
.btn-deletar { background-color: #ff4c4c; color: white; padding: 6px 12px; font-size: 0.85em; }

/* ========================================= */
/* TAGS E GRIDS DE EQUIPES (Vínculos)        */
/* ========================================= */
.grid-equipes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.kart-equipe {
  background-color: #2a2a2a;
  padding: 15px;
  border-radius: 5px;
  border-left: 5px solid #4caf50;
}

.kart-equipe strong {
  font-size: 1.1em;
  color: #ffd700;
  display: block;
  margin-bottom: 10px;
}

.piloto-tag {
  display: inline-block;
  background-color: #333;
  padding: 8px 12px;
  margin: 5px 5px 0 0;
  border-radius: 20px;
  font-size: 0.9em;
  border: 1px solid #444;
}

.btn-remover {
  color: #ff4c4c;
  cursor: pointer;
  margin-left: 8px;
  font-weight: bold;
}

/* ================================================== */
/* CSS EXCLUSIVO DA TELA DE TENDÊNCIAS (GRÁFICOS)      */
/* Layout legado de grid de cards - mantido caso ainda */
/* esteja em uso em alguma página; renomeado de        */
/* .card-kart para .card-kart-grafico pra não colidir  */
/* com o .card-kart usado em paradas.html (eram dois   */
/* componentes visuais diferentes competindo pelo      */
/* mesmo nome de classe).                              */
/* ================================================== */

.grid-graficos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 30px;
  padding: 0 20px;
}

.card-kart-grafico {
  background: #2a2a2a;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
}

.media-ritmo { 
  font-size: 1.2rem; 
  font-weight: bold; 
  color: #00ff88; 
}

/* ================================================== */
/* EFEITO DO ALERTA DE QUEDA DE RITMO                 */
/* ================================================== */

.card-alerta {
  border: 2px solid #ff4444;
  background: #3a1c1c;
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

.card-alerta .media-ritmo { 
  color: #ff4444; 
}

.badge-alerta {
  background: #ff4444;
  color: white;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 10px;
  animation: piscar 1.5s infinite;
}

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

/* --- Estilos para a página de Classificação Virtual --- */

.tabela-container {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 15px;
  margin-top: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  overflow-x: auto;
}

.tabela-virtual {
  width: 100%;
  border-collapse: collapse;
}

.tabela-virtual th, .tabela-virtual td {
  padding: 14px 10px;
  text-align: center;
  border-bottom: 1px solid #333;
}

.tabela-virtual th {
  background-color: #2a2a2a;
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 1px;
}

.tabela-virtual tr:hover {
  background-color: #2a2a2a;
}

.linha-lider td {
  color: #00ff88;
  font-weight: bold;
}

.badge-devendo {
  background-color: #ff4444;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.badge-ok {
  background-color: #00ff88;
  color: black;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.kart-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.posicao-virtual {
  background-color: #444;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.9em;
}

/* --- ESTILOS DO CONTADOR DE ATUALIZAÇÃO --- */
#contador-atualizacao {
  text-align: center;
  font-weight: bold;
  color: #e74c3c;
  margin-bottom: 20px;
}

/* --- ESTILO DO SUBTÍTULO --- */
.subtitulo-grafico {
  text-align: center;
}

/* --- ESTILOS DO FILTRO DE KARTS (TEMA ESCURO) --- */
.filtro-container {
  text-align: center;
  margin-bottom: 20px;
  padding: 15px;
  background-color: #111111;
  color: #ffffff;
  border-radius: 8px;
  border: 1px solid #333333;
}

#botoes-filtro {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.btn-filtro {
  background-color: #e0e0e0;
  border: 2px solid transparent;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9em;
  color: #333;
  transition: all 0.2s ease;
}

.btn-filtro:hover {
  background-color: #d0d0d0;
}

.btn-filtro.ativo {
  background-color: #3498db;
  color: white;
  border-color: #2980b9;
}

.btn-perigo {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-top: 10px;
}

.btn-perigo:hover {
  background-color: #c0392b;
}

/* --- ESTILOS DA BARRA DE POSIÇÃO EM PISTA --- */
.pista-container {
  position: relative;
  width: 100%;
  height: 20px;
  margin: 10px 0;
  display: flex;
  align-items: center;
}

.pista-linha {
  position: absolute;
  width: 100%;
  height: 4px;
  background-color: #333333;
  border-radius: 2px;
}

.kart-ponto {
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: #00ff88;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 5px rgba(0, 255, 136, 0.8);
  transition: left 1s ease-in-out;
}

/* =========================================
   ESTILOS DO CONTROLE DE BOX (paradas.html)
   ========================================= */

.grid-box {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.card-kart {
  background-color: #1e1e1e;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 20px;
  position: relative;
}

.kart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #444;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.kart-num {
  font-size: 1.5em;
  font-weight: bold;
  color: #ffd700;
  background: #333;
  padding: 5px 12px;
  border-radius: 5px;
}

.piloto-atual {
  font-size: 1.3em;
  color: #4caf50;
  font-weight: bold;
  margin-bottom: 5px;
}

.cronometro-pista {
  font-size: 1.4em;
  font-weight: bold;
  color: #fff;
  background: #000;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  margin-bottom: 15px;
  border: 1px solid #555;
}

.alerta-pesado {
  display: block;
  font-size: 0.65em;
  margin-top: 5px;
}

.alerta-vermelho { color: #e74c3c; }
.alerta-verde { color: #4caf50; }

.historico-box {
  margin-top: 15px;
  background: #2a2a2a;
  padding: 10px;
  border-radius: 5px;
  font-size: 0.85em;
  max-height: 120px;
  overflow-y: auto;
}

.historico-item {
  border-bottom: 1px dashed #444;
  padding: 6px 0;
  color: #ccc;
}

.btn-troca {
  width: 100%;
  background-color: #e74c3c;
  color: white;
  margin-top: 10px;
  padding: 12px;
}
.btn-troca:hover { background-color: #c0392b; }

.btn-largada {
  width: 100%;
  background-color: #3498db;
  color: white;
  margin-top: 10px;
  padding: 12px;
}
.btn-largada:hover { background-color: #2980b9; }

.checkbox-stint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffd700;
  font-size: 0.9em;
  margin-bottom: 10px;
  background: #333;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
}

/* =========================================
   EXIBIÇÃO EM LINHA E EXPANSÃO (Tendências)
   ========================================= */
.container-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}

.card-linha {
  background-color: #1a1a1a;
  color: #fff;
  border-radius: 8px;
  border-left: 6px solid #333;
  overflow: hidden;
  transition: background-color 0.2s ease;
}

.card-linha.melhorando {
  border-left-color: #00ff88;
}

.card-linha.piorando {
  border-left-color: #ff4444;
}

summary.linha-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary.linha-cabecalho::-webkit-details-marker {
  display: none;
}

summary.linha-cabecalho:hover {
  background-color: #262626;
}

.info-piloto {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1em;
  font-weight: bold;
}

.badge-posicao {
  background: #333;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
}

.info-media {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1em;
}

.badge-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: bold;
}

.melhorando .badge-status {
  background-color: rgba(0, 255, 136, 0.15);
  color: #00ff88;
}

.piorando .badge-status {
  background-color: rgba(255, 68, 68, 0.15);
  color: #ff4444;
}

.tempo-media {
  font-weight: bold;
  font-family: monospace;
  font-size: 1.2em;
}

.melhorando .tempo-media { color: #00ff88; }
.piorando .tempo-media { color: #ff4444; }

/* DETALHES DAS 10 VOLTAS (QUANDO EXPANDIDO) */
.painel-voltas {
  background-color: #111;
  padding: 15px 18px;
  border-top: 1px solid #2a2a2a;
}

.grid-voltas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.item-volta {
  background-color: #222;
  padding: 6px 10px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 0.9em;
  font-family: monospace;
}

.item-volta .num-volta { color: #888; }
.item-volta .tempo-volta { font-weight: bold; color: #fff; }

.badge-ritmo {
  background-color: #f39c12;
  color: #1e1e1e;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ================================================== */
/* CSS EXCLUSIVO DA TELA DE TOCHA (KART MAIS RAPIDO)  */
/* ================================================== */

.tocha-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .tocha-layout { grid-template-columns: 1fr; }
}

.ranking-kart {
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: #2a2a2a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-left: 5px solid #444;
}

.ranking-kart.eh-tocha {
  border-left: 5px solid #00ff88;
  background-color: #1c2e26;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.25);
}

.ranking-kart.baixa-amostra {
  opacity: 0.55;
}

.ranking-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95em;
  color: #fff;
  flex-shrink: 0;
}

.ranking-info { flex: 1; min-width: 0; }
.ranking-numero { font-size: 1.05em; font-weight: bold; color: #fff; }
.ranking-sub { font-size: 0.8em; color: #999; margin-top: 2px; }

.ranking-metrica { text-align: right; }
.ranking-diff { font-size: 1.15em; font-weight: bold; font-family: monospace; }
.ranking-diff.rapido { color: #00ff88; }
.ranking-diff.lento { color: #ff4444; }
.ranking-diff-label { font-size: 0.75em; color: #777; }

.tab-modo {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.tab-modo button {
  flex: 1;
  background-color: #333;
  color: #ccc;
  padding: 10px;
}

.tab-modo button.ativo {
  background-color: #4caf50;
  color: #fff;
}

.fila-selecao {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
}

.fila-selecao button {
  flex: 1;
  background-color: #333;
  color: #ccc;
  padding: 10px;
}

.fila-selecao button.ativo {
  background-color: #ffd700;
  color: #000;
}

.status-registro {
  font-size: 0.85em;
  margin-top: 10px;
  min-height: 18px;
}

.status-registro.ok { color: #00ff88; }
.status-registro.erro { color: #ff4444; }

.painel-filas {
  margin-top: 20px;
}

.filas-linha {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed #333;
  font-size: 0.95em;
}

.filas-linha:last-child { border-bottom: none; }
.filas-linha span:last-child { color: #999; font-family: monospace; }

.vazio-tocha {
  color: #777;
  font-size: 0.9em;
  padding: 15px 0;
  text-align: center;
}