/* =========================
   Root Variables & Themes
   ========================= */
:root {
  --bg: #f8f7f5;
  --surface: #ffffff;
  --text: #232323;
  --muted: #6b7280;
  --primary: #D8B384;
  --primary-600: #c79a6b;
  --primary-700: #b88456;
  --accent: #0f172a;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  --container: 1200px;
  --radius: 16px;
  --shadow-sm: 0 2px 6px rgba(0,0,0,.05);
  --shadow-md: 0 6px 18px rgba(0,0,0,.08);
  --shadow-lg: 0 14px 34px rgba(0,0,0,.12);

  --font: "Tajawal", system-ui;
  --fs-1: clamp(2rem, 1.3rem + 2vw, 3rem);
  --fs-2: clamp(1.25rem, 1.1rem + .5vw, 1.75rem);
  --fs-3: 1.125rem;
  --fs-4: .95rem;

  --ease: cubic-bezier(.2,.7,.2,1);
  --t-fast: .18s var(--ease);
  --t: .3s var(--ease);
  --t-slow: .6s var(--ease);

  --header-h: 74px;
  --dropdown-hide-delay: 20s;
}

/* تحسين السرعة: الصور Lazy */
img { display: block; max-width: 100%; height: auto; content-visibility: auto; }

/* =========================
   Animations & Effects
   ========================= */
.fade-in { opacity: 0; transform: translateY(10px); animation: fadeIn .6s forwards; }
@keyframes fadeIn { to { opacity: 1; transform: none; } }

.scale-hover { transition: transform var(--t), box-shadow var(--t); }
.scale-hover:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }

/* =========================
   Buttons (مع تحسين تفاعل)
   ========================= */
.btn { cursor: pointer; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 800; transition: transform var(--t-fast), background var(--t), color var(--t); display: inline-flex; align-items: center; gap: 10px; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--primary); color: #1b1b1b; box-shadow: 0 6px 18px color-mix(in oklab, var(--primary), black 15%); }
.btn--primary:hover { background: var(--primary-600); }
.btn--outline { background: transparent; border: 1px solid var(--primary); color: var(--accent); }
.btn--outline:hover { background: color-mix(in oklab, var(--primary), white 85%); }

/* =========================
   Performance Tweaks
   ========================= */
/* تقليل الظلال على الموبايل لتسريع */
@media (max-width: 640px) {
  :root { --shadow-md: none; --shadow-lg: none; }
  .btn { padding: 10px 16px; font-size: .95rem; }
}

/* =========================
   Elegant Footer
   ========================= */
.footer { background: var(--surface); border-top: 1px solid rgba(0,0,0,.06); margin-top: 40px; }
.footer .inner { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 20px; padding: clamp(24px,4vw,48px); }
.footer .title { font-weight: 800; color: var(--accent); margin-bottom: 12px; }
.footer a { color: var(--text); opacity: .8; transition: color var(--t); }
.footer a:hover { opacity: 1; color: var(--primary-700); }
.footer .bottom { text-align: center; padding: 14px; font-size: .9rem; color: var(--muted); border-top: 1px solid rgba(0,0,0,.06); }

/* =========================
   Quick Speed Hacks
   ========================= */
/* استخدم will-change لأزرار التحويم */
.btn, .card, .nav a { will-change: transform, box-shadow; }
/* preload critical fonts/images من HTML */


/* =========================
   Performance & Elegance Add‑ons (v1.1)
   ========================= */

/* 1) CLS & Rendering Optimizations */
/* ملاحظات HTML (اختياري):
   - استخدم loading="lazy" و decoding="async" للصور، و fetchpriority="high" للصورة الأساسية.
   - حدّد width/height للصور لتثبيت الأبعاد ومنع اهتزاز التخطيط. */

/* content-visibility لتسريع أول رسم الصفحة على الصفحات الطويلة */
@supports (content-visibility: auto) {
  .defer, section, .card, .cart-item { content-visibility: auto; contain-intrinsic-size: 800px 1000px; }
}

/* إجبار الحاويات الثقيلة على إنشاء سياق رسم مستقل لتخفيف التكلفة */
.heavy, .hero, .gallery .main, .modal { will-change: transform, opacity; }

/* 2) Blur‑Up Images (يحتاج إضافة class="blur-up is-loaded" للصور عند اكتمال التحميل عبر JS خفيف) */
.blur-up { filter: blur(12px); opacity: .7; transition: filter var(--t-slow), opacity var(--t-slow); }
.blur-up.is-loaded { filter: blur(0); opacity: 1; }

/* 3) Skeleton Shimmer */
.skeleton { position: relative; overflow: hidden; background: #eee; border-radius: 12px; }
.skeleton::after { content: ""; position: absolute; inset: 0; translate: -100% 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); animation: shimmer 1.6s infinite; }
@keyframes shimmer { to { translate: 100% 0; } }

/* 4) Reveal on Scroll (أنيق وخفيف) */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity var(--t), transform var(--t); }
.reveal.is-visible { opacity: 1; transform: none; }

/* 5) Micro‑interactions & Polish */
.card .media img { transition: transform var(--t); }
.card:hover .media img { transform: scale(1.03); }

/* قص العناوين الطويلة بسطرين بدون جداول */
.line-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* أزرار إضافية */
.btn--ghost { background: transparent; border: 0; color: var(--accent); }
.btn--danger { background: color-mix(in oklab, var(--danger), white 10%); color: #fff; }
.btn--success { background: color-mix(in oklab, var(--success), white 10%); color: #fff; }

/* بادجات إضافية */
.badge.-new { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.badge.-hot { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.-sale { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* 6) Sticky Add‑to‑Cart (موبايل) */
.sticky-atc { position: sticky; bottom: 0; z-index: 40; background: color-mix(in oklab, var(--surface), white 10%); backdrop-filter: blur(6px) saturate(140%); padding: 10px; border-top: 1px solid rgba(0,0,0,.06); box-shadow: 0 -8px 20px rgba(0,0,0,.06); }
.sticky-atc .inner { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
@media (min-width: 992px) { .sticky-atc { display: none; } }

/* 7) Floating Action Button (CTA سريع) */
.fab-cta { position: fixed; inset-inline-start: 16px; bottom: 16px; z-index: 70; }
.fab-cta .btn { border-radius: 999px; padding: 14px 18px; box-shadow: var(--shadow-lg); }

/* زر الرجوع للأعلى (يحتاج JS لإظهار/إخفاء) */
.to-top { position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 70; display: none; }
.to-top.show { display: inline-grid; }

/* 8) Modal خفيف للـ Quick‑View */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); opacity: 0; visibility: hidden; transition: opacity var(--t), visibility 0s linear .3s; z-index: 90; }
.modal.open { opacity: 1; visibility: visible; transition-delay: 0s; }
.modal .panel { width: min(720px, 94vw); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal .panel .head { padding: 12px 16px; border-bottom: 1px solid rgba(0,0,0,.06); display: flex; justify-content: space-between; align-items: center; }
.modal .panel .body { padding: 16px; max-height: min(80vh, 720px); overflow: auto; }

/* 9) تقييم النجوم بدون صور (CSS فقط) */
.stars { --rating: 4.6; --size: 16px; --fill: #f59e0b; position: relative; display: inline-block; font-size: var(--size); line-height: 1; }
.stars::before { content: "★★★★★"; letter-spacing: 2px; background: linear-gradient(90deg, var(--fill) calc(var(--rating) / 5 * 100%), #ddd 0); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* 10) شبكات مرنة تلقائية التعبئة */
.grid-auto-fit { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* 11) دعم الوضع الليلي من النظام */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #0f141b;
    --text: #e7e7e7;
    --muted: #94a3b8;
    --accent: #e5e7eb;
    --shadow-sm: 0 2px 10px rgba(0,0,0,.3);
    --shadow-md: 0 10px 30px rgba(0,0,0,.35);
    --shadow-lg: 0 20px 50px rgba(0,0,0,.45);
  }
  .table th { color: #101010; }
}

/* 12) طباعة مبسطة للفواتير */
@media print {
  .header, .footer, .notice, .mobile-drawer, .cart-drawer, .fab-cta, .to-top { display: none !important; }
  body { background: #fff; }
  .card, .table { box-shadow: none; border-color: #ccc; }
}

/* =========================
   End
   ========================= */