/* ========================================
   انیمیشن‌های جذاب و پویا برای تمام صفحات
   بر اساس animations_megaprompt.json
   ======================================== */

/* تنظیمات عمومی */
* {
    --animation-duration: 0.6s;
    --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --animation-delay: 0s;
}

/* احترام به تنظیمات کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.3s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.3s !important;
    }
}

/* بهینه‌سازی عملکرد با GPU */
.anim-gpu {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ========================================
   KEYFRAMES - انیمیشن‌های پایه
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-8px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(220, 53, 69, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(220, 53, 69, 0.8), 0 0 30px rgba(220, 53, 69, 0.6);
    }
}

/* ========================================
   کلاس‌های انیمیشن عمومی
   ======================================== */

.anim-fade-in {
    animation: fadeIn 0.8s ease-out;
}

.anim-fade-in-up {
    animation: fadeInUp 0.8s ease-out;
}

.anim-fade-in-down {
    animation: fadeInDown 0.8s ease-out;
}

.anim-fade-in-left {
    animation: fadeInLeft 0.8s ease-out;
}

.anim-fade-in-right {
    animation: fadeInRight 0.8s ease-out;
}

.anim-slide-in-left {
    animation: slideInLeft 0.8s ease-out;
}

.anim-slide-in-right {
    animation: slideInRight 0.8s ease-out;
}

.anim-slide-in-up {
    animation: slideInUp 0.8s ease-out;
}

.anim-slide-in-down {
    animation: slideInDown 0.8s ease-out;
}

.anim-scale-in {
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.anim-rotate-in {
    animation: rotateIn 0.7s ease-out;
}

.anim-bounce {
    animation: bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.anim-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

.anim-shake {
    animation: shake 0.5s ease-in-out;
}

.anim-spin {
    animation: spin 1s linear infinite;
}

.anim-glow {
    animation: glow 2s ease-in-out infinite;
}

/* ========================================
   انیمیشن‌های صفحه
   ======================================== */

.page-fade-in {
    animation: fadeInUp 0.5s ease-out;
}

.page-slide-in {
    animation: slideInRight 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   انیمیشن‌های اسکرول
   ======================================== */

.scroll-animate {
    opacity: 0;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.scroll-animate.animated {
    opacity: 1;
}

.scroll-fade-in-up {
    transform: translateY(40px);
}

.scroll-fade-in-up.animated {
    transform: translateY(0);
}

.scroll-fade-in-left {
    transform: translateX(-50px);
}

.scroll-fade-in-left.animated {
    transform: translateX(0);
}

.scroll-fade-in-right {
    transform: translateX(50px);
}

.scroll-fade-in-right.animated {
    transform: translateX(0);
}

.scroll-scale-in {
    transform: scale(0.8);
}

.scroll-scale-in.animated {
    transform: scale(1);
}

.scroll-rotate-in {
    transform: rotate(-10deg) scale(0.9);
}

.scroll-rotate-in.animated {
    transform: rotate(0deg) scale(1);
}

/* ========================================
   انیمیشن‌های هاور
   ======================================== */

.hover-lift-up {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.hover-lift-up:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.hover-scale-up {
    transition: transform 0.3s ease-out;
}

.hover-scale-up:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow 0.3s ease-out;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.5);
}

.hover-rotate {
    transition: transform 0.3s ease-out;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

.hover-shimmer {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

/* ========================================
   انیمیشن‌های لودینگ
   ======================================== */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #dc3545;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-loader {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.loading-dots {
    display: inline-flex;
    gap: 8px;
}

.loading-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #dc3545;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ========================================
   انیمیشن‌های تعاملی
   ======================================== */

.button-click {
    transition: transform 0.2s ease-out;
}

.button-click:active {
    transform: scale(0.95);
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease-out, height 0.6s ease-out, opacity 0.6s ease-out;
}

.ripple-effect.active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* ========================================
   انیمیشن‌های کامپوننت‌ها
   ======================================== */

/* Navbar */
.navbar {
    animation: fadeInDown 0.5s ease-out;
}

.navbar.sticky {
    animation: slideInDown 0.3s ease-out;
}

/* Footer */
.footer {
    animation: fadeInUp 0.6s ease-out;
}

/* Modals */
.modal-content {
    animation: scaleIn 0.3s ease-out;
}

.modal-backdrop {
    animation: fadeIn 0.3s ease-out;
}

/* Alerts */
.alert,
.notification {
    animation: slideInRight 0.4s ease-out;
}

.alert.fade-out,
.notification.fade-out {
    animation: slideOutRight 0.3s ease-out;
}

/* Tabs */
.tab-pane {
    animation: fadeIn 0.3s ease-out;
}

/* Dropdowns */
.dropdown-menu {
    animation: fadeInDown 0.3s ease-out;
}

.dropdown-item {
    transition: transform 0.2s ease-out, background-color 0.2s ease-out;
}

.dropdown-item:hover {
    transform: translateY(-2px);
}

/* Tooltips */
.tooltip {
    animation: fadeInUp 0.2s ease-out;
}

/* Forms */
.form-control:focus,
.input:focus {
    transition: box-shadow 0.3s ease-out;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.is-invalid {
    animation: shake 0.5s ease-in-out;
}

.is-valid {
    animation: bounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Tables */
tbody tr {
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Cards */
.card,
.product-card,
.category-card {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.card:hover,
.product-card:hover,
.category-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Buttons */
.btn,
button {
    transition: transform 0.2s ease-out, box-shadow 0.3s ease-out;
}

.btn:hover,
button:hover {
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.5);
}

.btn:active,
button:active {
    transform: scale(0.95);
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Images */
img {
    animation: fadeIn 0.5s ease-out;
    transition: transform 0.3s ease-out;
}

img:hover {
    transform: scale(1.05);
}

img.lazy {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

img.lazy.loaded {
    opacity: 1;
}

/* Badges */
.badge,
.tag {
    animation: bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================
   انیمیشن‌های سفارشی
   ======================================== */

/* Product Card Hover */
.product-card-hover {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card-hover:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Cart Item Add */
@keyframes cartItemAdd {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.cart-item-add {
    animation: cartItemAdd 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Notification Slide */
.notification-slide {
    animation: slideInRight 0.4s ease-out;
}

.notification-slide.fade-out {
    animation: slideOutRight 0.3s ease-out;
}

/* Search Expand */
.search-expand {
    transition: width 0.3s ease-out, opacity 0.3s ease-out;
}

.search-expand:focus {
    width: 400px;
    opacity: 1;
}

/* ========================================
   انیمیشن‌های استاگر (تاخیر متوالی)
   ======================================== */

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }

/* ========================================
   بهینه‌سازی عملکرد
   ======================================== */

.anim-optimize {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ========================================
   رسپانسیو
   ======================================== */

@media (max-width: 768px) {
    .scroll-animate {
        opacity: 1;
        transform: none;
    }
    
    .card:hover,
    .product-card:hover,
    .category-card:hover {
        transform: translateY(-5px) scale(1.01);
    }
}

