/**
 * Micro-interactions & Button Enhancements
 * Adds delightful animations and feedback for user actions
 */

/* Button Hover & Active States */
.btn-primary,
.btn-accent,
button[type="submit"]:not([class*="btn-"]) {
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.btn-primary:hover,
.btn-accent:hover,
button[type="submit"]:not([class*="btn-"]):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 151, 196, 0.3);
}

.btn-primary:active,
.btn-accent:active,
button[type="submit"]:not([class*="btn-"]):active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(107, 151, 196, 0.2);
}

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Heart Animation (Like Button) */
@keyframes heart-beat {
    0% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.2); }
    60% { transform: scale(1); }
}

@keyframes heart-burst {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 1;
    }
    100% {
        transform: scale(1.5) rotate(-45deg);
        opacity: 0;
    }
}

.heart-animate {
    animation: heart-beat 0.8s ease-in-out;
}

.heart-liked {
    color: #ef4444 !important;
    fill: #ef4444 !important;
}

.heart-burst-container {
    position: relative;
    display: inline-block;
}

.heart-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #ef4444 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

.heart-burst.active {
    animation: heart-burst 0.6s ease-out forwards;
}

/* Cart Bounce Animation */
@keyframes cart-bounce {
    0%, 100% { transform: translateY(0); }
    10% { transform: translateY(-8px); }
    30% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
    70% { transform: translateY(0); }
}

@keyframes cart-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.cart-badge-animate {
    animation: cart-bounce 0.6s ease-in-out;
}

.cart-icon-shake {
    animation: cart-shake 0.4s ease-in-out;
}

/* Success Check Animation */
@keyframes check-scale {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(-45deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(-45deg);
        opacity: 1;
    }
}

.success-check {
    display: inline-block;
    width: 20px;
    height: 12px;
    border-left: 3px solid #10b981;
    border-bottom: 3px solid #10b981;
    transform: rotate(-45deg);
    animation: check-scale 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Confetti Effect */
@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #6b97c4;
    top: -10px;
    z-index: 9999;
    pointer-events: none;
    animation: confetti-fall 3s ease-out forwards;
}

.confetti-piece--1 { background: #6b97c4; left: 10%; animation-delay: 0s; }
.confetti-piece--2 { background: #8eb3d6; left: 20%; animation-delay: 0.1s; }
.confetti-piece--3 { background: #fbbf24; left: 30%; animation-delay: 0.2s; }
.confetti-piece--4 { background: #10b981; left: 40%; animation-delay: 0.3s; }
.confetti-piece--5 { background: #ef4444; left: 50%; animation-delay: 0.4s; }
.confetti-piece--6 { background: #8b5cf6; left: 60%; animation-delay: 0.5s; }
.confetti-piece--7 { background: #6b97c4; left: 70%; animation-delay: 0.6s; }
.confetti-piece--8 { background: #8eb3d6; left: 80%; animation-delay: 0.7s; }
.confetti-piece--9 { background: #fbbf24; left: 90%; animation-delay: 0.8s; }

/* Button Loading Pulse */
@keyframes button-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.btn-pulse {
    animation: button-pulse 1.5s ease-in-out infinite;
}

/* Badge Notification Bounce */
@keyframes badge-bounce-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.badge-animate-in {
    animation: badge-bounce-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Interactive Card Hover */
.interactive-card {
    transition: all 0.3s ease;
}

.interactive-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.interactive-card:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* Floating Animation for Icons */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.icon-float {
    animation: float 3s ease-in-out infinite;
}

/* Spin Animation for Loading Icons */
@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.icon-spin {
    animation: spin-slow 2s linear infinite;
}

/* Wiggle Animation */
@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.icon-wiggle {
    animation: wiggle 0.5s ease-in-out;
}

/* Success Flash */
@keyframes success-flash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(16, 185, 129, 0.2);
    }
}

.success-flash {
    animation: success-flash 0.6s ease-in-out;
}

/* Error Shake */
@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-shake {
    animation: error-shake 0.4s ease-in-out;
}

/* Bookmark Animation */
@keyframes bookmark-fill {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.3) translateY(-5px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

.bookmark-animate {
    animation: bookmark-fill 0.5s ease-in-out;
}

/* Star Rating Animation */
@keyframes star-sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.3) rotate(72deg);
        filter: brightness(1.5);
    }
}

.star-animate {
    animation: star-sparkle 0.6s ease-in-out;
}

/* Smooth Scale on Tap */
.tap-scale {
    transition: transform 0.1s ease;
}

.tap-scale:active {
    transform: scale(0.95);
}

/* Glow Effect */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(107, 151, 196, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(107, 151, 196, 0.8);
    }
}

.btn-glow {
    animation: glow 2s ease-in-out infinite;
}

/* Slide In from Bottom */
@keyframes slide-in-bottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-in-bottom {
    animation: slide-in-bottom 0.4s ease-out;
}

/* Fade In */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fade-in 0.3s ease-in;
}

/* RTL Support for Animations */
[dir="rtl"] .heart-burst {
    right: 50%;
    left: auto;
    transform: translate(50%, -50%) scale(0);
}

[dir="rtl"] .confetti-piece--1 { left: auto; right: 10%; }
[dir="rtl"] .confetti-piece--2 { left: auto; right: 20%; }
[dir="rtl"] .confetti-piece--3 { left: auto; right: 30%; }
[dir="rtl"] .confetti-piece--4 { left: auto; right: 40%; }
[dir="rtl"] .confetti-piece--5 { left: auto; right: 50%; }
[dir="rtl"] .confetti-piece--6 { left: auto; right: 60%; }
[dir="rtl"] .confetti-piece--7 { left: auto; right: 70%; }
[dir="rtl"] .confetti-piece--8 { left: auto; right: 80%; }
[dir="rtl"] .confetti-piece--9 { left: auto; right: 90%; }
