/* ==========================================================================
   FinPilot AI — Face Scan (scanner facial automático)
   Componente visual biométrico compartilhado entre login e cadastro facial.
   ========================================================================== */

.face-scan-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 15%, #1E293B 0%, #0B1120 70%);
  isolation: isolate;
}

.face-scan-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  filter: brightness(1.02) saturate(1.05);
}

/* dims the frame outside the guide oval so attention goes to the target */
.face-scan-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(6, 10, 20, 0.38);
  -webkit-mask-image: radial-gradient(ellipse 34% 46% at 50% 46%, transparent 0%, transparent 62%, #000 100%);
  mask-image: radial-gradient(ellipse 34% 46% at 50% 46%, transparent 0%, transparent 62%, #000 100%);
  transition: background 0.25s ease;
}

.face-scan-guide {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 46%;
  width: 62%;
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  border-radius: 50% / 45%;
  border: 2.5px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
  overflow: hidden;
}

.face-scan-guide .scan-line {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 2px;
  top: 0;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.95), transparent);
  box-shadow: 0 0 10px 2px rgba(96, 165, 250, 0.7);
  opacity: 0;
}

.face-scan-corners {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 46%;
  width: 68%;
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.face-scan-corners span {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--blue-light, #60A5FA);
  transition: border-color 0.25s ease, opacity 0.25s ease;
  opacity: 0.9;
}
.face-scan-corners span.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.face-scan-corners span.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.face-scan-corners span.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.face-scan-corners span.br { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 6px 0; }

/* -------------------- estados -------------------- */

/* carregando modelos / câmera */
.face-scan-wrap[data-state="loading"] .face-scan-corners span { border-color: rgba(148, 163, 184, 0.5); }

/* procurando rosto */
.face-scan-wrap[data-state="searching"] .face-scan-guide { border-color: rgba(148, 163, 184, 0.6); }
.face-scan-wrap[data-state="searching"] .face-scan-corners span { border-color: rgba(148, 163, 184, 0.7); }

/* rosto detectado, mas precisa ajustar posição/distância */
.face-scan-wrap[data-state="align"] .face-scan-guide { border-color: rgba(245, 158, 11, 0.85); }
.face-scan-wrap[data-state="align"] .face-scan-corners span { border-color: #F59E0B; }

/* rosto bem posicionado, analisando/confirmando automaticamente */
.face-scan-wrap[data-state="good"] .face-scan-guide {
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0), 0 0 24px rgba(96, 165, 250, 0.35) inset;
}
.face-scan-wrap[data-state="good"] .face-scan-corners span { border-color: var(--blue-light, #60A5FA); }
.face-scan-wrap[data-state="good"] .scan-line {
  opacity: 1;
  animation: fpScanSweep 1.1s ease-in-out infinite;
}

/* sucesso */
.face-scan-wrap[data-state="success"] .face-scan-guide { border-color: var(--green, #22C55E); }
.face-scan-wrap[data-state="success"] .face-scan-corners span { border-color: var(--green, #22C55E); }
.face-scan-wrap[data-state="success"] .face-scan-shade { background: rgba(34, 197, 94, 0.12); }

/* erro / negado */
.face-scan-wrap[data-state="error"] .face-scan-guide { border-color: var(--danger, #EF4444); }
.face-scan-wrap[data-state="error"] .face-scan-corners span { border-color: var(--danger, #EF4444); }

@keyframes fpScanSweep {
  0% { top: 6%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 92%; opacity: 0; }
}

/* -------------------- status / progresso -------------------- */

.face-scan-status {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.7rem 0.9rem 0.65rem;
  text-align: center;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: linear-gradient(0deg, rgba(6, 10, 20, 0.82) 0%, rgba(6, 10, 20, 0) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.face-scan-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-light, #60A5FA);
  flex: 0 0 auto;
}
.face-scan-wrap[data-state="searching"] .face-scan-status .dot { background: #94A3B8; animation: fpPulse 1.3s ease-in-out infinite; }
.face-scan-wrap[data-state="align"] .face-scan-status .dot { background: #F59E0B; animation: fpPulse 1.1s ease-in-out infinite; }
.face-scan-wrap[data-state="good"] .face-scan-status .dot { background: var(--blue-light, #60A5FA); animation: fpPulse 0.7s ease-in-out infinite; }
.face-scan-wrap[data-state="success"] .face-scan-status .dot { background: var(--green, #22C55E); animation: none; }
.face-scan-wrap[data-state="error"] .face-scan-status .dot { background: var(--danger, #EF4444); animation: none; }

@keyframes fpPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* barra de progresso do auto-capture (preenche enquanto confirma o rosto) */
.face-scan-hold {
  position: absolute;
  z-index: 4;
  left: 16%;
  right: 16%;
  bottom: 2.55rem;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.face-scan-wrap[data-state="good"] .face-scan-hold { opacity: 1; }
.face-scan-hold .fill {
  height: 100%;
  width: 0%;
  background: var(--blue-light, #60A5FA);
  border-radius: 3px;
  transition: width 0.06s linear;
}
.face-scan-wrap[data-state="success"] .face-scan-hold .fill { background: var(--green, #22C55E); }

.face-scan-hint {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
