/* ═══════════════════════════════════════════════════════════════
   PHASE 3 - COOL ANIMATIONS
   Loading, Payment, Success, Transitions, Effects
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. LOADING ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* Spinner Loading */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner-lg {
    border: 6px solid rgba(0, 0, 0, 0.1);
    border-top: 6px solid #007bff;
    width: 60px;
    height: 60px;
}

/* Pulse Loading */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Bounce Loading */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* Three Dots Loading */
.dots {
    display: inline-flex;
    gap: 5px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #007bff;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

/* ═══════════════════════════════════════════════════════════════
   2. FADE IN / FADE OUT
   ═══════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-in-out;
}

.fade-out {
    animation: fadeOut 0.6s ease-in-out;
}

/* ═══════════════════════════════════════════════════════════════
   3. SLIDE IN / SLIDE OUT
   ═══════════════════════════════════════════════════════════════ */

@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-top {
    animation: slideInFromTop 0.5s ease-out;
}

.slide-in-bottom {
    animation: slideInFromBottom 0.5s ease-out;
}

.slide-in-left {
    animation: slideInFromLeft 0.5s ease-out;
}

.slide-in-right {
    animation: slideInFromRight 0.5s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   4. SCALE / ZOOM
   ═══════════════════════════════════════════════════════════════ */

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scaleUp {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.4s ease-out;
}

.zoom-in {
    animation: zoomIn 0.5s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   5. SHAKE / WIGGLE
   ═══════════════════════════════════════════════════════════════ */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

.wiggle {
    animation: wiggle 0.5s ease-in-out;
}

/* ═══════════════════════════════════════════════════════════════
   6. SUCCESS ANIMATION (Checkmark)
   ═══════════════════════════════════════════════════════════════ */

@keyframes checkmark {
    0% {
        stroke-dashoffset: 50;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes successCircle {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.success-checkmark {
    animation: checkmark 0.6s ease-out;
    stroke-dasharray: 50;
}

.success-circle {
    animation: successCircle 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ═══════════════════════════════════════════════════════════════
   7. CONFETTI ANIMATION (Success Celebration)
   ═══════════════════════════════════════════════════════════════ */

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #007bff;
    animation: confetti-fall 3s ease-in forwards;
    pointer-events: none;
}

/* Different colors for confetti */
.confetti-gold { background: #FFD700; }
.confetti-green { background: #28a745; }
.confetti-red { background: #dc3545; }
.confetti-purple { background: #6f42c1; }
.confetti-pink { background: #e83e8c; }

/* ═══════════════════════════════════════════════════════════════
   8. BUTTON ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes buttonClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes buttonHover {
    from { transform: translateY(0); }
    to { transform: translateY(-3px); }
}

.btn-animated {
    transition: all 0.3s ease;
}

.btn-animated:hover {
    animation: buttonHover 0.3s ease-out forwards;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

.btn-animated:active {
    animation: buttonClick 0.3s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   9. CARD ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

@keyframes cardBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes cardGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(0, 123, 255, 0); }
}

.card-glow {
    animation: cardGlow 2s infinite;
}

.card-bounce {
    animation: cardBounce 1s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   10. TEXT ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes typewriter {
    from {
        width: 0;
        overflow: hidden;
    }
    to {
        width: 100%;
    }
}

@keyframes blinkCursor {
    0%, 100% { border-right-color: transparent; }
    50% { border-right-color: #007bff; }
}

@keyframes slideText {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.typewriter {
    animation: typewriter 2s steps(40, end), blinkCursor 0.75s step-end infinite;
    border-right: 2px solid #007bff;
    white-space: nowrap;
}

.slide-text {
    animation: slideText 0.6s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   11. MODAL ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes backdropFade {
    from {
        background-color: rgba(0, 0, 0, 0);
    }
    to {
        background-color: rgba(0, 0, 0, 0.5);
    }
}

.modal.show .modal-dialog {
    animation: modalSlideIn 0.3s ease-out;
}

.modal.fade .modal-backdrop {
    animation: backdropFade 0.3s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   12. TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    padding: 16px;
    margin-bottom: 10px;
    min-width: 300px;
    animation: toastSlideIn 0.4s ease-out;
}

.toast.hide {
    animation: toastSlideOut 0.4s ease-out forwards;
}

.toast-progress {
    height: 3px;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
    margin-top: 10px;
    animation: toastProgress 3s linear forwards;
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast.info {
    border-left: 4px solid #17a2b8;
}

/* ═══════════════════════════════════════════════════════════════
   13. PAYMENT PROCESSING ANIMATION
   ═══════════════════════════════════════════════════════════════ */

@keyframes paymentProcessing {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes cardFlip {
    0% {
        transform: rotateY(0);
    }
    100% {
        transform: rotateY(360deg);
    }
}

.payment-processing {
    background: linear-gradient(
        90deg,
        rgba(0, 123, 255, 0.1) 25%,
        rgba(0, 123, 255, 0.2) 50%,
        rgba(0, 123, 255, 0.1) 75%
    );
    background-size: 1000px 100%;
    animation: paymentProcessing 2s infinite;
}

.card-flip-animation {
    animation: cardFlip 2s infinite;
}

/* ═══════════════════════════════════════════════════════════════
   14. PROGRESS BAR ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes progressFill {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.progress-fill {
    animation: progressFill 1.5s ease-out;
}

.progress-pulse {
    animation: progressPulse 1s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   15. ALERT / NOTIFICATION ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes alertBounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes alertSlideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-animated {
    animation: alertSlideDown 0.4s ease-out;
}

.alert-bounce {
    animation: alertBounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ═══════════════════════════════════════════════════════════════
   16. FORM ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes inputFocus {
    from {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.5);
    }
    to {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
}

.form-control:focus {
    animation: inputFocus 0.6s ease-out;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

@keyframes checkboxClick {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.checkbox:checked {
    animation: checkboxClick 0.3s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   17. HEART BEAT (untuk favorit/like)
   ═══════════════════════════════════════════════════════════════ */

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(0.9);
    }
    20%, 40%, 60%, 80% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.15);
    }
    70% {
        transform: scale(1.05);
    }
    90% {
        transform: scale(0.95);
    }
}

.heart-beat {
    animation: heartbeat 0.6s ease-in-out;
}

/* ═══════════════════════════════════════════════════════════════
   18. GRADIENT ANIMATION
   ═══════════════════════════════════════════════════════════════ */

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animated {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* ═══════════════════════════════════════════════════════════════
   19. FLOATING ANIMATION (untuk icons atau elements)
   ═══════════════════════════════════════════════════════════════ */

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes floatRotate {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
    }
    100% {
        transform: translateY(0px) rotate(360deg);
    }
}

.float {
    animation: float 3s ease-in-out infinite;
}

.float-rotate {
    animation: floatRotate 4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   20. PAGE TRANSITION
   ═══════════════════════════════════════════════════════════════ */

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.page-enter {
    animation: pageEnter 0.5s ease-out;
}

.page-exit {
    animation: pageExit 0.5s ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */

/* Duration variations */
.anim-fast { animation-duration: 0.3s !important; }
.anim-normal { animation-duration: 0.6s !important; }
.anim-slow { animation-duration: 1s !important; }
.anim-slowest { animation-duration: 1.5s !important; }

/* Delay variations */
.delay-1 { animation-delay: 0.1s !important; }
.delay-2 { animation-delay: 0.2s !important; }
.delay-3 { animation-delay: 0.3s !important; }
.delay-4 { animation-delay: 0.4s !important; }
.delay-5 { animation-delay: 0.5s !important; }

/* Iteration */
.anim-infinite { animation-iteration-count: infinite !important; }
.anim-once { animation-iteration-count: 1 !important; }

/* Fill mode */
.anim-forwards { animation-fill-mode: forwards !important; }
.anim-backwards { animation-fill-mode: backwards !important; }
.anim-both { animation-fill-mode: both !important; }

/* Timing functions */
.ease-linear { animation-timing-function: linear !important; }
.ease-ease { animation-timing-function: ease !important; }
.ease-in { animation-timing-function: ease-in !important; }
.ease-out { animation-timing-function: ease-out !important; }
.ease-in-out { animation-timing-function: ease-in-out !important; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE - REDUCE MOTION for accessibility
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   COMBINED ANIMATIONS - Examples
   ═══════════════════════════════════════════════════════════════ */

/* Success popup */
.success-popup {
    animation: zoomIn 0.5s ease-out, float 2s ease-in-out 0.5s infinite;
}

/* Loading with text */
.loading-text {
    animation: fadeIn 0.5s ease-out;
}

.loading-text .dots {
    animation: bounce 1.4s infinite ease-in-out;
}

/* Error shake */
.error-shake {
    animation: shake 0.5s ease-in-out, alertBounceIn 0.5s ease-out;
}

/* Payment card processing */
.card-processing {
    animation: paymentProcessing 2s infinite, cardFlip 3s infinite;
}
