/**
 * Circular Biometric Face Verification UI Styles
 * Professional fintech-style face scanning interface
 */

/* Container and Layout */
.circular-face-verifier {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #1a1f35 100%);
    border-radius: 16px;
    color: #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Header */
.face-verifier-header {
    text-align: center;
    width: 100%;
}

.face-verifier-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.face-verifier-subtitle {
    font-size: 14px;
    color: #9ca3af;
    margin: 8px 0 0 0;
    font-weight: 400;
}

/* Video Container and Circular Frame */
.face-verifier-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 350px;
    border-radius: 50%;
    overflow: hidden;
    background: #1f2937;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8),
                0 0 30px rgba(16, 185, 129, 0.1);
}

.face-verifier-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror like selfie camera */
    background: #000;
}

.face-verifier-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* Circular Frame Overlay */
.face-circular-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: none;
}

/* Scanning Ring SVG */
.face-scanning-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.face-ring-background {
    fill: none;
    stroke: rgba(31, 41, 55, 0.5);
    stroke-width: 2;
}

.face-ring-animate {
    fill: none;
    stroke: url(#scanGradient);
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0;
    stroke-dasharray: 596;
    stroke-dashoffset: 596;
}

.face-scanning-ring.scanning .face-ring-animate {
    animation: scan-ring 2.5s ease-in-out infinite;
    opacity: 1;
}

.face-scanning-ring.success .face-ring-animate {
    animation: success-ring 0.6s ease-out forwards;
    opacity: 1;
    stroke: #10b981;
}

.face-scanning-ring.error .face-ring-animate {
    animation: error-ring 0.5s ease-out forwards;
    opacity: 1;
    stroke: #ef4444;
}

@keyframes scan-ring {
    0% {
        stroke-dashoffset: 596;
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 0.3;
    }
}

@keyframes success-ring {
    0% {
        stroke-dashoffset: 596;
        transform: scale(0.9);
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes error-ring {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(-4px, 0);
    }
    75% {
        transform: translate(4px, 0);
    }
}

/* Corner Indicators */
.face-corner-indicators {
    stroke: rgba(107, 114, 128, 0.6);
    stroke-width: 2;
    stroke-linecap: round;
}

.face-corner-indicators .corner-line {
    opacity: 0.6;
}

/* Face Center Guide (Crosshair) */
.face-center-guide {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.crosshair {
    width: 40px;
    height: 40px;
    position: relative;
    opacity: 0.4;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: #10b981;
}

.crosshair::before {
    width: 40px;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.crosshair::after {
    width: 2px;
    height: 40px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Face Detected Indicator */
.face-detected-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    opacity: 0.3;
}

.face-detected-indicator.detected {
    background: #10b981;
    opacity: 1;
    animation: pulse-indicator 1s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.pulse-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
}

/* Status Section */
.face-verifier-status {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Quality Meter */
.quality-meter {
    width: 100%;
    padding: 12px 16px;
    background: rgba(31, 41, 55, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.quality-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quality-text {
    color: #9ca3af;
}

.quality-value {
    color: #10b981;
    font-variant-numeric: tabular-nums;
}

.quality-bar {
    width: 100%;
    height: 6px;
    background: rgba(17, 24, 39, 0.8);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.quality-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    border-radius: 2px;
    width: 0%;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Live Instructions */
.live-instructions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.instruction-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    font-size: 18px;
}

.icon-spinner {
    animation: spin 2s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.instruction-text {
    flex: 1;
}

.instruction-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.4;
}

.instruction-detail {
    font-size: 12px;
    color: #9ca3af;
    margin: 2px 0 0 0;
    line-height: 1.4;
}

/* Challenge Display */
.challenge-display {
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.challenge-instruction {
    font-size: 16px;
    font-weight: 600;
    color: #3b82f6;
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

.challenge-progress {
    font-size: 12px;
    color: #9ca3af;
    margin: 6px 0 0 0;
    text-align: center;
    line-height: 1.4;
}

/* Verification Progress */
.verification-progress {
    display: flex;
    justify-content: center;
}

.progress-dots {
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(107, 114, 128, 0.5);
    transition: all 0.3s ease;
}

.progress-dot.active {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Error Message */
.error-message {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 13px;
    color: #fca5a5;
    text-align: center;
    line-height: 1.5;
    animation: slideIn 0.3s ease-out;
}

/* Success Message */
.success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.success-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    font-size: 18px;
    font-weight: bold;
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-text {
    font-size: 14px;
    font-weight: 600;
    color: #10b981;
    margin: 0;
    line-height: 1.4;
}

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

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Action Buttons */
.face-verifier-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-cancel {
    background: rgba(107, 114, 128, 0.2);
    color: #d1d5db;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.btn-cancel:hover {
    background: rgba(107, 114, 128, 0.3);
    border-color: rgba(107, 114, 128, 0.5);
}

.btn-retry,
.btn-reenroll {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
}

.btn-retry:hover,
.btn-reenroll:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.btn-retry:active,
.btn-reenroll:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 480px) {
    .circular-face-verifier {
        max-width: 100%;
        padding: 16px;
        gap: 16px;
    }

    .face-verifier-title {
        font-size: 24px;
    }

    .face-verifier-container {
        max-width: 280px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 12px;
    }

    .instruction-title {
        font-size: 13px;
    }
}

/* Dark Mode (already default, but ensure compatibility) */
@media (prefers-color-scheme: dark) {
    .circular-face-verifier {
        background: linear-gradient(135deg, #0f172a 0%, #1a1f35 100%);
        color: #e5e7eb;
    }
}

/* Light Mode Support (optional) */
@media (prefers-color-scheme: light) {
    .circular-face-verifier {
        background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
        color: #374151;
    }

    .face-verifier-title {
        color: #111827;
    }

    .face-verifier-subtitle {
        color: #6b7280;
    }

    .face-verifier-container {
        background: #e5e7eb;
        box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.1),
                    0 0 30px rgba(16, 185, 129, 0.1);
    }

    .quality-meter {
        background: rgba(229, 231, 235, 0.8);
        border-color: rgba(156, 163, 175, 0.3);
    }

    .live-instructions {
        background: rgba(16, 185, 129, 0.08);
        border-color: rgba(16, 185, 129, 0.2);
    }

    .instruction-title {
        color: #111827;
    }

    .instruction-detail {
        color: #6b7280;
    }

    .challenge-display {
        background: rgba(59, 130, 246, 0.08);
        border-color: rgba(59, 130, 246, 0.2);
    }

    .error-message {
        background: rgba(239, 68, 68, 0.08);
        border-color: rgba(239, 68, 68, 0.3);
    }

    .success-message {
        background: rgba(16, 185, 129, 0.08);
        border-color: rgba(16, 185, 129, 0.3);
    }

    .btn-cancel {
        background: rgba(229, 231, 235, 0.8);
        color: #374151;
        border-color: rgba(156, 163, 175, 0.3);
    }

    .btn-cancel:hover {
        background: rgba(209, 213, 219, 0.8);
    }
}

/* Hold-still countdown */
.face-countdown {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 0 24px rgba(16, 185, 129, 0.8);
    pointer-events: none;
}

.face-countdown-pulse {
    animation: countdown-pulse 1s ease-out;
}

@keyframes countdown-pulse {
    0% {
        transform: scale(1.6);
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* "✓ Done" flash after a completed challenge */
.face-done-badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    font-weight: 800;
    color: #10b981;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.7);
    pointer-events: none;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-detail {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

/* Print Styles */
@media print {
    .circular-face-verifier {
        display: none;
    }
}
