/* ============================================================
   NinjaTech AI — Liveness Detection SDK
   Scoped styles — all selectors prefixed with .ntl-
   Include this stylesheet or let the SDK inject it automatically
   ============================================================ */

/* ---------- Reset (scoped) ---------- */
.ntl-root *, .ntl-root *::before, .ntl-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- CSS Variables ---------- */
.ntl-root {
  --ntl-white:       #ffffff;
  --ntl-blue:        #4A90D9;
  --ntl-blue-light:  #7BB8F0;
  --ntl-blue-pale:   #EAF3FC;
  --ntl-blue-ring:   #A8D4F5;
  --ntl-green:       #22c55e;
  --ntl-red:         #ef4444;
  --ntl-text:        #1a1a2e;
  --ntl-text-mid:    #555577;
  --ntl-text-muted:  #9999bb;
  --ntl-bg:          #f0f2f5;
  --ntl-circle-size: min(260px, 58vw);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ntl-text);
}

/* ---------- Overlay / Modal Backdrop ---------- */
.ntl-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: ntl-fadeIn 0.25s ease;
}

@keyframes ntl-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Modal Shell ---------- */
.ntl-modal {
  background: var(--ntl-white);
  border-radius: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  animation: ntl-slideUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes ntl-slideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Modal Header ---------- */
.ntl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  flex-shrink: 0;
}

.ntl-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ntl-text);
  letter-spacing: -0.01em;
}

.ntl-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f0f0f5;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.ntl-close-btn:hover  { background: #e8e8f0; transform: scale(1.06); }
.ntl-close-btn:active { transform: scale(0.94); }
.ntl-close-btn svg { width: 16px; height: 16px; display: block; }

/* ---------- Main Content Area ---------- */
.ntl-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px 0;
  gap: 16px;
}

/* ---------- Circle Viewport ---------- */
.ntl-circle-wrap {
  position: relative;
  width: var(--ntl-circle-size);
  height: var(--ntl-circle-size);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ntl-ripple {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--ntl-blue-ring);
  opacity: 0;
  pointer-events: none;
}
.ntl-ripple.r1 {
  width: calc(var(--ntl-circle-size) + 28px);
  height: calc(var(--ntl-circle-size) + 28px);
}
.ntl-ripple.r2 {
  width: calc(var(--ntl-circle-size) + 58px);
  height: calc(var(--ntl-circle-size) + 58px);
}
.ntl-ripple.active { animation: ntl-ripple 2.4s ease-out infinite; }
.ntl-ripple.r2.active { animation-delay: 0.8s; }

@keyframes ntl-ripple {
  0%   { opacity: 0.5; transform: scale(0.92); }
  100% { opacity: 0;   transform: scale(1.08); }
}

.ntl-circle {
  width: var(--ntl-circle-size);
  height: var(--ntl-circle-size);
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: #e8f0f8;
  border: 4px solid var(--ntl-blue-ring);
  box-shadow: 0 0 0 6px rgba(168, 212, 245, 0.25);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.ntl-circle.active {
  border-color: var(--ntl-blue);
  box-shadow: 0 0 0 6px rgba(74,144,217,0.2), 0 0 30px rgba(74,144,217,0.12);
}
.ntl-circle.verified {
  border-color: var(--ntl-green);
  box-shadow: 0 0 0 6px rgba(34,197,94,0.18), 0 0 30px rgba(34,197,94,0.12);
}
.ntl-circle.failed {
  border-color: var(--ntl-red);
  box-shadow: 0 0 0 6px rgba(239,68,68,0.18);
}
.ntl-circle.flash-pass { animation: ntl-flashGreen 0.55s ease-out; }
.ntl-circle.flash-fail { animation: ntl-flashRed   0.55s ease-out; }

@keyframes ntl-flashGreen {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.7); }
  60%  { box-shadow: 0 0 0 18px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
@keyframes ntl-flashRed {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
  60%  { box-shadow: 0 0 0 18px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.ntl-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  border-radius: 50%;
}

.ntl-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  pointer-events: none;
  border-radius: 50%;
}

/* SVG arc */
.ntl-scan-arc {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  pointer-events: none;
  transform: rotate(-90deg);
}
.ntl-arc-track    { stroke: transparent; stroke-width: 4; fill: none; }
.ntl-arc-progress {
  stroke: var(--ntl-blue);
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 829.38;
  stroke-dashoffset: 829.38;
  transition: stroke-dashoffset 0.12s linear;
  filter: drop-shadow(0 0 4px rgba(74,144,217,0.5));
}
.ntl-arc-progress.success {
  stroke: var(--ntl-green);
  filter: drop-shadow(0 0 4px rgba(34,197,94,0.5));
}
.ntl-arc-progress.fail {
  stroke: var(--ntl-red);
  filter: none;
}

/* Challenge badge inside circle */
.ntl-badge {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50px;
  padding: 5px 14px;
  font-size: 1rem;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 12px rgba(74,144,217,0.18);
  border: 1px solid rgba(74,144,217,0.2);
  white-space: nowrap;
  z-index: 10;
}
.ntl-badge.visible {
  display: flex;
  animation: ntl-slideUp2 0.3s ease;
}
@keyframes ntl-slideUp2 {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading overlay */
.ntl-loading {
  position: absolute;
  inset: 0;
  background: #e8f0f8;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 20;
  transition: opacity 0.4s ease;
  padding: 16px;
}
.ntl-loading.hidden { opacity: 0; pointer-events: none; }

.ntl-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(74,144,217,0.2);
  border-top-color: var(--ntl-blue);
  border-radius: 50%;
  animation: ntl-spin 0.8s linear infinite;
}
@keyframes ntl-spin { to { transform: rotate(360deg); } }

.ntl-loading-label {
  font-size: 0.72rem;
  color: var(--ntl-text-muted);
  text-align: center;
  line-height: 1.4;
  padding: 0 8px;
}

/* ---------- Instruction Area ---------- */
.ntl-instruction {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 46px;
  width: 100%;
}
.ntl-instruction-main {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ntl-text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.ntl-instruction-sub {
  font-size: 0.78rem;
  color: var(--ntl-text-muted);
  line-height: 1.4;
  min-height: 18px;
}

/* ---------- Steps ---------- */
.ntl-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ntl-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1.5px solid #eee;
  border-radius: 12px;
  transition: all 0.3s ease;
}
.ntl-step.active  { background: var(--ntl-blue-pale); border-color: var(--ntl-blue-light); }
.ntl-step.done    { background: #f0fdf4; border-color: #86efac; }
.ntl-step.failed  { background: #fff1f2; border-color: #fca5a5; }

.ntl-step-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #f0f0f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: background 0.3s;
}
.ntl-step.active .ntl-step-icon { background: rgba(74,144,217,0.15); }
.ntl-step.done   .ntl-step-icon { background: rgba(34,197,94,0.12); }
.ntl-step.failed .ntl-step-icon { background: rgba(239,68,68,0.10); }

.ntl-step-text { flex: 1; min-width: 0; }
.ntl-step-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ntl-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ntl-step-desc {
  font-size: 0.7rem;
  color: var(--ntl-text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ntl-step-status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 50px;
  background: #eee;
  color: var(--ntl-text-muted);
  border: 1px solid #ddd;
  transition: all 0.3s;
  flex-shrink: 0;
  white-space: nowrap;
}
.ntl-step.active .ntl-step-status {
  background: rgba(74,144,217,0.15);
  color: var(--ntl-blue);
  border-color: var(--ntl-blue-light);
  animation: ntl-pulseBadge 1.2s infinite;
}
.ntl-step.done   .ntl-step-status { background: rgba(34,197,94,0.12); color: #16a34a; border-color: #86efac; }
.ntl-step.failed .ntl-step-status { background: rgba(239,68,68,0.10); color: #dc2626; border-color: #fca5a5; }

@keyframes ntl-pulseBadge {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---------- Progress Dots ---------- */
.ntl-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding-bottom: 4px;
}
.ntl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dde3ee;
  transition: all 0.35s ease;
}
.ntl-dot.active { background: var(--ntl-blue); transform: scale(1.4); box-shadow: 0 0 6px rgba(74,144,217,0.4); }
.ntl-dot.done   { background: var(--ntl-green); }
.ntl-dot.failed { background: var(--ntl-red); }

/* ---------- Alignment Overlay ---------- */
.ntl-align-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
}
.ntl-align-overlay.visible {
  display: flex;
}

.ntl-align-crosshair {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.ntl-align-h,
.ntl-align-v {
  position: absolute;
  background: rgba(74, 144, 217, 0.6);
  border-radius: 2px;
  transition: background 0.3s ease;
}
.ntl-align-h {
  width: 40px;
  height: 2px;
}
.ntl-align-v {
  width: 2px;
  height: 40px;
}

/* Corner brackets */
.ntl-align-crosshair::before,
.ntl-align-crosshair::after {
  content: '';
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  border: 2.5px solid rgba(74, 144, 217, 0.5);
  border-right: none;
  border-bottom: none;
  top: 0; left: 0;
  transition: border-color 0.3s ease;
}
.ntl-align-crosshair::after {
  top: auto; left: auto;
  bottom: 0; right: 0;
  border: 2.5px solid rgba(74, 144, 217, 0.5);
  border-left: none;
  border-top: none;
}

/* Aligned state */
.ntl-align-crosshair.aligned .ntl-align-h,
.ntl-align-crosshair.aligned .ntl-align-v {
  background: rgba(34, 197, 94, 0.9);
}
.ntl-align-crosshair.aligned::before,
.ntl-align-crosshair.aligned::after {
  border-color: rgba(34, 197, 94, 0.8);
}
.ntl-align-crosshair.aligned {
  animation: ntl-pulseGreen 0.6s ease-in-out infinite alternate;
}
@keyframes ntl-pulseGreen {
  from { transform: scale(1);    opacity: 0.9; }
  to   { transform: scale(1.08); opacity: 1;   }
}

/* ---------- Alignment Progress Bar ---------- */
.ntl-align-bar {
  width: 100%;
  height: 6px;
  background: #e8eef8;
  border-radius: 50px;
  overflow: hidden;
  display: none;
  flex-shrink: 0;
}
.ntl-align-bar.visible {
  display: block;
}
.ntl-align-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--ntl-blue);
  border-radius: 50px;
  transition: width 0.15s ease, background 0.4s ease;
}

/* ---------- Footer ---------- */
.ntl-footer {
  width: 100%;
  text-align: center;
  padding: 12px 0 16px;
  font-size: 0.72rem;
  color: var(--ntl-text-muted);
  flex-shrink: 0;
}
.ntl-footer a {
  color: var(--ntl-blue);
  font-weight: 600;
  text-decoration: none;
}
.ntl-footer a:hover { text-decoration: underline; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 380px) {
  .ntl-root { --ntl-circle-size: min(220px, 56vw); }
  .ntl-step-desc { display: none; }
}
@media (max-height: 640px) and (orientation: landscape) {
  .ntl-root { --ntl-circle-size: min(160px, 36vh); }
  .ntl-body { gap: 8px; padding-top: 4px; }
}