/**
 * Professional Selfie Capture UI
 * Visual guidance and feedback for face verification
 */

/* Face detection guideline frame */
.selfie-frame-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 350px;
  border: 3px solid rgba(129, 0, 127, 0.3);
  border-radius: 30px;
  background: transparent;
  pointer-events: none;
  z-index: 15;
  box-shadow: 
    inset 0 0 20px rgba(129, 0, 127, 0.1),
    0 0 40px rgba(129, 0, 127, 0.15);
  animation: frameGuidePulse 3s ease-in-out infinite;
}

@keyframes frameGuidePulse {
  0%, 100% {
    box-shadow: 
      inset 0 0 20px rgba(129, 0, 127, 0.1),
      0 0 40px rgba(129, 0, 127, 0.15);
    border-color: rgba(129, 0, 127, 0.3);
  }
  50% {
    box-shadow: 
      inset 0 0 20px rgba(129, 0, 127, 0.2),
      0 0 60px rgba(129, 0, 127, 0.25);
    border-color: rgba(129, 0, 127, 0.5);
  }
}

/* Corner accents for frame guide */
.selfie-frame-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid #81007F;
  pointer-events: none;
}

.selfie-frame-corner::before,
.selfie-frame-corner::after {
  content: '';
  position: absolute;
  background: #81007F;
}

.selfie-frame-corner-tl {
  top: -6px;
  left: -6px;
}

.selfie-frame-corner-tl::before {
  width: 100%;
  height: 3px;
  top: 0;
  left: 0;
}

.selfie-frame-corner-tl::after {
  width: 3px;
  height: 100%;
  top: 0;
  left: 0;
}

.selfie-frame-corner-tr {
  top: -6px;
  right: -6px;
}

.selfie-frame-corner-tr::before {
  width: 100%;
  height: 3px;
  top: 0;
  right: 0;
}

.selfie-frame-corner-tr::after {
  width: 3px;
  height: 100%;
  top: 0;
  right: 0;
}

.selfie-frame-corner-bl {
  bottom: -6px;
  left: -6px;
}

.selfie-frame-corner-bl::before {
  width: 100%;
  height: 3px;
  bottom: 0;
  left: 0;
}

.selfie-frame-corner-bl::after {
  width: 3px;
  height: 100%;
  bottom: 0;
  left: 0;
}

.selfie-frame-corner-br {
  bottom: -6px;
  right: -6px;
}

.selfie-frame-corner-br::before {
  width: 100%;
  height: 3px;
  bottom: 0;
  right: 0;
}

.selfie-frame-corner-br::after {
  width: 3px;
  height: 100%;
  bottom: 0;
  right: 0;
}

/* Liveness score visualization - Compact for desktop */
.selfie-score-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 0.5rem;
}

@media (min-width: 640px) {
  .selfie-score-ring {
    width: 130px;
    height: 130px;
    margin: 0 auto 0.5rem;
  }
}

.selfie-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.selfie-score-ring-bg {
  fill: none;
  stroke: rgba(129, 0, 127, 0.2);
  stroke-width: 8;
}

.selfie-score-ring-progress {
  fill: none;
  stroke: url(#scoreGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 565.5;
  stroke-dashoffset: 565.5;
  transition: stroke-dashoffset 0.5s ease-out;
}

.selfie-score-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1.2;
}

.selfie-score-number {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, #1B0081 0%, #81007F 50%, #FF0080 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
}

@media (min-width: 640px) {
  .selfie-score-number {
    font-size: 48px;
  }
}

.selfie-score-label {
  font-size: 12px;
  font-weight: 600;
  color: #81007F;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

/* Liveness detection feedback badges - Compact for desktop */
.selfie-detection-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 6px 0;
  min-height: 28px;
}

@media (min-width: 640px) {
  .selfie-detection-badges {
    gap: 6px;
    margin: 4px 0;
    min-height: 28px;
  }
}

.selfie-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(129, 0, 127, 0.1);
  border: 1px solid rgba(129, 0, 127, 0.3);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #81007F;
  animation: badgeSlideIn 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.selfie-badge.active {
  background: rgba(129, 0, 127, 0.2);
  border-color: rgba(129, 0, 127, 0.5);
}

.selfie-badge-icon {
  display: inline-block;
  font-size: 14px;
  animation: badgeIconFade 2.5s ease-in-out infinite;
}

.selfie-badge.active .selfie-badge-icon {
  animation: badgeIconFade 2.5s ease-in-out infinite;
}

@keyframes badgeIconFade {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Face detected indicator */
.selfie-face-detected {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #15803d;
  text-align: center;
  animation: faceDetectedGlow 3s ease-in-out infinite;
}

@keyframes faceDetectedGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.2);
  }
  50% {
    box-shadow: 0 0 8px 2px rgba(34, 197, 94, 0.15);
  }
}

.selfie-face-detected::before {
  content: '✓ ';
  color: #22c55e;
  font-weight: 900;
}

/* Ready state styling */
.selfie-ready {
  animation: readyPulse 1s ease-in-out infinite;
}

.selfie-ready .selfie-score-number {
  animation: readyNumberGlow 1s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes readyNumberGlow {
  0%, 100% {
    filter: drop-shadow(0 0 0px rgba(129, 0, 127, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(129, 0, 127, 0.8));
  }
}

/* Capture button ready state */
.selfie-capture-ready #captureSelfieBtn {
  animation: captureButtonPulse 1.2s ease-in-out infinite;
}

@keyframes captureButtonPulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(255, 0, 128, 0.3), 0 0 0 0 rgba(255, 0, 128, 0.4);
  }
  50% {
    box-shadow: 0 6px 20px rgba(255, 0, 128, 0.5), 0 0 0 8px rgba(255, 0, 128, 0.2);
  }
}

/* Instructions with visual hierarchy */
.selfie-instructions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 8px 0;
  padding: 8px;
  background: rgba(129, 0, 127, 0.05);
  border-left: 3px solid #81007F;
  border-radius: 8px;
}

@media (min-width: 640px) {
  .selfie-instructions {
    gap: 12px;
    margin: 8px 0 16px 0;
    padding: 12px;
  }
}

.selfie-instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #1B0081;
  line-height: 1.3;
}

@media (min-width: 640px) {
  .selfie-instruction-item {
    font-size: 13px;
    gap: 10px;
    line-height: 1.4;
  }
}

.selfie-instruction-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Light detection indicator */
.selfie-lighting-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #b45309;
  margin: 8px 0;
}

.selfie-lighting-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fbbf24;
  animation: lightingPulse 2s ease-in-out infinite;
}

@keyframes lightingPulse {
  0%, 100% {
    background: #fbbf24;
    box-shadow: 0 0 4px rgba(251, 191, 36, 0.5);
  }
  50% {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
  }
}

/* Loading skeleton for camera shell */
.selfie-shell-loading {
  background: linear-gradient(
    90deg,
    rgba(129, 0, 127, 0.05) 0%,
    rgba(129, 0, 127, 0.15) 50%,
    rgba(129, 0, 127, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skeletonLoad 1.5s ease-in-out infinite;
}

@keyframes skeletonLoad {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.selfie-shell-ready {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 
    0 0 0 2px rgba(34, 197, 94, 0.1),
    inset 0 0 20px rgba(34, 197, 94, 0.05);
}

/* Modal header styling */
.selfie-modal-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.5rem;
}

.selfie-modal-title {
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, #1B0081 0%, #81007F 50%, #FF0080 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

@media (min-width: 640px) {
  .selfie-modal-title {
    font-size: 22px;
  }

  .selfie-modal-header {
    gap: 2px;
    margin-bottom: 0.375rem;
  }
}

.selfie-modal-subtitle {
  font-size: 11px;
  color: #81007F;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (min-width: 640px) {
  .selfie-modal-subtitle {
    font-size: 12px;
  }
}

/* Responsive adjustments for mobile */
@media (max-width: 640px) {
  .selfie-frame-guide {
    width: 240px;
    height: 300px;
  }

  .selfie-score-ring {
    width: 140px;
    height: 140px;
    margin: 0 auto 0.75rem;
  }

  .selfie-score-number {
    font-size: 36px;
  }

  .selfie-score-label {
    font-size: 11px;
  }

  .selfie-modal-title {
    font-size: 20px;
  }

  .selfie-instructions {
    gap: 8px;
    padding: 10px;
    font-size: 12px;
  }

  .selfie-instruction-icon {
    font-size: 14px;
  }
}

/* Transition for ready state */
.selfie-modal.ready-state {
  pointer-events: auto;
}

.selfie-modal.ready-state #captureSelfieBtn {
  pointer-events: auto;
}

/* Animation for camera feed starting */
.selfie-camera-starting {
  animation: cameraStartFade 0.8s ease-out forwards;
}

@keyframes cameraStartFade {
  from {
    opacity: 0;
    background: #1a0a2e;
  }
  to {
    opacity: 1;
    background: transparent;
  }
}

/* Accessible focus states */
#captureSelfieBtn:focus-visible,
#selfieModal button:focus-visible {
  outline: 3px solid #81007F;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Reduce motion support */
@media (prefers-reduced-motion: reduce) {
  .selfie-frame-guide,
  .selfie-badge,
  .selfie-badge-icon,
  .selfie-face-detected,
  .selfie-ready,
  .selfie-ready .selfie-score-number,
  .selfie-capture-ready #captureSelfieBtn,
  .selfie-lighting-indicator,
  .selfie-shell-loading,
  .selfie-camera-starting {
    animation: none !important;
    transition: none !important;
  }
}
