/* ========================================================
   NUSA STORE - ANIMATION PACK
   Tambah efek hidup tanpa ubah layout/posisi
   ======================================================== */

/* ========== 1. FADE-IN PAGE LOAD ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.9); }
    50% { transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

/* Body fade-in */
body {
    animation: fadeIn 0.5s ease-out;
}

/* ========== 2. STAGGERED CARD ANIMATIONS ========== */
.card, .box, .stat-box, .trx-item, .user-card, 
.product-card, .product-option-card, .nominal-card,
.ppob-item, .category-card, .service-card {
    animation: popIn 0.5s ease-out backwards;
}

/* Stagger delay per card (biar muncul bergantian) */
.card:nth-child(1), .box:nth-child(1), .stat-box:nth-child(1),
.product-card:nth-child(1), .nominal-card:nth-child(1), .ppob-item:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2), .box:nth-child(2), .stat-box:nth-child(2),
.product-card:nth-child(2), .nominal-card:nth-child(2), .ppob-item:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3), .box:nth-child(3), .stat-box:nth-child(3),
.product-card:nth-child(3), .nominal-card:nth-child(3), .ppob-item:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4), .box:nth-child(4), .stat-box:nth-child(4),
.product-card:nth-child(4), .nominal-card:nth-child(4), .ppob-item:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5), .box:nth-child(5), .stat-box:nth-child(5),
.product-card:nth-child(5), .nominal-card:nth-child(5), .ppob-item:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6), .box:nth-child(6), .stat-box:nth-child(6),
.product-card:nth-child(6), .nominal-card:nth-child(6), .ppob-item:nth-child(6) { animation-delay: 0.30s; }
.card:nth-child(7), .product-card:nth-child(7), .ppob-item:nth-child(7) { animation-delay: 0.35s; }
.card:nth-child(8), .product-card:nth-child(8), .ppob-item:nth-child(8) { animation-delay: 0.40s; }
.card:nth-child(9), .product-card:nth-child(9), .ppob-item:nth-child(9) { animation-delay: 0.45s; }

/* ========== 3. BUTTON HOVER & CLICK ========== */
.btn, .btn-primary, button, .bottom-nav-item, 
.cat-chip, .provider-chip, .ppob-item, .nav-item {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-primary:hover, button[type="submit"]:not(:disabled):hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 28px rgba(15, 118, 110, 0.35) !important;
}

.btn-primary:active, button[type="submit"]:not(:disabled):active {
    transform: translateY(0) scale(0.98);
}

.bottom-nav-item:hover {
    transform: translateY(-2px);
}

.bottom-nav-item.active i {
    animation: bounce 0.6s ease-out;
}

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

/* ========== 4. CARD HOVER LIFT ========== */
.product-card:hover, .product-option-card:hover,
.nominal-card:hover, .ppob-item:hover, .card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(15, 118, 110, 0.15) !important;
}

/* ========== 5. INPUT FOCUS GLOW ========== */
input, textarea, select, .form-control {
    transition: all 0.25s ease !important;
}

input:focus, textarea:focus, select:focus, .form-control:focus {
    transform: scale(1.005);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12), 0 2px 8px rgba(15, 118, 110, 0.1) !important;
}

/* ========== 6. GRADIENT SHIFT (Header) ========== */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-header, .header, .hdr {
    background-size: 200% 200% !important;
    animation: gradientShift 8s ease infinite;
}

/* ========== 7. SALDO COUNT-UP PULSE ========== */
@keyframes pulseGlow {
    0%, 100% { 
        text-shadow: 0 0 0 rgba(15, 118, 110, 0);
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 20px rgba(15, 118, 110, 0.3);
        transform: scale(1.02);
    }
}

.balance-amount, .balance-value, #saldo-digiflazz {
    animation: pulseGlow 3s ease-in-out infinite;
}

/* ========== 8. LOADING SPINNER SMOOTH ========== */
@keyframes spinSmooth {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fa-spin, .spinner, .loading {
    animation: spinSmooth 1s linear infinite !important;
}

/* ========== 9. ALERT SLIDE DOWN ========== */
@keyframes alertSlide {
    from { 
        opacity: 0; 
        transform: translateY(-20px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

.alert, .flash-message {
    animation: alertSlide 0.4s ease-out;
}

/* ========== 10. FLOATING ICONS ========== */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.ppob-icon-wrapper, .service-icon, .category-icon,
.icon-box, .ico {
    animation: float 3s ease-in-out infinite;
}

/* Delay berbeda biar tidak kompak */
.ppob-item:nth-child(1) .ppob-icon-wrapper { animation-delay: 0s; }
.ppob-item:nth-child(2) .ppob-icon-wrapper { animation-delay: 0.2s; }
.ppob-item:nth-child(3) .ppob-icon-wrapper { animation-delay: 0.4s; }
.ppob-item:nth-child(4) .ppob-icon-wrapper { animation-delay: 0.6s; }
.ppob-item:nth-child(5) .ppob-icon-wrapper { animation-delay: 0.8s; }
.ppob-item:nth-child(6) .ppob-icon-wrapper { animation-delay: 1.0s; }

/* ========== 11. CHECKMARK POP ========== */
@keyframes checkPop {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.product-card.selected::after, 
.product-option-card.selected::after,
.nominal-card.selected::after {
    animation: checkPop 0.4s ease-out;
}

/* ========== 12. RIPPLE EFFECT ON BUTTONS ========== */
@keyframes ripple {
    from { 
        transform: scale(0); 
        opacity: 0.6;
    }
    to { 
        transform: scale(4); 
        opacity: 0;
    }
}

.btn-primary, button[type="submit"] {
    position: relative;
    overflow: hidden;
}

/* ========== 13. ICON WOBBLE ========== */
@keyframes wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

.bottom-nav-item:hover i {
    animation: wobble 0.5s ease-in-out;
}

/* ========== 14. SHIMMER ON BUTTON ========== */
@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.btn-primary::before, button[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn-primary:hover::before, button[type="submit"]:hover::before {
    left: 100%;
}

/* ========== 15. BADGE PULSE ========== */
@keyframes badgePulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.badge-warning, .badge-pending, .status-pending {
    animation: badgePulse 2s ease-in-out infinite;
}

/* ========== 16. SMOOTH SCROLL ========== */
html {
    scroll-behavior: smooth;
}

/* ========== 17. TAB SWITCH ANIMATION ========== */
.tab, .tab-item, .cat-chip, .provider-chip {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.tab.active, .tab-item.active {
    animation: popIn 0.3s ease-out;
}

/* ========== 18. TRANSACTION ITEM HOVER ========== */
.trx-item, .riwayat-item, .transaction-item {
    transition: all 0.25s ease !important;
}

.trx-item:hover, .riwayat-item:hover {
    transform: translateX(4px);
    border-color: #14b8a6 !important;
    background: #f0fdfa !important;
}

/* ========== 19. SKELETON LOADING ========== */
@keyframes skeleton {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton, .loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
}

/* ========== 20. NOTIFICATION BELL SHAKE ========== */
@keyframes bellShake {
    0%, 100% { transform: rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-10deg); }
    20%, 40%, 60%, 80% { transform: rotate(10deg); }
}

.icon-btn:hover i.fa-bell,
.fa-bell:hover {
    animation: bellShake 0.8s ease-in-out;
}

/* ========== 21. HEADER TEXT SLIDE IN ========== */
.greet, .uname, .hdr .title, .h1-title {
    animation: slideInLeft 0.6s ease-out;
}

/* ========== 22. FLOATING SHADOW ========== */
@keyframes floatShadow {
    0%, 100% { box-shadow: 0 4px 12px rgba(15, 118, 110, 0.15); }
    50% { box-shadow: 0 8px 25px rgba(15, 118, 110, 0.25); }
}

.balance-card, .agent-balance-card, .admin-widget {
    animation: floatShadow 4s ease-in-out infinite;
}

/* ========== 23. GRADIENT TEXT ANIMATION ========== */
@keyframes textGradient {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

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

/* ========== 25. MOBILE OPTIMIZATION ========== */
@media (max-width: 480px) {
    /* Kurangi animasi berat di HP biar tidak lag */
    .app-header, .header, .hdr {
        animation: none;
        background-size: 100% 100%;
    }
    
    .balance-card, .agent-balance-card, .admin-widget {
        animation: none;
    }
}
