/**
 * Biometric Login - CSS Otimizado v4.0
 * Sistema de autenticação biométrica moderno e performático
 * 
 * @version 4.0.0
 */

/* ============================================================================
   ANIMAÇÕES GLOBAIS
   ============================================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

@keyframes glow {
    0%, 100% { 
        opacity: 0.4; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.15);
    }
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

@keyframes scanLine {
    0%, 100% {
        top: 10%;
        opacity: 0;
    }
    10%, 90% {
        opacity: 1;
    }
    100% {
        top: 90%;
    }
}

/* ============================================================================
   WRAPPER PRINCIPAL
   ============================================================================ */
.biometric-wrapper {
    /* background: linear-gradient(135deg, #000945ed 0%, #00350c 100%); */
    /* display: none; */
    border-radius: 12px;
    /* padding: 10px; */
    /* margin: 5px 0 !important; */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); */
    position: relative;
    overflow: hidden;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1); */
}

.biometric-wrapper::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: glow 4s ease-in-out infinite;
    pointer-events: none;
}


/* Estado desabilitado */
.biometric-wrapper.disabled {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.8);
}

.biometric-wrapper.disabled::after {
    content: '🔒 Biometria indisponível';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   TOGGLE SWITCH
   ============================================================================ */
.biometric-toggle-container {
    display: block;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    align-items: center;
    text-align: left;
    margin-top: 10px;
}

.biometric-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
    margin: 0;
    flex-shrink: 0;
}

.biometric-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.biometric-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 9999px;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.biometric-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.biometric-slider::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: transparent;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Estado checked */
.biometric-checkbox:checked + .biometric-slider {
    background: linear-gradient(135deg, #00a32a 0%, #008a20 100%);
    border-color: #00a32a;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.biometric-checkbox:checked + .biometric-slider::before {
    transform: translateX(28px);
    box-shadow: 0 0 10px rgba(0, 163, 42, 0.5);
}

/* Estado focus */
.biometric-checkbox:focus-visible + .biometric-slider::after {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
}

/* Estado disabled */
.biometric-checkbox:disabled + .biometric-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hover effect */
.biometric-slider:hover:not(.biometric-checkbox:disabled + .biometric-slider) {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.02);
}

/* ============================================================================
   LABEL DO TOGGLE
   ============================================================================ */
.biometric-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    margin: 0;
    user-select: none;
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.biometric-label:hover {
    opacity: 0.9;
    transform: translateX(2px);
}

.biometric-label svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.biometric-label:hover svg {
    animation: iconBounce 0.6s ease;
}

.biometric-checkbox:disabled ~ .biometric-label {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   MENSAGENS DE STATUS
   ============================================================================ */
.biometric-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    color: #2c3338;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 8px;
    line-height: 1.5;
}

.biometric-message svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

/* Estado de sucesso */
.biometric-success .biometric-message {
    background: linear-gradient(135deg, #f0fff4 0%, #dcfce7 100%);
    border-left: 4px solid #00a32a;
}

.biometric-success .biometric-message svg {
    color: #00a32a;
    animation: pulse 0.5s ease;
}

/* Estado de erro */
.biometric-error .biometric-message {
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    border-left: 4px solid #d63638;
    animation: shake 0.5s ease;
}

.biometric-error .biometric-message svg {
    color: #d63638;
}

/* ============================================================================
   LOADER
   ============================================================================ */
#biometric-loader {
    text-align: center;
    margin-top: 10px;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#biometric-loader > div {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================================================
   MODAIS
   ============================================================================ */
.biometric-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 999999;
    padding: 20px;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.biometric-modal.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.biometric-modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 24px;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
}

.biometric-modal-content h2 {
    font-size: 20px;
    color: #2c3338;
    margin: 0 0 10px;
    font-weight: 700;
    line-height: 1.4;
}

.biometric-modal-content p {
    color: #50575e;
    font-size: 15px;
    margin: 0 0 12px;
    line-height: 1.6;
}

/* ============================================================================
   ÍCONE DE BIOMETRIA ANIMADO
   ============================================================================ */
.fingerprint-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    margin: 12px auto;
    position: relative;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.fingerprint-icon::before {
    content: '';
    position: absolute;
    inset: -20%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.3) 0%, transparent 70%);
    animation: ripple 2s ease-out infinite;
}

.fingerprint-icon svg {
    width: 50px;
    height: 50px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.2));
}

/* ============================================================================
   BOTÕES
   ============================================================================ */
.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.modal-buttons button {
    flex: 1;
    padding: 14px 30px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-cancel {
    background: #f0f0f1;
    color: #2c3338;
    border: 1px solid #dcdcde;
}

.btn-cancel:hover {
    background: #dcdcde;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-allow {
    background: linear-gradient(135deg, #0073aa 0%, #005177 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 115, 170, 0.3);
}

.btn-allow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 115, 170, 0.5);
}

.modal-buttons button:active {
    transform: translateY(0);
}

.modal-buttons button:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* ============================================================================
   BARRA DE PROGRESSO
   ============================================================================ */
.progress-container {
    width: 100%;
    height: 8px;
    background: #e8e8e8;
    border-radius: 9999px;
    overflow: hidden;
    margin: 10px 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0073aa 0%, #00a32a 100%);
    border-radius: inherit;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(0, 115, 170, 0.5);
}

.biometric-modal.error .progress-fill {
    background: linear-gradient(90deg, #d63638 0%, #8b0000 100%);
}

.biometric-modal.success .progress-fill {
    background: linear-gradient(135deg, #00a32a 0%, #008a20 100%);
}

/* ============================================================================
   SCANNER DE IMPRESSÃO DIGITAL
   ============================================================================ */
.fingerprint-scanner {
    width: 150px;
    height: 150px;
    position: relative;
    margin: 12px auto;
}

.fingerprint-scanner svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 20px rgba(0, 115, 170, 0.3));
}

.scan-line {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #00a32a 50%, transparent 100%);
    box-shadow: 0 0 10px #00a32a;
    animation: scanLine 2s ease-in-out infinite;
}

/* ============================================================================
   RESPONSIVIDADE
   ============================================================================ */
@media (max-width: 600px) {
    .biometric-wrapper {
        padding: 8px;
        margin: 8px 0;
    }

    .biometric-label {
        font-size: 14px;
    }

    .biometric-label svg {
        width: 18px;
        height: 18px;
    }

    .biometric-modal {
        padding: 15px;
    }

    .biometric-modal-content {
        padding: 12px 10px;
        max-width: calc(100% - 30px);
    }
    
    .biometric-modal-content h2 {
        font-size: 18px;
    }
    
    .fingerprint-icon {
        width: 80px;
        height: 80px;
    }
    
    .fingerprint-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .fingerprint-scanner {
        width: 120px;
        height: 120px;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-buttons button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .biometric-wrapper.disabled::after {
        font-size: 11px;
        padding: 5px 8px;
        white-space: normal;
        max-width: 200px;
    }

    .biometric-message {
        padding: 12px;
        font-size: 12px;
    }
}

/* ============================================================================
   ACESSIBILIDADE
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .biometric-wrapper {
        border: 2px solid white;
    }
    
    .biometric-slider {
        border-width: 3px;
    }
}

/* ============================================================================
   DARK MODE
   ============================================================================ */
@media (prefers-color-scheme: dark) {
    .biometric-message {
        background: #1e1e1e;
        color: #ffffff;
    }

    .biometric-modal-content {
        background: linear-gradient(135deg, #1f2937, #111827);
        color: white;
    }

    .biometric-modal-content h2,
    .biometric-modal-content p {
        color: rgba(255, 255, 255, 0.9);
    }

    .btn-cancel {
        background: #3c3c3c;
        color: #ffffff;
        border-color: #555555;
    }

    .btn-cancel:hover {
        background: #4a4a4a;
    }
}

/* ============================================================================
   INTEGRAÇÃO WORDPRESS/WOOCOMMERCE
   ============================================================================ */
.login form .biometric-wrapper,
.woocommerce-form-login .biometric-wrapper,
#loginform .biometric-wrapper {
    margin: -10px 0 3px 0;
}