/* Ponto Eletronico - Vibbe Plus
   Etapa 1.5: tela de marcacao. Mobile-first: base pensada para celular, com
   media queries so para aproveitar espaco extra em telas maiores (PC de mesa).
   Sem dependencia de fonte externa via CDN. Identidade visual Vibbe Plus:
   tema escuro petroleo com acento laranja/ambar da marca. */

:root {
  --fundo: #1a1f2e;        /* petroleo, fundo de todas as telas */
  --tecla: #232a3d;        /* fundo de tecla e cards */
  --laranja: #f07822;      /* acento primario da marca */
  --ambar: #f5a623;        /* acento secundario da marca */
  --texto: #f0f1f3;        /* texto principal */
  --secundario: #8a93a6;   /* texto secundario */
  --dot-inativo: #3a4256;  /* "+" do PIN ainda nao preenchido */
  --borda-sutil: #2c3448;

  --verde: #22c55e;        /* sucesso (check do comprovante) */
  --azul: #3b82f6;
  --vermelho: #ef4444;

  --amarelo-aviso: #f5a623;
  --fundo-aviso: #33290f;
  --texto-erro: #ffb4ad;
  --fundo-erro: #3a1d1b;

  --fonte-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--fonte-base);
  background: var(--fundo);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

#app {
  min-height: 100vh;
  min-height: 100dvh; /* viewport real no mobile (desconta barras do navegador) */
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
}

.tela {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
}

/* PIN e confirmacao: bloco centralizado verticalmente (sem empurrar teclado/
   botoes para o fundo, que criava um vao grande no meio). */
#tela-pin,
#tela-confirmacao {
  justify-content: center;
}

.tela[hidden] {
  display: none;
}

.camera-oculta {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
}

/* ---------- Mensagens de estado (erro / aviso) ---------- */

.mensagem {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
}

.mensagem-erro {
  background: var(--fundo-erro);
  color: var(--texto-erro);
}

.mensagem-aviso {
  background: var(--fundo-aviso);
  color: var(--amarelo-aviso);
}

.mensagem[hidden] {
  display: none;
}

.carregando {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 1rem;
  color: var(--secundario);
}

.carregando[hidden] {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--laranja);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

/* ---------- Tela PIN ---------- */

.cabecalho-pin {
  text-align: center;
  margin-bottom: 24px;
}

.logo-vibbe {
  display: block;
  width: 190px;
  max-width: 62%;
  height: auto;
  margin: 8px auto 20px;
}

.titulo-app {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--texto);
  margin: 0 0 8px;
}

.instrucao {
  font-size: 1.1rem;
  color: var(--secundario);
  margin: 0;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 20px;
}

/* Cada dot e o simbolo "+" da marca: cinza inativo, laranja quando preenchido
   (classe dot-preenchido, aplicada pelo app.js). */
.dot {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dot::before {
  content: '+';
  font-size: 2.7rem;
  font-weight: 800;
  line-height: 0.6;
  color: var(--dot-inativo);
  transition: color 0.15s ease, transform 0.15s ease;
}

.dot.dot-preenchido::before {
  color: var(--laranja);
  transform: scale(1.05);
}

.teclado-numerico {
  margin-top: 20px;        /* espaco moderado apos os dots, sem vao gigante */
  align-self: center;      /* centraliza horizontalmente */
  width: 100%;
  max-width: 300px;        /* teto: teclas nao ficam gigantes no desktop */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.tecla {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 50%;
  border: 1px solid var(--borda-sutil);
  background: var(--tecla);
  color: var(--texto);
  font-size: 1.7rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0; /* deixa o aspect-ratio mandar, sem forcar altura extra */
  transition: background-color 0.1s ease, transform 0.1s ease;
}

/* No toque a tecla vira laranja com o numero escuro (contraste com a marca). */
.tecla:active {
  background: var(--laranja);
  color: var(--fundo);
  border-color: var(--laranja);
  transform: scale(0.96);
}

.tecla-vazia {
  visibility: hidden;
}

.tecla-apagar {
  font-size: 1.6rem;
  color: var(--secundario);
  border-color: var(--borda-sutil);
}

.tecla-apagar:active {
  background: var(--ambar);
  color: var(--fundo);
  border-color: var(--ambar);
}

/* ---------- Tela confirmacao ---------- */

.btn-voltar {
  position: absolute;      /* fora do fluxo, para nao desbalancear a centralizacao */
  top: 0;
  left: 0;
  background: none;
  border: none;
  color: var(--secundario);
  font-size: 0.95rem;
  padding: 8px 0;
  min-height: 44px;
}

.confirmacao-card {
  text-align: center;
  margin-bottom: 16px;
}

.foto-wrapper {
  width: 140px;
  height: 140px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--tecla);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--laranja);
}

.foto-perfil {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-inicial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tecla);
  color: var(--laranja);
  font-size: 3.5rem;
  font-weight: 700;
}

.nome-funcionario {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--texto);
}

.pergunta-confirmacao {
  font-size: 1.05rem;
  color: var(--secundario);
  margin: 0;
}

.botoes-tipo {
  margin-top: 24px;        /* espaco moderado apos o nome, sem vao gigante */
  align-self: center;      /* centraliza horizontalmente */
  width: 100%;
  max-width: 380px;        /* teto para nao esticar demais no desktop */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.btn-tipo {
  position: relative;
  min-height: 92px;
  border: none;
  border-radius: 18px;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.btn-tipo:active {
  transform: scale(0.97);
}

.btn-tipo:disabled {
  opacity: 0.6;
}

.btn-entrada { background: var(--verde); }
.btn-saida-almoco { background: var(--laranja); }
.btn-retorno-almoco { background: var(--azul); }
.btn-saida { background: var(--vermelho); }

.btn-tipo-destaque {
  box-shadow: 0 0 0 4px rgba(240, 120, 34, 0.55), 0 3px 8px rgba(0, 0, 0, 0.4);
}

.btn-tipo-destaque::after {
  content: 'Provavel';
  position: absolute;
  top: -10px;
  right: 8px;
  background: var(--ambar);
  color: var(--fundo);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Tela comprovante ---------- */

#tela-comprovante {
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.comprovante-card {
  text-align: center;
  padding: 24px;
}

.check-verde {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
}

.comprovante-selfie {
  display: block;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--verde);
}

.check-verde-circulo {
  stroke: var(--verde);
  stroke-width: 3;
}

.check-verde-marca {
  stroke: var(--verde);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comprovante-tipo {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--texto);
  margin: 0 0 8px;
}

.comprovante-horario {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--verde);
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}

.comprovante-nome {
  font-size: 1.2rem;
  color: var(--texto);
  margin: 0 0 20px;
}

.comprovante-dica {
  font-size: 0.9rem;
  color: var(--secundario);
  margin: 0;
}

/* ---------- Ajustes para telas maiores (PC de mesa) ---------- */

@media (min-width: 560px) {
  #app {
    padding: 40px 24px 48px;
  }

  .logo-vibbe {
    width: 230px;
  }

  .titulo-app {
    font-size: 1.6rem;
  }

  .tecla {
    font-size: 2.1rem;
    min-height: 76px;
  }

  .foto-wrapper {
    width: 170px;
    height: 170px;
  }

  .nome-funcionario {
    font-size: 1.9rem;
  }

  .btn-tipo {
    min-height: 130px;
    font-size: 1.35rem;
  }

  .comprovante-horario {
    font-size: 3.2rem;
  }
}

@media (min-width: 900px) {
  #app {
    max-width: 560px;
  }
}
