/* ══════════════════════════════════════════════════════════════
   BIOMETRIA DIGITAL — Modal genérico de espera (Entrega EPI + Treinamentos)
   z-index 9950: acima do modal principal (9810) e seletor (9901),
   abaixo da câmera facial (9998/9999).
   ══════════════════════════════════════════════════════════════ */
.bio-wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 9950;
  background:
    radial-gradient(circle at center, rgba(37,99,235,.09), transparent 40%),
    rgba(15,23,42,.56);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bio-wait-modal {
  background: #ffffff;
  border-radius: 26px;
  padding: 32px 28px 24px;
  width: min(400px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  box-shadow:
    0 34px 90px rgba(15,23,42,.28),
    inset 0 1px 0 rgba(255,255,255,.8);
  border: 1px solid rgba(226,232,240,.98);
  text-align: center;
  animation: bioModalIn .22s ease-out;
}

@keyframes bioModalIn {
  from { opacity: 0; transform: scale(.93) translateY(10px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Área central do ícone ── */
.bio-fingerprint-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

/* Pulse rings — animação de expansão */
.bio-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #3b82f6;
  opacity: 0;
  animation: bioPulse 2.4s ease-out infinite;
}
.bio-pulse:nth-child(2) { animation-delay: .8s; }
.bio-pulse:nth-child(3) { animation-delay: 1.6s; }

@keyframes bioPulse {
  0%   { opacity: .65; transform: scale(.85); }
  100% { opacity: 0;   transform: scale(1.6); }
}

/* Anel de carregamento giratório */
.bio-ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 3.5px solid #dbeafe;
  border-top-color: #2563eb;
  animation: bioSpin .85s linear infinite;
  transition: border-color .4s ease;
}

@keyframes bioSpin {
  to { transform: rotate(360deg); }
}

/* Ícone/imagem central */
.bio-fingerprint {
  position: relative;
  z-index: 1;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 2.5px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .4s ease, border-color .4s ease;
}

.bio-fingerprint img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  opacity: .88;
  transition: opacity .3s ease;
}

/* ── Estados: sucesso ── */
.bio-wait-modal.is-success .bio-fingerprint {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac;
}
.bio-wait-modal.is-success .bio-ring {
  border-color: #dcfce7;
  border-top-color: #16a34a;
  animation-duration: .45s;
}
.bio-wait-modal.is-success .bio-pulse {
  border-color: #22c55e;
  animation-duration: 1.4s;
}

/* ── Estados: erro ── */
.bio-wait-modal.is-error .bio-fingerprint {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  border-color: #fca5a5;
}
.bio-wait-modal.is-error .bio-ring {
  border-color: #ffe4e6;
  border-top-color: #dc2626;
  animation: none;
}
.bio-wait-modal.is-error .bio-pulse {
  animation: none;
  opacity: 0;
}

/* ── Barra de progresso por steps ── */
.bio-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin-bottom: 20px;
}

.bio-step {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: #e2e8f0;
  transition: background .35s ease;
}
.bio-step.is-done   { background: #2563eb; }
.bio-step.is-active {
  background: #93c5fd;
  animation: bioStepPulse 1.3s ease-in-out infinite;
}

@keyframes bioStepPulse {
  0%, 100% { background: #93c5fd; }
  50%       { background: #3b82f6; }
}

/* ── Textos ── */
.bio-status {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #0f172a;
  line-height: 1.3;
}

.bio-status-sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.55;
  max-width: 310px;
}

/* ── Botão de ação (Continuar / Fechar) ── */
.bio-action {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  transition: filter .15s;
}
.bio-action:hover { filter: brightness(1.06); }
.bio-action.is-success { background: linear-gradient(135deg, #16a34a, #22c55e); }
.bio-action.is-error   { background: linear-gradient(135deg, #dc2626, #ef4444); }
.bio-action[hidden]    { display: none; }

/* ── Botão cancelar ── */
.bio-cancel {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.bio-cancel:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}
.bio-cancel[hidden] { display: none; }

@media (max-width: 480px) {
  .bio-wait-modal { padding: 24px 18px 18px; }
  .bio-status { font-size: 15px; }
}

/* ══════════════════════════════════════════════════════════════
   VISUAL LEITOR/DEDO — SVG premium por estado
   ══════════════════════════════════════════════════════════════ */

.bio-wait-visual.bio-device-visual {
  position: relative;
  width: 220px;
  height: 220px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.bio-reader-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.bio-reader-shadow {
  fill: rgba(15, 23, 42, .18);
  filter: blur(2px);
}

.bio-reader-shell {
  fill: url(#bioReaderShell);
  stroke: rgba(255,255,255,.10);
  stroke-width: 1;
  filter: drop-shadow(0 18px 22px rgba(15,23,42,.28));
}

.bio-reader-glass {
  fill: url(#bioGlassGlow);
  opacity: .78;
  filter: drop-shadow(0 0 12px rgba(37,99,235,.38));
}

.bio-reader-reflection {
  fill: none;
  stroke: rgba(255,255,255,.32);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: .75;
}

.bio-scan-light {
  stroke: #bfdbfe;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(147,197,253,.9));
}

.bio-finger-svg {
  opacity: 0;
  transform-origin: 112px 138px;
  transform: translateY(-28px) rotate(-1deg);
  transition: opacity .28s ease, transform .38s ease;
}

.bio-finger-shadow {
  fill: rgba(15,23,42,.16);
  filter: blur(1px);
}

.bio-finger-body {
  fill: url(#bioFingerSkin);
  stroke: rgba(80, 45, 35, .12);
  stroke-width: .9;
}

.bio-finger-side,
.bio-finger-ridge {
  fill: none;
  stroke: rgba(80, 45, 35, .16);
  stroke-width: 1;
  stroke-linecap: round;
}

.bio-finger-nail {
  fill: url(#bioFingerNail);
  opacity: .78;
  stroke: rgba(80, 45, 35, .10);
  stroke-width: .7;
}

.bio-finger-pad {
  fill: rgba(176, 99, 76, .22);
  stroke: rgba(80, 45, 35, .08);
  stroke-width: .7;
}

.bio-reader-cable {
  fill: url(#bioCableGrad);
  stroke: rgba(255,255,255,.07);
  stroke-width: 1;
}

.bio-reader-connector {
  fill: url(#bioReaderShell);
  stroke: rgba(255,255,255,.12);
  stroke-width: 1;
}

.bio-reader-inset {
  fill: rgba(5, 8, 20, .65);
  stroke: rgba(255,255,255,.06);
  stroke-width: 1;
}

/* ── Estados por classe no modal ── */

.bio-state-preparing .bio-reader-glass {
  opacity: .45;
  animation: bioReaderSoftPulse 2.2s ease-in-out infinite;
}

.bio-state-preparing .bio-scan-light {
  opacity: 0;
}

.bio-state-preparing .bio-finger-svg {
  opacity: 0;
  transform: translateY(-34px) rotate(-1deg);
}

.bio-state-waiting .bio-reader-glass,
.bio-state-ready .bio-reader-glass {
  opacity: .95;
  animation: bioReaderReadyPulse 1.25s ease-in-out infinite;
}

.bio-state-waiting .bio-finger-svg,
.bio-state-ready .bio-finger-svg {
  opacity: 1;
  animation: bioFingerApproach 1.55s ease-in-out infinite;
}

.bio-state-waiting .bio-scan-light,
.bio-state-ready .bio-scan-light {
  opacity: .95;
  animation: bioScanLine 1.15s ease-in-out infinite;
}

.bio-state-capturing .bio-finger-svg,
.bio-state-reading .bio-finger-svg {
  opacity: 1;
  transform: translateY(3px) rotate(0deg) scaleY(.99);
}

.bio-state-capturing .bio-scan-light,
.bio-state-reading .bio-scan-light {
  opacity: 1;
  animation: bioScanLine .85s linear infinite;
}

.bio-state-success .bio-reader-glass {
  opacity: .96;
  fill: #22c55e;
  filter: drop-shadow(0 0 16px rgba(34,197,94,.5));
}

.bio-state-error .bio-reader-glass,
.bio-state-error-offline .bio-reader-glass,
.bio-state-error-no-enroll .bio-reader-glass,
.bio-state-timeout .bio-reader-glass {
  opacity: .88;
  filter: drop-shadow(0 0 14px rgba(239,68,68,.45));
}

/* ── Keyframes ── */

@keyframes bioReaderSoftPulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(59,130,246,.18)); }
  50% { filter: drop-shadow(0 0 18px rgba(59,130,246,.36)); }
}

@keyframes bioReaderReadyPulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(59,130,246,.45)); }
  50% { filter: drop-shadow(0 0 26px rgba(96,165,250,.75)); }
}

@keyframes bioFingerApproach {
  0%, 100% {
    transform: translateY(-26px) rotate(-1deg);
    opacity: .84;
  }
  50% {
    transform: translateY(3px) rotate(0deg) scaleY(.99);
    opacity: 1;
  }
}

@keyframes bioScanLine {
  0% {
    transform: translateY(-13px);
    opacity: .25;
  }
  45% {
    opacity: 1;
  }
  100% {
    transform: translateY(21px);
    opacity: .25;
  }
}

@media (max-width: 480px) {
  .bio-wait-visual.bio-device-visual {
    width: 172px;
    height: 172px;
    margin-bottom: 16px;
  }

  .bio-wait-modal {
    width: min(360px, calc(100vw - 28px));
  }
}
