/**
 * AN Product Fields - Custom Validation Styles
 * VERSION ULTRA-OPTIMISÉE POUR PERFORMANCES MAXIMALES
 * GPU Acceleration + will-change + contain + optimisations avancées
 */

/* ========================================
   Toast Notifications - GPU ACCELERATED
   ======================================== */

.an-pf-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0) scale(0);
    background: #fff;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(220, 53, 69, 0.3), 0 0 0 2px rgba(220, 53, 69, 0.2);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 400px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    will-change: transform, opacity;
    backface-visibility: hidden;
    contain: layout style paint;
}

.an-pf-toast-show {
    opacity: 1;
    transform: translate3d(-50%, -50%, 0) scale(1);
}

.an-pf-toast-error {
    border-left: 6px solid #dc3545;
    background: linear-gradient(135deg, #fff 0%, #fff5f5 100%);
}

.an-pf-toast-success {
    border-left: 6px solid #28a745;
    background: linear-gradient(135deg, #fff 0%, #f0fff4 100%);
}

.an-pf-toast-icon {
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
    animation: iconPulse 1s ease-in-out infinite;
    will-change: transform;
    transform: translateZ(0);
}

@keyframes iconPulse {
    0%, 100% { transform: scale3d(1, 1, 1); }
    50% { transform: scale3d(1.2, 1.2, 1); }
}

.an-pf-toast-message {
    font-weight: 600;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
    contain: layout style;
}

@media (max-width: 768px) {
    .an-pf-toast {
        min-width: 90%;
        max-width: 90%;
    }
}

/* ========================================
   États des champs - OPTIMISÉ GPU
   ======================================== */

.an-pf-field {
    contain: layout style;
}

.an-pf-field-error {
    position: relative;
}

.an-pf-field-error input,
.an-pf-field-error textarea,
.an-pf-field-error select {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
    background-color: #fff5f5 !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.an-pf-field-error input:focus,
.an-pf-field-error textarea:focus,
.an-pf-field-error select:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.2) !important;
}

.an-pf-field-error::after {
    content: '⚠️ Ce champ est obligatoire - Veuillez le remplir';
    display: block;
    color: #dc3545;
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff5f5;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
    animation: errorMessageSlide 0.2s ease;
    contain: layout style paint;
}

@keyframes errorMessageSlide {
    from {
        opacity: 0;
        transform: translate3d(0, -10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ========================================
   État Valide - OPTIMISÉ
   ======================================== */

.an-pf-field-valid input,
.an-pf-field-valid textarea,
.an-pf-field-valid select {
    border: 2px solid #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.2) !important;
    background-color: #f0fff4 !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.an-pf-field-valid input:focus,
.an-pf-field-valid textarea:focus,
.an-pf-field-valid select:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.2) !important;
}

.an-pf-field-valid::after {
    content: '✓ Parfait !';
    display: block;
    color: #28a745;
    font-size: 13px;
    font-weight: 600;
    margin-top: 5px;
    animation: successMessageSlide 0.2s ease;
    contain: layout style;
}

@keyframes successMessageSlide {
    from {
        opacity: 0;
        transform: translate3d(-10px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ========================================
   Transitions - OPTIMISÉ
   ======================================== */

.an-pf-field input,
.an-pf-field textarea,
.an-pf-field select {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.an-pf-field input:focus,
.an-pf-field textarea:focus,
.an-pf-field select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ========================================
   Popup Specific Styles - Hide error messages
   ======================================== */

.sidebar-product-popup .an-pf-field-error::after,
.attribute-customization .an-pf-field-error::after {
    display: none !important;
}

/* ========================================
   Mobile Optimizations
   ======================================== */

@media (max-width: 768px) {
    .an-pf-field-error::after {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* ========================================
   Toast Overlay - GPU ACCELERATED
   ======================================== */

.an-pf-toast-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    will-change: opacity;
    backface-visibility: hidden;
}

.an-pf-toast-overlay.show {
    opacity: 1;
}

/* ========================================
   Highlight Flash - GPU OPTIMIZED
   ======================================== */

@keyframes highlightFlash {
    0% { background-color: #fff; }
    25% { background-color: #fff3cd; }
    50% { background-color: #ffc107; }
    75% { background-color: #fff5f5; }
    100% { background-color: #fff5f5; }
}

.an-pf-field-highlight-flash input,
.an-pf-field-highlight-flash textarea {
    animation: highlightFlash 1s ease;
}

/* ========================================
   Arrow Indicator - GPU OPTIMIZED
   ======================================== */

.an-pf-field-arrow::before {
    content: '👇';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translate3d(-50%, 0, 0);
    font-size: 30px;
    animation: arrowBounce 1s ease-in-out 3;
    z-index: 10;
    will-change: transform;
    backface-visibility: hidden;
}

@keyframes arrowBounce {
    0%, 100% { transform: translate3d(-50%, 0, 0); }
    50% { transform: translate3d(-50%, -10px, 0); }
}

/* ========================================
   Performance: Disable animations on low-end devices
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

