/**
 * ShopNoi Animations & Micro-interactions
 * Enhanced User Experience with smooth animations
 * Version: 1.0
 */

/* ===== PAGE LOAD ANIMATIONS ===== */
.animate-on-load {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Staggered animations for product grids */
.prod-item:nth-child(1) { animation-delay: 0.05s; }
.prod-item:nth-child(2) { animation-delay: 0.1s; }
.prod-item:nth-child(3) { animation-delay: 0.15s; }
.prod-item:nth-child(4) { animation-delay: 0.2s; }
.prod-item:nth-child(5) { animation-delay: 0.25s; }
.prod-item:nth-child(6) { animation-delay: 0.3s; }
.prod-item:nth-child(7) { animation-delay: 0.35s; }
.prod-item:nth-child(8) { animation-delay: 0.4s; }
.prod-item:nth-child(9) { animation-delay: 0.45s; }
.prod-item:nth-child(10) { animation-delay: 0.5s; }
.prod-item:nth-child(11) { animation-delay: 0.55s; }
.prod-item:nth-child(12) { animation-delay: 0.6s; }

/* Apply initial state for animation */
.prod-item {
    opacity: 0;
    transform: translateY(20px);
    animation: cardReveal 0.5s ease-out forwards;
}

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

/* ===== BUTTON RIPPLE EFFECT ===== */
.btn-buy,
.buy-btn-box4,
.btn-more,
.more-btn-box4,
.btn-category-home {
    position: relative;
    overflow: hidden;
}

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

.btn-buy:active::after,
.buy-btn-box4:active::after {
    width: 300px;
    height: 300px;
}

/* ===== CARD HOVER EFFECTS ===== */
.product-box4 {
    position: relative;
}

.product-box4::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    background: linear-gradient(
        135deg,
        rgba(8, 145, 178, 0.02) 0%,
        rgba(34, 211, 238, 0.02) 100%
    );
}

.product-box4:hover::after {
    opacity: 1;
}

/* Product image zoom on hover */
.feature-media img,
.product-thumb img {
    transition: transform 0.4s ease;
}

.feature-card:hover .feature-media img,
.product-box4:hover .product-thumb img {
    transform: scale(1.05);
}

/* ===== ICON ANIMATIONS ===== */
.feature-desc i,
.product-body-box4 p i {
    transition: transform 0.3s ease;
}

.feature-card:hover .feature-desc i {
    transform: translateX(5px);
}

.product-body-box4 p:hover i {
    transform: scale(1.2);
}

/* Cart icon bounce */
.btn-buy i,
.buy-btn-box4 i {
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.btn-buy:hover i,
.buy-btn-box4:hover i {
    transform: scale(1.2);
}

/* ===== PRICE HIGHLIGHT ===== */
.feature-price span,
.price-box4 strong,
.proce-box4-not-discount {
    display: inline-block;
    transition: transform 0.3s ease;
}

.feature-card:hover .feature-price span,
.product-box4:hover .price-box4 strong,
.product-box4:hover .proce-box4-not-discount {
    transform: scale(1.05);
}

/* ===== BADGE PULSE ===== */
.label-text.off {
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    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);
    }
}

/* ===== STOCK BADGE ANIMATION ===== */
.badge.bg-primary {
    position: relative;
    overflow: hidden;
}

.badge.bg-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: badgeShine 3s infinite;
}

@keyframes badgeShine {
    0%, 100% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
}

/* ===== NAVIGATION ANIMATIONS ===== */
.navbar-nav .nav-link {
    position: relative;
}

.navbar-nav .nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.3s ease, left 0.3s ease;
}

.navbar-nav .nav-link:hover::before {
    width: 100%;
    left: 0;
}

/* Mobile menu animation */
.navbar-collapse {
    transition: all 0.3s ease;
}

.navbar-collapse.show {
    animation: slideDown 0.3s ease forwards;
}

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

/* ===== MODAL ANIMATIONS ===== */
.modal.fade .modal-dialog {
    transform: scale(0.9) translateY(-50px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== SCROLL REVEAL ===== */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===== TOOLTIP ANIMATIONS ===== */
[data-toggle="tooltip"] {
    position: relative;
}

[data-toggle="tooltip"]::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: var(--gray-800);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
}

[data-toggle="tooltip"]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* ===== SUCCESS / ERROR FEEDBACK ===== */
.feedback-success {
    animation: successPop 0.5s ease;
}

@keyframes successPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.feedback-error {
    animation: errorShake 0.5s ease;
}

@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-10px);
    }
    40%, 80% {
        transform: translateX(10px);
    }
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.fab-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(8, 145, 178, 0.4);
}

.fab-button i {
    font-size: 24px;
}

/* ===== PROGRESS BAR ===== */
.progress-animated {
    overflow: hidden;
    position: relative;
}

.progress-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    to {
        left: 100%;
    }
}

/* ===== NOTIFICATION BADGE ===== */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: notificationPop 0.3s ease;
}

@keyframes notificationPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ===== SKELETON LOADING ===== */
.skeleton-box {
    background: linear-gradient(
        90deg,
        var(--gray-100) 25%,
        var(--gray-200) 50%,
        var(--gray-100) 75%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 14px;
    margin: 8px 0;
}

.skeleton-title {
    height: 24px;
    width: 70%;
}

.skeleton-image {
    height: 200px;
    width: 100%;
}

/* ===== ACCESSIBILITY - REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .prod-item {
        opacity: 1;
        transform: none;
    }
    
    .label-text.off {
        animation: none;
    }
    
    .badge.bg-primary::before {
        animation: none;
    }
}

/* ===== FOCUS VISIBLE STATES ===== */
.btn-buy:focus-visible,
.buy-btn-box4:focus-visible,
.btn-more:focus-visible,
.more-btn-box4:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

/* ===== SMOOTH SCROLL INDICATOR ===== */
.scroll-indicator {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-primary);
    z-index: 9999;
    transition: width 0.1s ease;
}

/* ===== PAGE TRANSITION ===== */
.page-transition-enter {
    opacity: 0;
}

.page-transition-enter-active {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.page-transition-exit {
    opacity: 1;
}

.page-transition-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}
