@layer base {
  /* إعدادات التنقل السلس العامة */
  html {
    scroll-behavior: smooth;
    scroll-padding-top: 4rem; /* مسافة من الهيدر */
  }
  
  body {
    font-family: 'Cairo', sans-serif;
    /* تحسين الأداء للحركات */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
  }
  
  /* RTL Support and Right Alignment */
  [dir="rtl"] {
    direction: rtl;
    text-align: right;
  }
  
  [dir="rtl"] input,
  [dir="rtl"] textarea,
  [dir="rtl"] select {
    text-align: right;
  }
  
  [dir="rtl"] .text-right {
    text-align: right;
  }
  
  [dir="rtl"] .text-left {
    text-align: left;
  }
  
  /* Form elements RTL optimization */
  [dir="rtl"] input::placeholder,
  [dir="rtl"] textarea::placeholder {
    text-align: right;
  }
  
  /* Select dropdown RTL */
  [dir="rtl"] select option {
    text-align: right;
  }
  
  /* Better RTL spacing */
  [dir="rtl"] .space-x-6 > * + * {
    margin-right: 1.5rem;
    margin-left: 0;
  }
  
  [dir="rtl"] .space-y-6 > * + * {
    margin-top: 1.5rem;
    margin-bottom: 0;
  }
  
  /* ========================================= */
  /*          تحسينات الحركات السلسة           */
  /* ========================================= */
  
  /* تحسين الحركات الانتقالية للعناصر التفاعلية */
  a, button, input, select, textarea {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* حركات الهوفر المحسنة */
  .hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  }
  
  /* حركات الظهور */
  @keyframes fadeInUp {
    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 scaleIn {
    from {
      opacity: 0;
      transform: scale(0.9);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
  
  /* فئات الحركة */
  .animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
  }
  
  .animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out forwards;
  }
  
  .animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out forwards;
  }
  
  .animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
  }
  
  /* تأخير الحركات */
  .animate-delay-100 { animation-delay: 0.1s; }
  .animate-delay-200 { animation-delay: 0.2s; }
  .animate-delay-300 { animation-delay: 0.3s; }
  .animate-delay-400 { animation-delay: 0.4s; }
  .animate-delay-500 { animation-delay: 0.5s; }
  
  /* حالة الانتظار للحركات */
  .animate-on-scroll {
    opacity: 0;
  }
  
  .animate-on-scroll.animate {
    opacity: 1;
  }
  
  /* تحسينات الأداء للحركات */
  .will-animate {
    will-change: transform, opacity;
  }
  
  /* تحسين حركة الأزرار */
  .btn-smooth {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .btn-smooth::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
  }
  
  .btn-smooth:hover::before {
    left: 100%;
  }
  
  /* تحسين حركة الكروت */
  .card-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
    transform: translateZ(0);
  }
  
  .card-smooth:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  }
  
  /* تحسين الحركة للعناصر العائمة */
  .float-animation {
    animation: float 3s ease-in-out infinite;
  }
  
  @keyframes float {
    0%, 100% {
      transform: translateY(0px);
    }
    50% {
      transform: translateY(-10px);
    }
  }
  
  /* تحسين حركة التمرير للأشرطة */
  .progress-bar {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* تحسين الحركة للنماذج */
  .form-smooth input:focus,
  .form-smooth textarea:focus,
  .form-smooth select:focus {
    transform: scale(1.02);
    transition: all 0.2s ease;
  }
  
  /* إزالة الحركات للمستخدمين الذين يفضلون تقليلها */
  @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;
    }
  }
  
  /* تحسينات أثناء التمرير */
  .scrolling * {
    pointer-events: none;
  }
  
  .scrolling .will-animate {
    will-change: auto;
  }
  
  /* تحسين الأداء للعناصر المتحركة */
  .animate-on-scroll {
    contain: layout style paint;
  }
  
  .animate-on-scroll.animate {
    contain: none;
  }
  
  /* تحسين عرض الصور */
  img {
    content-visibility: auto;
    contain-intrinsic-size: 300px 200px;
  }
  
  /* تحسين الخطوط */
  .font-cairo {
    font-display: swap;
  }
  
  /* تحسين التمرير على الأجهزة اللمسية */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* تحسين الحركات للأجهزة الضعيفة */
  @media (prefers-reduced-motion: no-preference) and (max-width: 768px) {
    .animate-fade-in-up,
    .animate-fade-in-left,
    .animate-fade-in-right,
    .animate-scale-in {
      animation-duration: 0.4s;
    }
  }
  
  /* تحسين البطارية للأجهزة المحمولة */
  @media (max-width: 768px) {
    .float-animation {
      animation: none;
    }
    
    .hover-lift:hover {
      transform: none;
    }
    
    .card-smooth:hover {
      transform: none;
    }
  }
}
