/*
==============================================
  Animations & Effects - التأثيرات والأنيميشن
  د. نجاة فرادي - المنصة الرسمية
==============================================
*/

/* ========================================
   Keyframe Animations - حركات الأنيميشن
======================================== */

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Right (for RTL) */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Left (for RTL) */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Float */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(20px, -20px) rotate(3deg);
    }
    66% {
        transform: translate(-15px, 15px) rotate(-3deg);
    }
}

/* Rotate */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Blink */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* Shimmer */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Slide In Modal */
@keyframes slideInModal {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Spin Loader */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Wave */
@keyframes wave {
    0%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(1.5);
    }
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(233, 168, 40, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(233, 168, 40, 0.6);
    }
}

/* ========================================
   Animation Classes - أصناف الأنيميشن
======================================== */

/* Fade In Animations */
.animate-fade-in-up {
    animation: fadeInUp 0.8s ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.8s ease forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s ease forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s ease forwards;
}

.animate-scale-in {
    animation: scaleIn 0.6s ease forwards;
}

/* Continuous Animations */
.animate-pulse {
    animation: pulse 2s ease infinite;
}

.animate-bounce {
    animation: bounce 2s ease infinite;
}

.animate-float {
    animation: float 20s ease-in-out infinite;
}

.animate-rotate {
    animation: rotate 30s linear infinite;
}

.animate-blink {
    animation: blink 2s ease infinite;
}

.animate-glow {
    animation: glowPulse 2s ease infinite;
}

/* Animation Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* ========================================
   Scroll Reveal - الظهور عند التمرير
======================================== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}

.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ========================================
   Hover Effects - تأثيرات التمرير
======================================== */

/* Lift Effect */
.hover-lift {
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Scale Effect */
.hover-scale {
    transition: transform 0.2s ease-out;
}

.hover-scale:hover {
    transform: scale(1.03);
}

/* Glow Effect */
.hover-glow {
    transition: box-shadow 0.2s ease-out;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(233, 168, 40, 0.3);
}

/* Shine Effect */
.hover-shine {
    position: relative;
    overflow: hidden;
}

.hover-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.6s ease;
}

.hover-shine:hover::before {
    left: 100%;
}

/* Underline Effect */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--primary-gold);
    transition: width 0.4s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* ========================================
   Loading States - حالات التحميل
======================================== */

/* ========================================
   Loader - شاشة التحميل الاحترافية
   تصميم جديد مع حلقة متوهجة
======================================== */

/* Keyframes للـ Loader */
@keyframes loaderGlow {
    0%, 100% {
        box-shadow: 
            0 0 20px rgba(233, 168, 40, 0.4),
            0 0 40px rgba(233, 168, 40, 0.2),
            0 0 60px rgba(233, 168, 40, 0.1);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(233, 168, 40, 0.6),
            0 0 60px rgba(233, 168, 40, 0.4),
            0 0 90px rgba(233, 168, 40, 0.2);
    }
}

@keyframes loaderRing {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes loaderProgress {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

@keyframes loaderBreathing {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Loader Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1E5A8A 0%, #164666 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loader, 9999);
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

.loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Logo Container with Glowing Ring */
.loader-logo-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rotating Ring */
.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary-gold, #E9A828);
    border-right-color: var(--primary-gold, #E9A828);
    animation: loaderRing 1.5s linear infinite;
}

.loader-ring::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 3px solid rgba(233, 168, 40, 0.2);
}

/* Logo */
.loader-logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-gold, #E9A828);
    animation: loaderBreathing 2s ease-in-out infinite, loaderGlow 2s ease-in-out infinite;
    z-index: 2;
}

/* Text */
.loader-text {
    font-family: var(--font-heading, 'Markazi Text', serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 1px;
    margin: 0;
}

.loader-subtitle {
    font-family: var(--font-primary, 'Markazi Text', sans-serif);
    font-size: 1rem;
    color: var(--primary-gold, #E9A828);
    margin: -0.5rem 0 0 0;
    font-weight: 500;
}

/* Progress Bar */
.loader-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-gold, #E9A828), #F4C04A);
    border-radius: 10px;
    animation: loaderProgress 2s ease-out forwards;
}

/* Dots Animation (Alternative) */
.loader-dots {
    display: flex;
    gap: 8px;
    margin-top: 0.5rem;
}

.loader-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-gold, #E9A828);
    border-radius: 50%;
    animation: loaderBreathing 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 25%,
        var(--gray-100) 50%,
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--space-sm);
}

.skeleton-heading {
    height: 2rem;
    width: 60%;
    margin-bottom: var(--space-md);
}

.skeleton-image {
    height: 200px;
    margin-bottom: var(--space-md);
}

/* ========================================
   Special Effects - تأثيرات خاصة
======================================== */

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass Effect - محسّن للأداء */
.glass {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Gradient Border */
.gradient-border {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-gold));
    border-radius: inherit;
    z-index: -1;
}

/* Decorative Circle */
.deco-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(233, 168, 40, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

/* Background Pattern */
.pattern-bg {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232B7CB4' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ========================================
   Page Transitions - انتقالات الصفحات
======================================== */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-exit {
    opacity: 1;
}

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

/* ========================================
   Reduced Motion - تقليل الحركة
======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reveal,
    .reveal-right,
    .reveal-left,
    .reveal-scale {
        opacity: 1;
        transform: none;
    }
}
