:root {
  --faixa-1: #222224;
  --faixa-2: #1b1b1d;
  --faixa-3: #151517;
  --faixa-4: #0e0e10;
  --barra: #0f0f10;
  --painel: #18181a;
  --texto: #ffffff;
  --texto-2: rgba(255, 255, 255, 0.72);
  --texto-3: rgba(255, 255, 255, 0.45);
  --ouro: #f5b800;
  --ouro-claro: #ffd84d;
  --ouro-escuro: #c98a00;
  --whats: #25d366;
  --vivo: #ff3b3b;
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100%;
  background: var(--faixa-4);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--faixa-2);
  background: linear-gradient(to bottom,
    var(--faixa-1) 0, var(--faixa-1) 38%,
    var(--faixa-2) 38%, var(--faixa-2) 56%,
    var(--faixa-3) 56%, var(--faixa-3) 72%,
    var(--faixa-4) 72%, var(--faixa-4) 100%);
}

/* Barra do topo */
.topo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 12px 0 4px;
  padding-top: env(safe-area-inset-top);
  background: var(--barra);
  border-bottom: 1px solid rgba(245, 184, 0, 0.35);
}
.topo-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--texto);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topo-btn:hover { background: rgba(255, 255, 255, 0.08); }
.topo-btn:focus { outline: none; }
.topo-btn:focus-visible { outline: 2px solid var(--ouro); outline-offset: -4px; }
.topo-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.topo-titulo {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ao-vivo {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--texto-3);
}
.ponto { width: 7px; height: 7px; border-radius: 50%; background: var(--texto-3); }
body[data-estado="tocando"] .ao-vivo { color: var(--texto); }
body[data-estado="tocando"] .ponto { background: var(--vivo); animation: piscar 1.4s ease-in-out infinite; }

/* Palco: logo no centro */
.palco {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 8px;
  text-align: center;
}
.logo-wrap {
  position: relative;
  width: 240px;
  width: min(64vw, 38vh, 300px);
}
.logo {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
}
.logo-wrap::before {
  content: "";
  position: absolute;
  top: 4%; right: 4%; bottom: 4%; left: 4%;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ouro);
  opacity: 0;
}
body[data-estado="tocando"] .logo-wrap::before { animation: halo 2.4s ease-out infinite; }

/* Equalizador decorativo */
.eq {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 34px;
  margin-top: 28px;
}
.eq span {
  display: block;
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(to top, var(--ouro-escuro), var(--ouro-claro));
  transform: scaleY(0.12);
  transform-origin: bottom;
  transition: transform 0.3s ease;
}
body[data-estado="tocando"] .eq span { animation: eq 0.9s ease-in-out infinite alternate; }
body[data-estado="tocando"] .eq span:nth-child(2) { animation-duration: 0.7s; animation-delay: -0.2s; }
body[data-estado="tocando"] .eq span:nth-child(3) { animation-duration: 1.1s; animation-delay: -0.5s; }
body[data-estado="tocando"] .eq span:nth-child(4) { animation-duration: 0.8s; animation-delay: -0.1s; }
body[data-estado="tocando"] .eq span:nth-child(5) { animation-duration: 1s; animation-delay: -0.6s; }
body[data-estado="tocando"] .eq span:nth-child(6) { animation-duration: 0.75s; animation-delay: -0.3s; }
body[data-estado="tocando"] .eq span:nth-child(7) { animation-duration: 0.95s; animation-delay: -0.4s; }

.status {
  min-height: 1.5em;
  margin-top: 14px;
  max-width: 320px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto-2);
}
/* Navegador bloqueou o som automático: o play pulsa chamando o toque */
body[data-estado="bloqueado"] .play { animation: chamar 1.8s ease-in-out infinite; }

body[data-estado="bloqueado"] .status,
body[data-estado="erro"] .status,
body[data-estado="formato"] .status,
body[data-estado="offline"] .status { color: var(--ouro-claro); }

/* Controles de baixo */
.controles {
  padding: 8px 16px 28px;
  padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
}

.volume {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 22px;
}
.volume[hidden] { display: none; }
.mute {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--texto);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mute:focus { outline: none; }
.mute:focus-visible { outline: 2px solid var(--ouro); outline-offset: 2px; }
.mute svg { width: 22px; height: 22px; }
.mute .cheio { fill: currentColor; }
.mute .linha { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mute[aria-pressed="true"] .ic-som,
.mute[aria-pressed="false"] .ic-mudo { display: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 28px;
  background: transparent;
  cursor: pointer;
  accent-color: var(--ouro);
}
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.22); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  border: 0;
  background: var(--ouro);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(245, 184, 0, 0.45); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.22); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ouro); }
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: var(--ouro);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.botoes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
}

.redondo {
  flex: none;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease;
}
.redondo:active { transform: scale(0.93); }
.redondo:focus { outline: none; }
.redondo:focus-visible { outline: 2px solid var(--ouro-claro); outline-offset: 3px; }
.redondo svg { width: 28px; height: 28px; }
.redondo[hidden] { display: none; }

/* Quando o WhatsApp não está configurado, a vaga segura o play no centro */
.vaga { flex: none; width: 52px; height: 52px; display: none; }
.whats[hidden] + .vaga { display: block; }

.whats { background: var(--whats); }
.whats .bolha { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linejoin: round; }
.whats .fone { fill: #fff; }

.compartilhar { background: #2a2a2d; border: 1px solid rgba(245, 184, 0, 0.45); }
.compartilhar svg { width: 24px; height: 24px; }
.compartilhar circle { fill: var(--ouro); }
.compartilhar .linha { fill: none; stroke: var(--ouro); stroke-width: 1.8; }

.play {
  position: relative;
  flex: none;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  background: var(--ouro);
  background: linear-gradient(145deg, var(--ouro-claro), var(--ouro) 55%, var(--ouro-escuro));
  color: #111;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(245, 184, 0, 0.32), 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}
.play:active { transform: scale(0.95); }
.play:focus { outline: none; }
.play:focus-visible { outline: 3px solid var(--ouro-claro); outline-offset: 5px; }
.play svg { width: 34px; height: 34px; fill: currentColor; }
.play .ic-play { margin-left: 3px; }
.play[aria-pressed="true"] .ic-play,
.play[aria-pressed="false"] .ic-pause { display: none; }

body[data-estado="conectando"] .play::after,
body[data-estado="reconectando"] .play::after {
  content: "";
  position: absolute;
  top: -8px; right: -8px; bottom: -8px; left: -8px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--ouro-claro);
  border-right-color: var(--ouro-claro);
  animation: girar 0.9s linear infinite;
}

/* Menu lateral */
.fundo-menu {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.menu {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 11;
  width: 300px;
  max-width: 82vw;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top);
  background: var(--painel);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
body.menu-aberto .fundo-menu { opacity: 1; visibility: visible; transition: opacity 0.25s ease; }
body.menu-aberto .menu { transform: none; visibility: visible; transition: transform 0.25s ease; }

.menu-topo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.menu-topo img { border-radius: 12px; }
.menu-topo strong { font-size: 18px; }

.menu-item {
  display: block;
  margin: 4px 8px;
  padding: 12px 12px;
  border-radius: 8px;
  color: var(--texto);
  text-decoration: none;
  font-size: 16px;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.menu-item:focus { outline: none; }
.menu-item:focus-visible { outline: 2px solid var(--ouro); outline-offset: -2px; }
.menu-item.ativo { background: rgba(245, 184, 0, 0.14); color: var(--ouro-claro); }
.menu-item[hidden], .menu-grupo[hidden] { display: none; }
.menu hr { margin: 8px 0; border: 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.menu-secao { padding: 8px 20px 4px; font-size: 14px; color: var(--texto-3); }

.menu-instalar {
  display: block;
  width: calc(100% - 32px);
  margin: 20px 16px;
  padding: 12px;
  border: 1px solid var(--ouro);
  border-radius: 999px;
  background: transparent;
  color: var(--ouro-claro);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.menu-instalar:hover { background: rgba(245, 184, 0, 0.1); }
.menu-instalar[hidden] { display: none; }

/* "Instalar aplicativo no dispositivo": link discreto, igual ao login do ERP */
.instalar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 18px auto 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--texto-3);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.instalar-link:hover { color: var(--texto-2); }
.instalar-link:focus { outline: none; }
.instalar-link:focus-visible { outline: 2px solid var(--ouro); color: var(--texto-2); }
.instalar-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.instalar-link[hidden] { display: none; }

/* Passo a passo de instalação (iPhone e Android sem o pedido automático) */
.guia {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.6);
}
.guia[hidden] { display: none; }
.guia-caixa {
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 20px 20px;
  border-radius: 18px;
  background: var(--painel);
  border: 1px solid rgba(245, 184, 0, 0.3);
  text-align: center;
}
.guia-caixa img { border-radius: 12px; }
.guia-caixa h2 { margin: 12px 0 16px; font-size: 20px; }
.guia-passos {
  margin: 0 0 0 22px;
  text-align: left;
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto-2);
}
.guia-passos li { margin-bottom: 12px; padding-left: 4px; }
.guia-passos b { color: var(--texto); }
.guia-ic {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin: 0 2px;
  vertical-align: -5px;
  fill: none;
  stroke: var(--ouro);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.guia-ic circle { fill: var(--ouro); stroke: none; }
.guia-nota { margin-top: 4px; font-size: 13px; color: var(--texto-3); }
.guia-nota b { color: var(--texto-2); }
.guia [data-guia] { display: none; }
.guia[data-modo="ios"] [data-guia="ios"],
.guia[data-modo="android"] [data-guia="android"] { display: block; }
.guia-ok {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  border: 0;
  border-radius: 999px;
  background: var(--ouro);
  color: #111;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.guia-ok:focus { outline: none; }
.guia-ok:focus-visible { outline: 2px solid var(--ouro-claro); outline-offset: 3px; }

@media (min-width: 600px) {
  .guia { align-items: center; }
}

/* Diagnóstico (5 toques no "AO VIVO") */
.diag {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 19;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.85);
}
.diag[hidden] { display: none; }
.diag-caixa {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  border-radius: 12px;
  background: var(--painel);
  border: 1px solid rgba(245, 184, 0, 0.3);
  overflow: hidden;
}
.diag-topo { padding: 12px 14px; font-size: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.diag-topo span { color: var(--ouro-claro); margin-left: 6px; }
.diag-texto {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px 14px;
  overflow: auto;
  font-family: ui-monospace, Consolas, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--texto-2);
}
.diag-botoes { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.diag-botoes button {
  flex: 1;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: transparent;
  color: var(--texto);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* Aviso rápido ("Link copiado") */
.aviso {
  position: fixed;
  left: 50%;
  bottom: 140px;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.aviso.visivel { opacity: 1; transform: translate(-50%, 0); }

.noscript {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 16px;
  background: #000;
  text-align: center;
  font-size: 14px;
}
.noscript audio { width: 100%; max-width: 360px; margin-top: 10px; }

/* Tela baixa (celular deitado) */
@media (max-height: 560px) {
  .palco { padding-top: 12px; }
  .logo-wrap { width: min(30vh, 200px); }
  .eq { height: 24px; margin-top: 12px; }
  .status { margin-top: 8px; }
  .controles { padding-bottom: 12px; }
  .volume { margin-bottom: 10px; }
}

/* Celular deitado: logo à esquerda, controles à direita (em coluna não cabe na altura) */
@media (orientation: landscape) and (max-height: 500px) {
  .app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
  }
  .topo { grid-column: 1 / -1; }
  .palco { grid-column: 1; grid-row: 2; padding: 8px 16px; }
  .controles { grid-column: 2; grid-row: 2; align-self: center; padding: 8px 16px; }
  .instalar-link { margin-top: 10px; }
  .logo-wrap { width: min(34vh, 180px); }
  .eq { height: 20px; margin-top: 10px; }
}

@keyframes eq { 0% { transform: scaleY(0.2); } 100% { transform: scaleY(1); } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes chamar {
  0%, 100% { box-shadow: 0 10px 26px rgba(245, 184, 0, 0.32), 0 0 0 0 rgba(245, 184, 0, 0.55); }
  50% { box-shadow: 0 10px 26px rgba(245, 184, 0, 0.32), 0 0 0 16px rgba(245, 184, 0, 0); }
}
@keyframes piscar { 50% { opacity: 0.35; } }
@keyframes halo {
  0% { opacity: 0.7; transform: scale(0.96); }
  100% { opacity: 0; transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-estado="tocando"] .eq span { animation: none; transform: scaleY(0.6); }
  body[data-estado="tocando"] .logo-wrap::before,
  body[data-estado="tocando"] .ponto,
  body[data-estado="bloqueado"] .play { animation: none; }
  .menu, .fundo-menu { transition: none; }
}
