/* QR Accreditation Scanner — tema escuro minimalista */

:root {
  --bg: #0b0f14;
  --panel: #121821;
  --line: #232d3a;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #ffdd00;
  --success: #2dd4a7;
  --danger: #ff5c6c;
  --warn: #ffb454;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Câmara (topo) ---------- */
#camera-area {
  position: relative;
  flex: 0 0 55%;
  background: #000;
  overflow: hidden;
  border-radius: 6px;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mira de leitura - dimensões controladas via JavaScript */
#scan-frame {
  position: absolute;
  pointer-events: none;
  transition: all 0.3s ease;
  /* Valores padrão quando a câmara não está ativa */
  width: 250px;
  height: 250px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
#scan-frame .c {
  position: absolute;
  width: 34px; height: 34px;
  border: 4px solid rgba(255,255,255,.9);
}
#scan-frame .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
#scan-frame .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
#scan-frame .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
#scan-frame .br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
#scan-frame .beam {
  position: absolute;
  left: 8%; right: 8%;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .85;
  animation: beam 4s ease-in-out infinite;
}
@keyframes beam {
  0%, 100% { transform: translateY(calc(100% / 6)); }
  50% { transform: translateY(calc(100% / 1.2)); }
}

/* Feedback verde/vermelho */
#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
  border: 0 solid transparent;
  border-radius: 6px;
}
#flash.ok    { opacity: 1; box-shadow: inset 0 0 0 8px var(--success), inset 0 0 90px rgba(45,212,167,.35); }
#flash.err   { opacity: 1; box-shadow: inset 0 0 0 8px var(--danger), inset 0 0 90px rgba(255,92,108,.35); }
#flash.warn  { opacity: 1; box-shadow: inset 0 0 0 8px var(--warn), inset 0 0 90px rgba(255,180,84,.35); }
#flash.busy  { opacity: 1; box-shadow: inset 0 0 0 6px rgba(255,255,255,.55); }

/* Botão definições */
#btn-settings {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 12px;
  z-index: 5;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(10,14,20,.65);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: opacity .4s ease, transform .15s ease;
}
#btn-settings:active { transform: scale(.92); }
#btn-settings.hidden-gear { opacity: 0; pointer-events: none; }

/* ---------- Conteúdo (fundo) ---------- */
/* Garante que o atributo hidden ganha sempre a regras de display mais específicas */
[hidden] { display: none !important; }

#content-area {
  position: relative;
  flex: 1 1 auto;
  background: var(--bg);
  overflow-y: auto;
  padding: 10px 0px 10px;
}

/* Botão de fechar o resultado (X) no canto superior direito */
#btn-close-response {
  position: absolute;
  top: 15px;
  right: 12px;
  margin-left: auto;
  z-index: 10;
  width: 30px; height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(10,14,20,.65);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .15s ease;
}
#btn-close-response:active { transform: scale(.92); }

#content-default {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text);
  gap: 14px;
}
#content-default p { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
#content-default p span { font-size: .85rem; font-weight: 400; color: var(--muted); }
#content-default .event-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
}
#content-default .config-hint {
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted);
  opacity: .75;
  max-width: 260px;
}
#content-default .config-hint {
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted);
  opacity: .75;
  max-width: 260px;
}

.pulse-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .35; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.api-hint {
  margin-top: 10px;
  font-size: .8rem;
  color: var(--muted);
}
.api-hint code {
  font-size: .78rem;
  color: var(--text);
}

/* ---------- Modal de definições ---------- */
#settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
}
#settings-backdrop.is-open { display: flex; }
#settings-modal {
  width: 100%;
  max-width: 420px;
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}
.settings-head h2 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1;
  text-align: right;
}
.settings-version {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
#settings-modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .82rem;
  color: var(--muted);
}
#settings-modal input:not([type=checkbox]) {
  width: 100%;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
#settings-modal select {
  appearance: none; /* Disable the default arrow */
  -webkit-appearance: none; /* For WebKit-based browsers */
  -moz-appearance: none; /* For Firefox */
  width: 100%;
  padding: 11px 24px 11px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 1rem;
  background-color: var(--bg);
  background-image: url('data:image/svg+xml;utf8,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 9L12 15L18 9" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor" style="stroke: rgba(255, 255, 255, 0.8);"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  cursor: pointer;
}
#settings-modal input:focus, #settings-modal select:focus { outline: 1px solid var(--accent); }
#settings-modal .grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#settings-modal label.check {
  flex-direction: row;
  align-items: center;
  justify-content: left;
  font-size: .95rem;
  color: var(--text);
}
#settings-modal input[type=checkbox] {
  width: 22px; height: 22px;
  accent-color: var(--accent);
}
#settings-modal .actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
#settings-modal button {
  flex: 1;
  padding: 13px;
  border-radius: 3px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
#settings-modal .config-info {
  display: block;
  font-size: .7rem;
}
#settings-modal .config-info span {
  color: var(--muted);
}
#settings-modal .config-info code {
  color: #ffffff;
  word-break: nowrap;
}
.token-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.token-row input { flex: 1; min-width: 0; }
#btn-load-config {
  flex: none !important;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line) !important;
  border-radius: 6px;
  cursor: pointer;
}
#btn-load-config:disabled { opacity: .6; cursor: default; }
#settings-modal .config-status {
  font-size: .78rem;
  text-align: center;
  color: var(--muted);
}
#settings-modal .config-status.ok { color: var(--success); }
#settings-modal .config-status.err { color: var(--danger); }
#btn-save { background: var(--accent); color: #06281f; }
#btn-cancel.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* ---------- Bloqueio de orientação landscape ---------- */
#orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 20px;
}
#orientation-warning.is-visible {
  display: flex;
}
#orientation-warning .warning-icon {
  font-size: 4rem;
  animation: rotate-device 2s ease-in-out infinite;
}
@keyframes rotate-device {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-90deg); }
  75% { transform: rotate(90deg); }
}
#orientation-warning h2 {
  font-size: 1.5rem;
  color: var(--text);
  margin: 0;
}
#orientation-warning p {
  font-size: 1rem;
  color: var(--muted);
  max-width: 300px;
  line-height: 1.5;
}

@media (orientation: landscape) and (max-height: 600px) {
  #app {
    display: none !important;
  }
  #orientation-warning {
    display: flex !important;
  }
}


/*
* Estilos dos cartões de resposta embutido nas respostas da API, copiado aqui para os erros gerados localmente
*/
.accred {
  --acc-panel: var(--panel, #121821);
  --acc-line: var(--line, #232d3a);
  --acc-text: var(--text, #e8edf3);
  --acc-muted: var(--muted, #8b98a8);
  --acc-success: var(--success, #2dd4a7);
  --acc-danger: var(--danger, #ff5c6c);
  --acc-warn: var(--warn, #ffb454);

  border-radius: 6px;
  padding: 18px;
  background: var(--acc-panel);
  border: 1px solid var(--acc-line);
  color: var(--acc-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: accred-in .25s ease;
  margin: 20px;
}
@keyframes accred-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.accred--ok   { border-color: var(--acc-success); }
.accred--err  { border-color: var(--acc-danger); }
.accred--warn { border-color: var(--acc-warn); }

.accred__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.accred__avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--acc-success);
  color: #06281f;
  font-size: 1.5rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.accred--err .accred__avatar, .accred--warn .accred__avatar { background: var(--acc-warn); }
.accred__name { font-size: 2rem; font-weight: 700; margin-right: 20px; }
.accred__meta { font-size: 1.2rem; color: var(--acc-muted); margin-top: 2px; }

.accred__title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.accred--ok .accred__title   { color: var(--acc-success); }
.accred--err .accred__title  { color: var(--acc-danger); }
.accred--warn .accred__title { color: var(--acc-warn); }
.accred__detail { font-size: .9rem; color: var(--acc-muted); }

/* ---------- Overlay de scan region (QrScanner) ---------- */
/* Quando highlightScanRegion está desativado, usamos overlay personalizado apenas para code outline */
.scan-region-highlight {
  /* Não aplicar estilos quando highlightScanRegion está false */
}

.code-outline-highlight {
  animation: code-pulse 1.5s ease-in-out infinite;
}

/* Estilização do SVG do contorno do QR code */
.code-outline-highlight {
  /* Aplicar filtro no container HTML */
  -webkit-filter: drop-shadow(0 0 2px #000);
  filter: drop-shadow(0 0 2px #000);
  animation: code-pulse 1.5s ease-in-out infinite;
}

.code-outline-highlight svg {
  /* Garantir que o SVG herda os filtros e tem dimensões corretas */
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.code-outline-highlight polygon {
  stroke: #ffdd00 !important;        /* Cor amarela do contorno */
  stroke-width: 8px !important;       /* Espessura da linha */
  stroke-dasharray: 20,20 !important;    /* Padrão tracejado (comprimento dos traços) */
  stroke-linecap: round !important;   /* Extremidades arredondadas */
  stroke-linejoin: round !important;  /* Cantos arredondados */
  fill: none !important;              /* Sem preenchimento */
}

@keyframes code-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

