/* css/ui.css */

/* ── Fundo: grid sutil + vinheta ────────────────── */
body {
  margin: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .05) -50px, rgba(0, 0, 0, .05) 19px, transparent 10px, transparent 20px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) -50px, rgba(0, 0, 0, .05) 19px, transparent 10px, transparent 20px),
    radial-gradient(circle, rgba(217, 236, 255, 0) 40%, rgb(141, 141, 141) 150%);
}

canvas {
  display: block;
}

/* ── Container: posiciona e empilha os painéis ───── */
#hud-stack {
  position: fixed;
  top: 30px;
  left: 30px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0px;
}

/* ── Responsivo: mobile ──────────────────────────── */
@media (max-width: 768px) {
  #hud-stack {
    top: auto;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0;
  }

  #hudToggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 22px;
    border-radius: 50%;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
  }

  #hudClose {
    position: absolute;
    top: 8px;
    right: 8px;
    left: auto;
    margin-left: 0;
    width: 40px;
    height: 40px;
    font-size: 18px;
    z-index: 15;
    border-radius: 50%;
  }

  #hud-panels {
    background: rgba(0, 0, 0, .85);
    backdrop-filter: blur(8px);
    border-radius: 16px 16px 0 0;
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding: 16px;
    max-height: 80vh;
    overflow-y: auto;
    gap: 12px;
  }

  #hud2,
  #hud3,
  #hud4 {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 14px;
  }

  #hud2 .hud-title,
  #hud3 .hud-title,
  #hud4 .hud-title {
    font-size: 16px;
  }

  #hud2 label,
  #hud3 label,
  #hud4 label {
    font-size: 14px;
  }

  #hud2 input,
  #hud3 input,
  #hud4 input {
    padding: 10px 12px;
    font-size: 14px;
  }

  #hud2 input[type="range"],
  #hud3 input[type="range"],
  #hud4 input[type="range"] {
    height: 32px;
  }

  #hud2 button,
  #hud3 button,
  #hud4 button {
    padding: 12px 14px;
    font-size: 14px;
  }

  /* Tooltips viram popups centrais no mobile */
  .hud-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    margin-left: 0;
    transform: translate(-50%, -50%) scale(0.9);
    width: min(320px, 90vw);
    z-index: 200;
    box-shadow: 0 12px 40px rgba(0,0,0,.8);
  }

  .tooltip-trigger:hover .hud-tooltip,
  .tooltip-trigger.show-tooltip .hud-tooltip {
    transform: translate(-50%, -50%) scale(1);
  }

  /* Telemetria: barra compacta no topo */
  #telemetry {
    top: 0;
    right: 0;
    left: 0;
    border-radius: 0;
    padding: 8px 12px;
    justify-content: center;
    gap: 4px;
    border-left: none;
    border-right: none;
    border-top: none;
  }

  .tel-item {
    min-width: auto;
    flex-direction: row;
    gap: 4px;
  }

  .tel-value {
    font-size: 18px;
  }

  .tel-label {
    font-size: 10px;
    margin-top: 0;
  }

  .tel-divider {
    height: 24px;
    margin: 0 8px;
  }
}

/* Telas muito pequenas (<= 480px) */
@media (max-width: 480px) {
  #telemetry {
    padding: 6px 8px;
    gap: 2px;
  }

  .tel-value {
    font-size: 15px;
  }

  .tel-label {
    font-size: 9px;
  }

  .tel-divider {
    height: 20px;
    margin: 0 5px;
  }

  #hud-panels {
    padding: 12px;
  }

  #hud2,
  #hud3,
  #hud4 {
    padding: 10px 12px;
  }
}

/* ── Base dos painéis (compartilhado por #hud e #hud2) ── */
#hud,
#hud2,
#hud3,
#hud4 {
  position: relative;
  background: rgba(0, 0, 0, .6);
  color: #ddd;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  font: 12px system-ui, -apple-system, Segoe UI, Roboto, Arial;
  display: grid;
  gap: 6px;
  width: 190px;
  user-select: none;
}

/* ── Title/ Subtitle ──────────────────────────────────────── */
#hud .hud-title,
#hud2 .hud-title,
#hud3 .hud-title,
#hud4 .hud-title {
  font-size: 15px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  padding-bottom: 5px;
}

#hud .hud-subtitle,
#hud2 .hud-subtitle,
#hud3 .hud-subtitle,
#hud4 .hud-subtitle {
  font-size: 13px;
}



/* ── Labels ──────────────────────────────────────── */
#hud label,
#hud2 label,
#hud3 label,
#hud4 label {
  opacity: .9;
}

/* Labels de valor (RPM, Temperatura, Vibração) com destaque */
#panelSimulator label[for="rpmInput"],
#panelSimulator label[for="tempInput"],
#panelSimulator label[for="vibInput"] {
  font-size: 14px;
  font-weight: 500;
}


/* ── Inputs de texto e número ────────────────────── */
#hud input,
#hud2 input,
#hud3 input,
#hud4 input {
  width: 100%;
  box-sizing: border-box;
  background: #8b8b8b;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}

#hud input:focus,
#hud2 input:focus,
#hud3 input:focus,
#hud4 input:focus {
  border-color: rgba(255, 255, 255, .28);
}

/* ── Checkbox/radio — não vira full-width ────────── */
#hud input[type="checkbox"],
#hud input[type="radio"],
#hud2 input[type="checkbox"],
#hud2 input[type="radio"],
#hud3 input[type="checkbox"],
#hud3 input[type="radio"],
#hud4 input[type="checkbox"],
#hud4 input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

/* ── Slider ──────────────────────────────────────── */
#hud input[type="range"],
#hud2 input[type="range"],
#hud3 input[type="range"],
#hud4 input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: #ffc400;
  cursor: pointer;
}

/* Sliders de rampa (aceleração, desaceleração, aquecimento, resfriamento)
   tom verde claro para diferenciar dos sliders principais (amarelo) */
#hud4 input[type="range"].rampa-slider {
  accent-color: #aed581!important;
}

/* ── Título da seção de rampas ── */
.rampa-title {
  font-size: 11px;
  font-weight: 600;
  color: #aed581;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
  text-align: center;
}

/* ── Pares de rampa (↑ subida / ↓ descida) lado a lado ── */
.rampa-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rampa-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rampa-icon {
  font-size: 14px;
  font-weight: 700;
  color: #aed581;
  min-width: 14px;
  text-align: center;
  user-select: none;
}

.rampa-item .rampa-slider {
  flex: 1;
  min-width: 0;
}

/* ── Grupos de controles por painel ──────────────── */
#hud .hud-group,
#hud2 .hud-group,
#hud3 .hud-group,
#hud4 .hud-group {
  display: grid;
  gap: 6px;
  opacity: .45;
  transition: opacity .18s ease;
}

#hud .hud-group.is-active,
#hud2 .hud-group.is-active,
#hud3 .hud-group.is-active,
#hud4 .hud-group.is-active {
  opacity: 1;
}

/* Painéis inativos em hud4 e hud2 ficam ocultos */
#hud2 .hud-group:not(.is-active):not(#panelMode),
#hud4 .hud-group:not(.is-active) {
  display: none;
}

/* Esconde separadores entre painéis de modo inativos */
#hud2 .hud-sep:not(#sepMode) {
  display: none;
}

/* ── Separador visual ────────────────────────────── */
#hud .hud-sep,
#hud2 .hud-sep,
#hud3 .hud-sep,
#hud4 .hud-sep {
  height: 1px;
  background: rgba(255, 255, 255, .12);
  margin: 4px 0;
}

/* ── Radio labels ────────────────────────────────── */
#hud .hud-check,
#hud2 .hud-check,
#hud3 .hud-check,
#hud4 .hud-check {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 6px;
  align-items: center;
}

/* Label com input disabled — cursor not-allowed e texto opaco */
#hud .hud-check:has(input:disabled),
#hud2 .hud-check:has(input:disabled),
#hud3 .hud-check:has(input:disabled),
#hud4 .hud-check:has(input:disabled) {
  cursor: not-allowed;
}

#hud .hud-check:has(input:disabled) > span,
#hud2 .hud-check:has(input:disabled) > span,
#hud3 .hud-check:has(input:disabled) > span,
#hud4 .hud-check:has(input:disabled) > span {
  opacity: 0.5;
}

/* ── Botões ──────────────────────────────────────── */
#hud button,
#hud2 button,
#hud3 button,
#hud4 button {
  width: 100%;
  box-sizing: border-box;
  background: #333333;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

#hud button:not(:disabled):hover,
#hud2 button:not(:disabled):hover,
#hud3 button:not(:disabled):hover,
#hud4 button:not(:disabled):hover {
  background: #333333;
  color: #ffc400;
}

#hud button:not(:disabled):active,
#hud2 button:not(:disabled):active,
#hud3 button:not(:disabled):active,
#hud4 button:not(:disabled):active {
  color: #000;
  background-color: #ffc400;
}

#hud button:disabled,
#hud2 button:disabled,
#hud3 button:disabled,
#hud4 button:disabled {
  opacity: .4;
  cursor: default;
}

/* ── Texto de status ─────────────────────────────── */
#hud .hud-status,
#hud2 .hud-status,
#hud3 .hud-status,
#hud4 .hud-status {
  font-size: 11px;
  opacity: .8;
  min-height: 4.2em;
  line-height: 1.4;
}

/* ── Readout de telemetria (RPM real) ────────────── */
#hud .hud-readout,
#hud2 .hud-readout,
#hud3 .hud-readout,
#hud4 .hud-readout {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #aaa;
}

#hud .hud-readout span:last-child,
#hud2 .hud-readout span:last-child,
#hud3 .hud-readout span:last-child,
#hud4 .hud-readout span:last-child {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ── Botão de abrir painéis ──── */
#hudToggle {
  width: 35px;
  height: 35px;
  padding: 0;
  background: rgba(0, 0, 0, .5);
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

#hudToggle:hover {
  color: #ffc400;
}

#hudToggle:active {
  color: #000;
  background: #ffc400;
}

/* ── Botão de fechar painéis ──── */
#hudClose {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 8px;
  /* Espaço entre o bloco e o botão */
  width: 35px;
  height: 35px;
  padding: 0;
  background: rgba(0, 0, 0, .5);
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s, background-color .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

#hudClose:hover {
  color: #ffc400;
}

#hudClose:active {
  color: #000;
  background-color: #ffc400;
}

/* ── Painéis — wrapper que controla visibilidade ──── */
#hud-panels {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Utilitário de ocultação ─────────────────────── */
.is-hidden {
  display: none !important;
}

/* ── Remove spinners dos inputs numéricos ────────── */
#hud input[type="number"]::-webkit-inner-spin-button,
#hud input[type="number"]::-webkit-outer-spin-button,
#hud2 input[type="number"]::-webkit-inner-spin-button,
#hud2 input[type="number"]::-webkit-outer-spin-button,
#hud3 input[type="number"]::-webkit-inner-spin-button,
#hud4 input[type="number"]::-webkit-inner-spin-button,
#hud3 input[type="number"]::-webkit-outer-spin-button,
#hud4 input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#hud input[type="number"],
#hud2 input[type="number"],
#hud3 input[type="number"],
#hud4 input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}


/* ═══════════════════════════════════════════════════
   TELEMETRIA PERMANENTE — topo direito
   Sempre visível, independente do estado do HUD.
═══════════════════════════════════════════════════ */

#telemetry {
  position: fixed;
  top: 30px;
  right: 30px;
  z-index: 10;

  display: flex;
  align-items: center;
  gap: 0;

  background: rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  padding: 10px 18px;

  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  user-select: none;
}

/* Cada bloco RPM / Temp */
.tel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

/* Número grande */
.tel-value {
  font-size: 28px;
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Label pequeno abaixo */
.tel-label {
  font-size: 11px;
  color: #ffc400;
  letter-spacing: .06em;
  margin-top: 4px;
  /* text-transform: uppercase; */
}

/* Divisor vertical entre os dois blocos */
.tel-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, .12);
  margin: 0 16px;
}


/* ═══════════════════════════════════════════════════
   TOOLTIPS RICOS — Conteúdo em HTML
═══════════════════════════════════════════════════ */

.tooltip-trigger {
  cursor: help;
}

.hud-tooltip {
  position: absolute;
  top: -3px;
  left: 100%;
  margin-left: 58px;
  transform: translateX(-10px) scale(0.95);
  opacity: 0;
  pointer-events: none;

  background: rgba(0, 0, 0, .85);
  color: #ddd;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);

  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;

  /* Layout interno */
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 260px;
  cursor: default;
}

.tooltip-trigger:hover .hud-tooltip,
.tooltip-trigger.show-tooltip .hud-tooltip {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.tooltip-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffc400;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.tooltip-desc {
  font-size: 12.5px;
  line-height: 1.4;
  color: #ccc;
}

.tooltip-apps {
  font-size: 12.5px;
  line-height: 1.4;
  color: #9ab4d6;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 8px;
}

.tooltip-apps strong {
  color: #a7c8f2;
}

/* Tooltip de status "Desabilitado" — destaque laranja */
.tooltip-apps.tooltip-disabled {
  color: #fb923c;
  margin-top: 8px;
  border-top: 1px solid rgba(251, 146, 60, 0.3);
  padding-top: 8px;
}

/* ═══════════════════════════════════════════════════
   LOADING (Barra de progresso)
═══════════════════════════════════════════════════ */
#loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
   background: #020617;
  backdrop-filter: blur(4px);
  color: #aaa;
  font: 13px monospace;
}

#loadingTrack {
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
  overflow: hidden;
}

#loadingProgress {
  height: 100%;
  width: 0%;
  background: #ffc400;
  border-radius: 4px;
  transition: width 0.2s ease;
}

/* ═══════════════════════════════════════════════════
   ESTILOS AUXILIARES (Ocultação e Opacidade)
═══════════════════════════════════════════════════ */
#jsonCountdown {
  opacity: .7;
}

#rpmReadout,
#smoothingAccelLabel,
#smoothingDecelLabel,
#smoothingTempAccelLabel,
#smoothingTempDecelLabel {
  display: none;
}

/* ═══════════════════════════════════════════════════
   PAINEL OBSERVER — indicadores de conexão e valores
═══════════════════════════════════════════════════ */

.obs-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.obs-label {
  font-size: 12px;
  opacity: .8;
}

.obs-value {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.obs-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.obs-connected {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.obs-disconnected {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
}


