/* =========================
   Salla Performance + SEO Optimized
   ========================= */

/* ===== 1. Images Optimization ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
  loading: lazy; /* إضافة مهمة! */
}

/* First hero image - load immediately */
.salla-slider:first-of-type img,
.hero:first-of-type img,
.banner:first-of-type img {
  loading: eager !important;
}

/* Prevent layout shift for product grids */
.product img,
.products img,
.product-card img,
.product-item img,
[class*="product"] img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* ===== 2. Fix hero/slider (no black gap) ===== */
.salla-slider,
.hero,
.hero-slider,
.home-slider,
.slider,
.banner,
.main-banner,
.section-banner {
  min-height: 0 !important;
  height: auto !important;
  overflow: hidden !important;
}

/* First hero/slider height */
.salla-slider:first-of-type,
.hero:first-of-type,
.hero-slider:first-of-type,
.home-slider:first-of-type,
.slider:first-of-type,
.banner:first-of-type {
  height: clamp(360px, 70vh, 720px) !important;
}

/* Swiper fill */
.salla-slider:first-of-type .swiper,
.salla-slider:first-of-type .swiper-wrapper,
.salla-slider:first-of-type .swiper-slide {
  height: 100% !important;
}

/* Cover image */
.salla-slider:first-of-type img,
.hero:first-of-type img,
.hero-slider:first-of-type img,
.home-slider:first-of-type img,
.slider:first-of-type img,
.banner:first-of-type img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* ===== 3. Font Optimization (Almarai) ===== */
@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700;800&display=swap');

body {
  font-family: 'Almarai', Arial, sans-serif;
  font-display: swap;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Almarai', Arial, sans-serif;
  font-weight: 700;
}

/* ===== 4. Performance Boost ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Reduce repaints */
.product-card,
.card,
.container {
  contain: layout style paint;
}

/* Optimize buttons */
button,
.btn,
a.button {
  transform: translateZ(0);
  backface-visibility: hidden;
  cursor: pointer;
}

/* Smooth hover effects */
.product-card:hover {
  transform: translateY(-3px);
  transition: transform 0.2s ease;
}

/* ===== 5. Accessibility (تحسين إمكانية الوصول) ===== */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0f766e;
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 100;
}

.skip-to-content:focus {
  top: 0;
}

/* ===== 6. Mobile Optimization ===== */
@media (max-width: 768px) {
  .salla-slider:first-of-type,
  .hero:first-of-type,
  .hero-slider:first-of-type,
  .home-slider:first-of-type,
  .slider:first-of-type,
  .banner:first-of-type {
    height: clamp(300px, 55vh, 520px) !important;
  }
  
  /* Reduce font size for mobile */
  body {
    font-size: 14px;
  }
  
  h1 {
    font-size: 24px;
  }
  
  h2 {
    font-size: 20px;
  }
  
  /* Disable heavy animations on mobile */
  .animated,
  .fade-in,
  .slide-in {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== 7. 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;
  }
}

/* ===== 8. CTA Buttons Enhancement ===== */
.donate-button,
.cta-button,
.btn-primary,
.add-to-cart,
.buy-now {
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  border: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.donate-button:hover,
.cta-button:hover,
.btn-primary:hover {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* ===== 9. Footer Enhancement ===== */
footer {
  background: #1f2937;
  color: #f3f4f6;
  padding: 40px 20px;
}

footer a {
  color: #d1d5db;
  transition: color 0.3s ease;
}

footer a:hover {
  color: #0d9488;
}

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

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

/* ===== 11. Print Styles ===== */
@media print {
  .header,
  .footer,
  .navigation,
  .sidebar {
    display: none;
  }
  
  body {
    color: #000;
    background: #fff;
  }
}