/* =========================================================
   نظام الثيم الموحّد: فاتح / داكن  (theme.css)
   - بيتحمّل آخر ملف CSS في الصفحة، وبيحل محل التثبيت القديم على الأخضر الداكن.
   - كل الألوان من متغيرات --k-* ؛ الأدمن بيغيّر القيم الأساسية من «شكل الصفحة»
     والباقي (الثانوي/الحبر/الحدود القوية) بيتحسب تلقائيًا.
   - الأشرطة اللي هويتها زمردية (الهيرو، الهيدر، قسم الفروع، الفوتر، عناوين الأقسام)
     بتفضل زمردية في الوضعين عشان الهوية، والمحتوى بينقلب.
   ========================================================= */

/* ---------- 1) المتغيرات: الوضع الفاتح (الافتراضي) ---------- */
:root{
  color-scheme:light;
  --k-bg:#F7F6ED;
  --k-bg-2:#EEF2E8;
  --k-surface:#FFFFFF;
  --k-fg:#123D2B;
  --k-line:#D9D2B0;
  --k-gold:#D8A62A;
  --k-muted-src:#617568;

  --k-surface-2:color-mix(in srgb,var(--k-surface) 55%,var(--k-bg));
  --k-muted:color-mix(in srgb,var(--k-muted-src) 55%,var(--k-fg));
  --k-line-strong:color-mix(in srgb,var(--k-line) 55%,var(--k-fg));
  --k-gold-ink:color-mix(in srgb,var(--k-gold) 55%,#2a1a00);
  --k-on-gold:#073D2C;
  --k-chip-on-bg:#073D2C;
  --k-chip-on-fg:#FFF8E9;
  --k-shadow:0 8px 24px #073d2c14;
  --k-shadow-hover:0 14px 32px #073d2c24;
  --k-focus:#176044;
  --k-warn-bg:#FFF3CE;
  --k-warn-fg:#654700;
}

/* ---------- 2) المتغيرات: الوضع الداكن ---------- */
html[data-theme=dark]{
  color-scheme:dark;
  --k-bg:#07251A;
  --k-surface:#0D3526;
  --k-fg:#FFF8E9;
  --k-line:#2E5C48;
  --k-gold:#E2B63E;

  --k-bg-2:color-mix(in srgb,var(--k-bg) 72%,var(--k-surface));
  --k-surface-2:color-mix(in srgb,var(--k-surface) 91%,var(--k-fg));
  --k-muted:color-mix(in srgb,var(--k-fg) 72%,var(--k-bg));
  --k-line-strong:color-mix(in srgb,var(--k-gold) 55%,var(--k-bg));
  --k-gold-ink:var(--k-gold);
  --k-on-gold:#073321;
  --k-chip-on-bg:var(--k-gold);
  --k-chip-on-fg:#073321;
  --k-shadow:0 10px 28px #0006;
  --k-shadow-hover:0 16px 36px #0008;
  --k-focus:var(--k-gold);
  --k-warn-bg:#2b1b05;
  --k-warn-fg:#f4d89e;
}

/* ---------- 3) ربط المتغيرات القديمة (style.css / signature-redesign.css) بالنظام الجديد ---------- */
html[data-theme]{
  --bg:var(--k-bg);--paper:var(--k-bg-2);--card:var(--k-surface);
  --fg:var(--k-fg);--mut:var(--k-muted);--line:var(--k-line);--ink:var(--k-line-strong);
  --pri:var(--k-gold);--sun:var(--k-gold);--on-pri:var(--k-on-gold);--hot:var(--k-gold-ink);
  --sh:color-mix(in srgb,var(--k-fg) 55%,transparent);--inp:var(--k-bg);
  background:var(--k-bg)!important;
}
html[data-theme=dark]{--sh:#000}
html[data-theme] body{background:var(--k-bg)!important;color:var(--k-fg)}
html[data-theme] ::selection{background:var(--k-gold);color:var(--k-on-gold)}
html[data-theme] :focus-visible{outline:3px solid var(--k-focus);outline-offset:3px}

/* ---------- 4) زر التبديل (3 حالات) ---------- */
html #thm .si{display:none}
html[data-mode=light] #thm .i-sun,
html[data-mode=dark] #thm .i-moon,
html[data-mode=auto] #thm .i-auto{display:block}
#thm{position:relative}
#thm:after{content:"";position:absolute;inset-inline-end:4px;bottom:4px;width:7px;height:7px;border-radius:50%;background:var(--k-gold);border:1.5px solid #07251A;opacity:0;transform:scale(.4);transition:opacity .2s,transform .2s}
html[data-mode=auto] #thm:after{opacity:1;transform:scale(1)}

/* انتقال ناعم وقت التبديل بس (مش بيأثر على الأداء بعد كده) */
html.theme-anim *:not(video):not(img),
html.theme-anim *:not(video):not(img)::before,
html.theme-anim *:not(video):not(img)::after{
  transition:background-color .35s ease,color .35s ease,border-color .35s ease,box-shadow .35s ease,fill .35s ease,stroke .35s ease!important;
}

/* ---------- 5) المنيو: الأقسام والبطاقات ---------- */
html[data-theme] .mh,
html[data-theme] .news,
html[data-theme] .news-page-intro{background:var(--k-bg)!important;color:var(--k-fg)!important}
html[data-theme] .mh h2,
html[data-theme] .mh .xl,
html[data-theme] .news h2,
html[data-theme] .news-page-intro h1,
html[data-theme] .news-page-intro h2{color:var(--k-fg)!important}
html[data-theme] .mh h2 b,html[data-theme] .news h2 b{color:var(--k-gold-ink)!important}
html[data-theme] .mh .eyebrow,
html[data-theme] .news .eyebrow{color:var(--k-gold-ink)!important}
html[data-theme] .mh .mut,
html[data-theme] .news .mut,
html[data-theme] .news-page-intro .mut{color:var(--k-muted)!important}

html[data-theme] .cs,
html[data-theme] .cs.offers,
html[data-theme] .cs[style],
html[data-theme] .cs.offers[style]{background-color:var(--k-bg-2)!important;background-image:none!important;color:var(--k-fg)!important}

/* شرائح الأقسام (chips) */
html[data-theme] #chips .chip,
html[data-theme] #chips .chip:visited,
html[data-theme] #chips .chip:hover{
  background:var(--k-surface)!important;background-image:none!important;
  color:var(--k-fg)!important;border:1px solid var(--k-line)!important;box-shadow:none!important}
html[data-theme] #chips .chip:hover{border-color:var(--k-line-strong)!important}
html[data-theme] #chips .chip span{color:inherit!important}
html[data-theme] #chips .chip.on,
html[data-theme] #chips .chip.on:hover{
  background:var(--k-chip-on-bg)!important;color:var(--k-chip-on-fg)!important;
  border-color:var(--k-chip-on-bg)!important;box-shadow:none!important}
html[data-theme] .chips{background:color-mix(in srgb,var(--k-bg) 92%,transparent)!important;border-color:var(--k-line)!important}

/* بطاقات الأقسام */
html[data-theme] .mh .cats .cat,
html[data-theme] .mh .cats .cat:visited,
html[data-theme] .mh .cats .cat:hover,
html[data-theme] .mh .cats .cat[style],
html[data-theme] .mh .cats .cat[style]:hover{
  background:var(--k-surface)!important;background-image:none!important;color:var(--k-fg)!important;
  border:1px solid var(--k-line)!important;box-shadow:var(--k-shadow)}
html[data-theme] .mh .cats .cat:hover{border-color:var(--k-line-strong)!important;box-shadow:var(--k-shadow-hover)}
html[data-theme] .mh .cats .cat *{color:var(--k-fg)!important}
html[data-theme] .mh .cats .cat b{color:var(--k-fg)!important;text-shadow:none!important}
html[data-theme] .mh .cats .cat small{color:var(--k-muted)!important}

/* بطاقات الأصناف */
html[data-theme] .item{
  background:var(--k-surface)!important;color:var(--k-fg)!important;
  border:1px solid var(--k-line)!important;box-shadow:var(--k-shadow)!important}
html[data-theme] .item:hover{border-color:var(--k-line-strong)!important;box-shadow:var(--k-shadow-hover)!important}
html[data-theme] .item h3{color:var(--k-fg)!important}
html[data-theme] .item p{color:var(--k-muted)!important}
html[data-theme] .item .pr{color:var(--k-muted)!important}
html[data-theme] .item .pr b{color:var(--k-gold-ink)!important}
html[data-theme] .item .plus{background:var(--k-gold)!important;color:var(--k-on-gold)!important}
html[data-theme] .item .plate{background:var(--k-surface-2)}
html[data-theme] .item .plate .ph,html[data-theme] .item .oi.ph0{background:var(--k-surface-2)!important}
/* بطاقات العروض: النص فوق الصورة بتدرّج زمردي، فيفضل فاتح في الوضعين */
html[data-theme] .item .ov h3{color:#fff!important}
html[data-theme] .item .ov p,html[data-theme] .item .ov .pr{color:#F6E3C0!important}
html[data-theme] .item .ov .pr b{color:#F5D26B!important}
html[data-theme] .item .variant-label{color:var(--k-muted)}
html[data-theme] .item .variant-select{
  background:var(--k-surface-2);color:var(--k-fg);border:1px solid var(--k-line-strong);border-radius:10px}
html[data-theme] .item .variant-select option{background:var(--k-surface);color:var(--k-fg)}

/* ---------- 6) شريط الإغلاق / البحث / التنبيهات ---------- */
html[data-theme] .closedbar{background:var(--k-warn-bg)!important;color:var(--k-warn-fg)!important;border-color:var(--k-line-strong)!important}
html[data-theme] .srch{background:var(--k-surface);border-color:var(--k-line)}
html[data-theme] .srch input{background:var(--k-bg);color:var(--k-fg);border:1px solid var(--k-line-strong)}
html[data-theme] .srch input::placeholder{color:var(--k-muted)}

/* ---------- 7) الأخبار ---------- */
html[data-theme] .ncard,
html[data-theme] .nmodal .nm-box,
html[data-theme] .nw-empty{background:var(--k-surface);color:var(--k-fg);border-color:var(--k-line)}
html[data-theme] .nf{background:var(--k-surface);color:var(--k-fg);border-color:var(--k-line)}
html[data-theme] .nf.on{background:var(--k-chip-on-bg);color:var(--k-chip-on-fg);border-color:var(--k-chip-on-bg)}

/* ---------- 8) صفحة الدفع والنماذج ---------- */
html[data-theme] .co{background:var(--k-bg)}
html[data-theme] .co .panel,
html[data-theme] .co .vfbox{background:var(--k-surface);color:var(--k-fg);border-color:var(--k-line)}
html[data-theme] .co input:not([type=checkbox]):not([type=radio]):not([type=file]),
html[data-theme] .co select,
html[data-theme] .co textarea{background:var(--k-bg);color:var(--k-fg);border:1px solid var(--k-line-strong)}
html[data-theme] .co input::placeholder,html[data-theme] .co textarea::placeholder{color:var(--k-muted)}
html[data-theme] .co .hint,html[data-theme] .co .mut{color:var(--k-muted)}
html[data-theme] .co .tog button{background:var(--k-bg);color:var(--k-fg);border-color:var(--k-line-strong)}
html[data-theme] .co .tog button small{color:var(--k-muted)}
html[data-theme] .co .tog button.on{background:var(--k-gold);color:var(--k-on-gold);border-color:var(--k-gold)}
html[data-theme] .co .tog button.on small{color:var(--k-on-gold)}

/* ---------- 8.5) شريط الموبايل العلوي: خلفية مصمتة في الوضعين ---------- */
@media(max-width:760px){
  html[data-theme] #nav,html[data-theme] nav#nav,html[data-theme] nav#nav.solid{background:linear-gradient(180deg,#02150f,#04201a)}
}

/* ---------- 9) احترام تفضيل تقليل الحركة ---------- */
@media(prefers-reduced-motion:reduce){
  html.theme-anim *,html.theme-anim *::before,html.theme-anim *::after{transition:none!important}
}
