﻿/* =========================================================
   URNA ELETRÔNICA — vista de frente (referência UE real)
   + TÉRMICA estilo Epson
   ========================================================= */

:root {
  --plastico: #c5c8cc;
  --plastico-escuro: #aeb2b7;
  --teclado-bg: #3a3d42;
  --lcd: #d8dce6;
  --ink: #111;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #e8eaed;
}

.cena {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2.75rem;
  width: max-content;
  max-width: 100%;
}

.urna-fit {
  /* no desktop: só envolve */
  display: block;
}

/* ========== URNA ========== */
.urna {
  --urna-w: 820px;
  width: var(--urna-w);
  background: linear-gradient(180deg, #d2d5d9 0%, var(--plastico) 40%, var(--plastico-escuro) 100%);
  border-radius: 10px 10px 6px 6px;
  border: 1px solid #9aa0a6;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.28),
    0 2px 0 #8a9096,
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  position: relative;
  z-index: 2;
}

.urna-corpo {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.85rem;
  padding: 1rem 1rem 0.75rem;
}

.urna-base-rilhos {
  height: 14px;
  margin: 0 6px 6px;
  border-radius: 0 0 4px 4px;
  background:
    repeating-linear-gradient(
      90deg,
      #9aa0a6 0 6px,
      #b4b8bc 6px 10px
    );
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.15);
}

/* LCD */
.urna-tela {
  min-width: 0;
}

.lcd {
  background: var(--lcd);
  border: 3px solid #5a5e64;
  min-height: 380px;
  box-shadow:
    inset 0 0 0 1px #fff,
    inset 0 0 18px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

.tela-voto,
.tela-fim,
.tela-branco-preview {
  min-height: 380px;
  display: flex;
  flex-direction: column;
}

.lcd-topo {
  padding: 0.75rem 0.85rem 0.25rem;
}

.seu-voto {
  font-size: 0.8rem;
  font-weight: 700;
}

.cargo {
  font-size: 1.55rem;
  font-weight: 900;
  margin-top: 0.1rem;
  letter-spacing: 0.02em;
}

.lcd-meio {
  flex: 1;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
}

.linha-numero {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.rotulo { font-size: 0.9rem; }

.digitos { display: flex; gap: 0.2rem; }

.digito {
  width: 36px;
  height: 44px;
  border: 2px solid #222;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  font-weight: 800;
  font-family: "Courier New", monospace;
}

.dados-candidato .linha {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.valor {
  font-weight: 800;
  text-transform: uppercase;
}

.vice-bloco {
  margin-top: 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.vice-titulo { font-size: 0.8rem; font-weight: 700; }

.msg-especial {
  margin-top: 1rem;
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
}

.lcd-fotos {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.foto-principal,
.foto-vice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.foto-principal img {
  width: 115px;
  height: 145px;
  object-fit: cover;
  object-position: top;
  border: 2px solid #222;
  background: #bbb;
}

.foto-vice img {
  width: 72px;
  height: 92px;
  object-fit: cover;
  object-position: top;
  border: 2px solid #222;
  background: #bbb;
}

.foto-principal span,
.foto-vice span {
  font-size: 0.65rem;
  font-weight: 700;
}

.lcd-rodape {
  border-top: 2px solid #222;
  padding: 0.4rem 0.85rem 0.55rem;
  background: rgba(255, 255, 255, 0.35);
  font-size: 0.78rem;
  line-height: 1.35;
}

.tecla-verde { color: #0a6b24; font-weight: 900; }
.tecla-laranja { color: #b04a00; font-weight: 900; }

.tela-fim {
  align-items: center;
  justify-content: center;
  background: #e4e8f0;
}

.fim-texto {
  font-size: clamp(4.5rem, 15vw, 7rem);
  font-weight: 900;
  letter-spacing: 0.06em;
}

.fim-sub {
  margin-top: 0.35rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.tela-branco-preview { justify-content: space-between; }

.branco-msg {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
}

/* Teclado — painel escuro + JE no topo */
.urna-teclado {
  display: flex;
  flex-direction: column;
  background: transparent;
}

.teclado-cabecalho {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.4rem 0.5rem;
  color: #111;
}

.teclado-cabecalho strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.teclado-placa {
  flex: 1;
  background: linear-gradient(180deg, #4a4e54 0%, #2f3237 100%);
  border-radius: 4px;
  padding: 0.7rem 0.65rem 0.75rem;
  border: 2px solid #1e2125;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 3px 6px rgba(0, 0, 0, 0.25);
}

.teclado-numeros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.vazio { visibility: hidden; }

.btn-num,
.btn-acao {
  border: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  transition: transform 0.07s ease, box-shadow 0.07s ease;
}

.btn-num {
  height: 50px;
  border-radius: 4px;
  background: linear-gradient(180deg, #3a3d42 0%, #1c1e22 100%);
  color: #fff;
  box-shadow:
    0 4px 0 #08090a,
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding-top: 2px;
}

.btn-num .n {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.btn-num .braille,
.btn-acao .braille {
  font-size: 0.55rem;
  opacity: 0.55;
  line-height: 1;
  margin-top: 1px;
}

.btn-num:active,
.btn-num.pressionado {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #08090a, inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Ações em LINHA: BRANCO | CORRIGE | CONFIRMA */
.teclado-acoes {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 0.4rem;
  align-items: end;
}

.btn-acao {
  border-radius: 4px;
  font-weight: 900;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.35rem 0.2rem;
}

.btn-acao .txt {
  font-size: 0.68rem;
  line-height: 1.1;
}

.btn-branco {
  color: #111;
  background: linear-gradient(180deg, #fff, #dcdcdc);
  box-shadow: 0 4px 0 #888, inset 0 1px 0 #fff;
}

.btn-corrige {
  color: #111;
  background: linear-gradient(180deg, #ff9a3c, #e35f00);
  box-shadow: 0 4px 0 #8a3a00, inset 0 1px 0 rgba(255, 220, 180, 0.5);
}

.btn-confirma {
  color: #111;
  min-height: 58px;
  background: linear-gradient(180deg, #4adf6e, #1aa83e);
  box-shadow: 0 5px 0 #0a5a20, inset 0 1px 0 rgba(220, 255, 220, 0.5);
}

.btn-branco:active,
.btn-branco.pressionado,
.btn-corrige:active,
.btn-corrige.pressionado {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #666, inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.btn-confirma:active,
.btn-confirma.pressionado {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #0a5a20, inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* ========== TÉRMICA EPSON ========== */
.termica {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.35));
}

.termica-papel-area {
  width: 100%;
  height: 280px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.comprovante-wrap {
  width: 82%;
  transform: translateY(110%) rotateX(8deg);
  transform-origin: bottom center;
  transition: transform 2.9s cubic-bezier(0.18, 0.7, 0.2, 1);
  will-change: transform;
}

.termica.imprimindo .comprovante-wrap,
.termica.impresso .comprovante-wrap {
  transform: translateY(0) rotateX(6deg);
}

.comprovante {
  background: repeating-linear-gradient(
    0deg,
    #faf8f0 0 12px,
    #f2efe6 12px 13px
  );
  padding: 0.55rem 0.45rem 0.65rem;
  font-size: 0.62rem;
  line-height: 1.25;
  box-shadow:
    0 -6px 16px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  border-radius: 2px 2px 0 0;
  /* curva leve no topo do papel */
  clip-path: polygon(2% 0, 98% 0, 100% 100%, 0 100%);
}

.comp-cabecalho { text-align: center; margin-bottom: 0.25rem; }
.comp-cabecalho strong { display: block; font-size: 0.68rem; }
.comp-cabecalho span { font-size: 0.52rem; color: #444; }

.comp-linha {
  height: 1px;
  margin: 0.3rem 0;
  background: repeating-linear-gradient(90deg, #333 0 3px, transparent 3px 6px);
}

.comp-campo {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  margin-bottom: 0.15rem;
}

.comp-campo span {
  font-size: 0.52rem;
  text-transform: uppercase;
  color: #555;
}

.comp-campo strong {
  font-size: 0.62rem;
  text-align: right;
  max-width: 58%;
  word-break: break-word;
}

.comp-rodape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.52rem;
  font-weight: 800;
}

.comp-barcode {
  margin-top: 0.35rem;
  height: 24px;
  background: repeating-linear-gradient(
    90deg,
    #111 0 2px,
    transparent 2px 3px,
    #111 3px 5px,
    transparent 5px 7px
  );
}

.termica-corpo {
  width: 100%;
  position: relative;
  z-index: 3;
}

.termica-fenda {
  height: 10px;
  background: #0a0a0a;
  border-radius: 4px 4px 0 0;
  border: 2px solid #111;
  border-bottom: none;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.9);
  position: relative;
}

.termica-fenda::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 3px;
  height: 2px;
  background: #222;
  box-shadow: 0 1px 0 #444;
}

.termica-tampa {
  background: linear-gradient(180deg, #2a2a2a 0%, #141414 55%, #0c0c0c 100%);
  border: 2px solid #050505;
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 0.85rem 0.75rem 1rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 0 #050505;
}

.termica-logo {
  display: block;
  color: #c8c8c8;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  margin-bottom: 1.1rem;
  font-family: Arial, sans-serif;
}

.termica-frente {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.termica-leds {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a2a2a;
  border: 1px solid #111;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.led-on {
  background: #3aa0ff;
  box-shadow: 0 0 8px #3aa0ff;
}

.termica.imprimindo .led-on {
  background: #ffc107;
  box-shadow: 0 0 10px #ffc107;
  animation: blink 0.3s infinite alternate;
}

@keyframes blink {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

.termica-icones {
  display: flex;
  gap: 0.55rem;
  font-size: 0.55rem;
  color: #666;
  margin-bottom: 0.45rem;
}

.termica-botoes {
  display: flex;
  gap: 0.4rem;
  align-self: flex-end;
  margin-top: -1.4rem;
}

.tb {
  width: 22px;
  height: 18px;
  border-radius: 3px;
  background: linear-gradient(180deg, #333, #1a1a1a);
  border: 1px solid #0a0a0a;
  box-shadow: 0 2px 0 #000, inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.imp-status {
  margin-top: 0.7rem;
  font-size: 0.7rem;
  color: #666;
  text-align: center;
  min-height: 1.1em;
}

.termica.imprimindo .imp-status { color: #b8860b; }
.termica.impresso .imp-status { color: #1a7a3a; }

.mobile-overlay {
  display: none;
}

[hidden] { display: none !important; }

/* ========== CELULAR (classe .modo-celular via JS) ==========
   Cobre iPhone Pro Max deitado (~932×430), que passa de 900px de largura.
   ========================================================= */
body.modo-celular {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  min-height: 100dvh;
  overflow: hidden;
  background: #e8eaed;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body.modo-celular html,
html:has(body.modo-celular) {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

body.modo-celular .cena {
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  padding: 0;
}

body.modo-celular .urna-fit {
  width: 100vw;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  position: relative;
}

body.modo-celular .urna {
  width: 820px;
  flex-shrink: 0;
}

/* Térmica some no celular até votar */
body.modo-celular .termica {
  display: none;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: min(220px, 46vw);
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

body.modo-celular .termica.mobile-ativa {
  display: flex;
  animation: termicaEntra 0.35s ease;
}

@keyframes termicaEntra {
  from {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

body.modo-celular .mobile-overlay.ativo {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}

body.modo-celular .termica-papel-area {
  height: 220px;
}

body.modo-celular .imp-status {
  color: #eee;
}

/* fallback se JS atrasar: altura baixa = celular deitado */
@media (max-height: 520px) {
  body:not(.modo-celular) .termica {
    display: none;
  }
}
