/**
 * Animações - Sistema de Cadastro Moeble
 *
 * @package MoebleCadastro
 */

/* ==========================================================================
   Keyframes
   ========================================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

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

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ==========================================================================
   Animation Classes
   ========================================================================== */
.animate-fade-in-up {
    animation: fadeInUp 0.4s ease forwards;
}

.animate-fade-out-up {
    animation: fadeOutUp 0.3s ease forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.animate-fade-out {
    animation: fadeOut 0.3s ease forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.4s ease forwards;
}

.animate-slide-out-left {
    animation: slideOutLeft 0.3s ease forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease forwards;
}

.animate-shake {
    animation: shake 0.5s ease;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease infinite;
}

/* ==========================================================================
   Transition Utilities
   ========================================================================== */
.transition-all {
    transition: all 0.3s ease;
}

.transition-colors {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.transition-transform {
    transition: transform 0.3s ease;
}

.transition-opacity {
    transition: opacity 0.3s ease;
}

/* ==========================================================================
   Form Step Transitions - SUAVE SEM TRAVAMENTO
   ========================================================================== */
.moeble-step {
    display: none;
    opacity: 0;
}

.moeble-step.active {
    display: block;
    opacity: 1;
    animation: elegantFadeIn 0.6s ease-out;
}

@keyframes elegantFadeIn {
    0% {
        opacity: 0;
        transform: translateY(16px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Input Focus Animation
   ========================================================================== */
.moeble-field-input,
.moeble-field-select,
.moeble-field-textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.moeble-field-input:focus,
.moeble-field-select:focus,
.moeble-field-textarea:focus {
    border-color: #FFFFFF;
}

/* ==========================================================================
   Button Animations
   ========================================================================== */
.moeble-btn {
    position: relative;
    overflow: hidden;
}

.moeble-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.moeble-btn:active::after {
    width: 200%;
    height: 200%;
}

.moeble-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.moeble-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Loading state */
.moeble-btn.loading {
    pointer-events: none;
    position: relative;
}

.moeble-btn.loading::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   Choice Animation
   ========================================================================== */
.moeble-choice-label {
    transition: all 0.2s ease;
}

.moeble-choice-label:active {
    transform: scale(0.98);
}

.moeble-choice-input:checked + .moeble-choice-label {
    animation: scaleIn 0.2s ease;
}

/* ==========================================================================
   Error Animation
   ========================================================================== */
.moeble-field.has-error .moeble-field-input,
.moeble-field.has-error .moeble-field-select,
.moeble-field.has-error .moeble-field-textarea {
    animation: shake 0.4s ease;
}

.moeble-field-error {
    animation: fadeIn 0.2s ease;
}

/* ==========================================================================
   Success Animation
   ========================================================================== */
.moeble-field.is-valid .moeble-field-input::after {
    content: '✓';
    position: absolute;
    right: 0;
    color: var(--mc-success);
    animation: scaleIn 0.2s ease;
}

/* ==========================================================================
   Progress Bar Animation
   ========================================================================== */
.moeble-progress-fill {
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Modal Animations
   ========================================================================== */
.moeble-modal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.moeble-modal.active {
    opacity: 1;
}

.moeble-modal-content {
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
}

.moeble-modal.active .moeble-modal-content {
    transform: scale(1) translateY(0);
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */
.moeble-loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.moeble-loading.active {
    opacity: 1;
}

.moeble-spinner {
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Stagger Animation for Lists
   ========================================================================== */
.moeble-stagger > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}

.moeble-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.moeble-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.moeble-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.moeble-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.moeble-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.moeble-stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
