/* ============================================================
   BH Orders — الثيمات (themes-v1)
   كل ثيم = مجموعة ألوان. الثيم يتفعّل بـ data-theme على <html>
   الثيمات الداكنة (dark / midnight / amoled) تاخذ زادة class="dark"
   ============================================================ */

/* ---------- 1) ذهبي كلاسيك (الافتراضي) ---------- */
html, html[data-theme="gold"] {
  --bg: #f5f1ea;
  --paper: #fefcf7;
  --paper-2: #f9f5ec;
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --soft: #e8e0d0;
  --border: #e4ddd0;
  --ink: #1a1a1a;
  --muted: #6b6357;
  --muted-2: #9a9285;
  --gold: #c9a961;
  --gold-dark: #a8893f;
  --gold-light: #e6d5a8;
  --on-gold: #ffffff;
  --btn-fg: #1a1a1a;
  --accent: #8b3a3a;
  --green: #5a7a3f;
  --red: #a94442;
  --blue: #3a5f8b;
  --purple: #6b4a7a;
  --orange: #c97d4a;
  --line: #1e3a5f;
  --th-bg: #1e3a5f;
  --th-fg: #ffffff;
  /* ألوان الحالات (نجاح / خطأ / تنبيه / معلومة ...) */
  --ok: #2e8b47;
  --bad: #c8343f;
  --warn: #d97706;
  --info: #3a6fb0;
  --vio: #7c4dad;
  --pink: #c2185b;
  --teal: #2a9d8f;
  --shadow: rgba(0,0,0,0.08);
  color-scheme: light;
}

/* ---------- 2) داكن (القديم، محسّن) ---------- */
html[data-theme="dark"] {
  --bg: #0f1419;
  --paper: #1a2028;
  --paper-2: #1c232c;
  --surface: #1f262f;
  --surface-2: #232a34;
  --soft: #252c36;
  --border: #333c48;
  --ink: #f1f1f1;
  --muted: #b5b0a3;
  --muted-2: #8a8578;
  --gold: #d4b878;
  --gold-dark: #b9985a;
  --gold-light: #4a3f28;
  --on-gold: #1a1a1a;
  --btn-fg: #ffffff;
  --accent: #c95555;
  --green: #7a9a5f;
  --red: #d46a68;
  --blue: #6a8fbf;
  --purple: #9b7aa8;
  --orange: #d99765;
  --line: #3a4a60;
  --th-bg: #1e3a5f;
  --th-fg: #e0f2fe;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;
  --vio: #c084fc;
  --pink: #f472b6;
  --teal: #2dd4bf;
  --shadow: rgba(0,0,0,0.4);
  color-scheme: dark;
}

/* ---------- 3) أزرق احترافي ---------- */
html[data-theme="blue"] {
  --bg: #f1f5fb;
  --paper: #ffffff;
  --paper-2: #f6f9fd;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --soft: #e3eaf4;
  --border: #dbe3ee;
  --ink: #0f172a;
  --muted: #5b6b80;
  --muted-2: #94a3b8;
  --gold: #2563eb;
  --gold-dark: #1d4ed8;
  --gold-light: #c7d7fb;
  --on-gold: #ffffff;
  --btn-fg: #ffffff;
  --accent: #9f1239;
  --green: #3f7d4f;
  --red: #b91c1c;
  --blue: #1e40af;
  --purple: #6d28d9;
  --orange: #c2410c;
  --line: #1e3a8a;
  --th-bg: #1e3a8a;
  --th-fg: #ffffff;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --info: #2563eb;
  --vio: #7c3aed;
  --pink: #db2777;
  --teal: #0d9488;
  --shadow: rgba(15,23,42,0.08);
  color-scheme: light;
}

/* ---------- 4) أخضر زمردي ---------- */
html[data-theme="emerald"] {
  --bg: #eef5f1;
  --paper: #fbfdfc;
  --paper-2: #f4f9f6;
  --surface: #ffffff;
  --surface-2: #f1f6f3;
  --soft: #d9e8df;
  --border: #d4e3da;
  --ink: #10231a;
  --muted: #56695f;
  --muted-2: #8fa398;
  --gold: #0f8a5f;
  --gold-dark: #0b6b49;
  --gold-light: #bfe3d2;
  --on-gold: #ffffff;
  --btn-fg: #ffffff;
  --accent: #8b3a3a;
  --green: #2f7a3f;
  --red: #b42d2d;
  --blue: #2f5f8b;
  --purple: #6b4a7a;
  --orange: #c46a2b;
  --line: #134e3a;
  --th-bg: #134e3a;
  --th-fg: #ffffff;
  --ok: #15803d;
  --bad: #c8343f;
  --warn: #d97706;
  --info: #2f6fb0;
  --vio: #7c4dad;
  --pink: #c2185b;
  --teal: #0f8a7f;
  --shadow: rgba(16,35,26,0.08);
  color-scheme: light;
}

/* ---------- 5) وردي ناعم ---------- */
html[data-theme="rose"] {
  --bg: #fbf1f3;
  --paper: #fffafb;
  --paper-2: #fdf5f7;
  --surface: #ffffff;
  --surface-2: #faf3f5;
  --soft: #f1dde2;
  --border: #efdbe0;
  --ink: #2a1418;
  --muted: #7a5f66;
  --muted-2: #b09aa0;
  --gold: #c0587a;
  --gold-dark: #9e3f5f;
  --gold-light: #f3c9d6;
  --on-gold: #ffffff;
  --btn-fg: #ffffff;
  --accent: #8b2f4a;
  --green: #4f7a3f;
  --red: #b3343f;
  --blue: #4a5f9b;
  --purple: #7a4a8a;
  --orange: #c97d4a;
  --line: #6b2a42;
  --th-bg: #6b2a42;
  --th-fg: #ffffff;
  --ok: #2e8b47;
  --bad: #c8343f;
  --warn: #d97706;
  --info: #4a6fb0;
  --vio: #8b4dad;
  --pink: #c2185b;
  --teal: #2a9d8f;
  --shadow: rgba(42,20,24,0.08);
  color-scheme: light;
}

/* ---------- 6) ليلي (أزرق داكن) ---------- */
html[data-theme="midnight"] {
  --bg: #0b1220;
  --paper: #111a2e;
  --paper-2: #131d33;
  --surface: #152038;
  --surface-2: #1a2642;
  --soft: #1e2b48;
  --border: #253455;
  --ink: #e6edf7;
  --muted: #9fb0c8;
  --muted-2: #6b7d98;
  --gold: #5b9cf5;
  --gold-dark: #3b7ee0;
  --gold-light: #1d3460;
  --on-gold: #ffffff;
  --btn-fg: #ffffff;
  --accent: #f07178;
  --green: #6cc28a;
  --red: #f07178;
  --blue: #7aa7f0;
  --purple: #b39ddb;
  --orange: #f0a35b;
  --line: #2a3c60;
  --th-bg: #1a2b4f;
  --th-fg: #dbe7ff;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;
  --vio: #c084fc;
  --pink: #f472b6;
  --teal: #2dd4bf;
  --shadow: rgba(0,0,0,0.45);
  color-scheme: dark;
}

/* ---------- 7) أسود AMOLED ---------- */
html[data-theme="amoled"] {
  --bg: #000000;
  --paper: #0a0a0a;
  --paper-2: #0d0d0d;
  --surface: #111111;
  --surface-2: #161616;
  --soft: #1c1c1c;
  --border: #262626;
  --ink: #f5f5f5;
  --muted: #a3a3a3;
  --muted-2: #6b6b6b;
  --gold: #d4b878;
  --gold-dark: #b9985a;
  --gold-light: #3a3222;
  --on-gold: #111111;
  --btn-fg: #111111;
  --accent: #ef5350;
  --green: #66bb6a;
  --red: #ef5350;
  --blue: #64b5f6;
  --purple: #ba68c8;
  --orange: #ffa726;
  --line: #2a2a2a;
  --th-bg: #1a1a1a;
  --th-fg: #f5f5f5;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;
  --vio: #c084fc;
  --pink: #f472b6;
  --teal: #2dd4bf;
  --shadow: rgba(0,0,0,0.6);
  color-scheme: dark;
}

/* ============================================================
   ألوان محسوبة أوتوماتيكياً من ألوان الثيم
   (خلفية فاتحة / حدود / نص) — تخدم في كل الثيمات
   ============================================================ */
html {
  --ok-bg:   color-mix(in srgb, var(--ok) 14%, var(--surface));
  --ok-bd:   color-mix(in srgb, var(--ok) 40%, var(--surface));
  --ok-fg:   color-mix(in srgb, var(--ok) 72%, var(--ink));
  --bad-bg:  color-mix(in srgb, var(--bad) 13%, var(--surface));
  --bad-bd:  color-mix(in srgb, var(--bad) 38%, var(--surface));
  --bad-fg:  color-mix(in srgb, var(--bad) 72%, var(--ink));
  --warn-bg: color-mix(in srgb, var(--warn) 15%, var(--surface));
  --warn-bd: color-mix(in srgb, var(--warn) 40%, var(--surface));
  --warn-fg: color-mix(in srgb, var(--warn) 68%, var(--ink));
  --info-bg: color-mix(in srgb, var(--info) 13%, var(--surface));
  --info-bd: color-mix(in srgb, var(--info) 38%, var(--surface));
  --info-fg: color-mix(in srgb, var(--info) 72%, var(--ink));
  --vio-bg:  color-mix(in srgb, var(--vio) 13%, var(--surface));
  --vio-fg:  color-mix(in srgb, var(--vio) 72%, var(--ink));
  --pink-bg: color-mix(in srgb, var(--pink) 13%, var(--surface));
  --gold-bg: color-mix(in srgb, var(--gold) 14%, var(--surface));
  --gold-deep: color-mix(in srgb, var(--gold-dark) 70%, var(--ink));
  --ink-soft: color-mix(in srgb, var(--ink) 80%, var(--surface));
  /* ألوان حالات الطلبيات */
  --st-attempt1: var(--orange);
  --st-attempt2: color-mix(in srgb, var(--orange) 85%, var(--ink));
  --st-attempt3: color-mix(in srgb, var(--orange) 70%, var(--ink));
  --st-fake: color-mix(in srgb, var(--bad) 70%, var(--ink));
}

/* ============================================================
   عناصر عامة تتبع الثيم
   ============================================================ */
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="tel"], input[type="email"], input[type="password"], input[type="search"],
input[type="datetime-local"], input[type="month"], select, textarea {
  background-color: var(--surface);
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select option { background: var(--surface); color: var(--ink); }
html.dark input[type="date"]::-webkit-calendar-picker-indicator,
html.dark input[type="time"]::-webkit-calendar-picker-indicator,
html.dark input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(1); }
html.dark img:not(.brand-logo):not(.brand-icon) { filter: brightness(0.92); }

/* انتقال ناعم وقت تبديل الثيم */
html.bh-theme-anim, html.bh-theme-anim * {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease !important;
}

/* ============================================================
   نافذة اختيار الثيم
   ============================================================ */
.bh-theme-overlay {
  position: fixed; inset: 0; z-index: 10050;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.bh-theme-modal {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 12px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow: auto;
  padding: 20px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}
.bh-theme-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.bh-theme-head h3 { font-size: 18px; font-weight: 900; }
.bh-theme-close {
  background: transparent; border: none; font-size: 22px;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.bh-theme-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.bh-theme-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px; padding: 0; overflow: hidden;
  cursor: pointer; background: transparent; text-align: start;
  font-family: inherit;
  transition: transform .15s ease, border-color .15s ease;
}
.bh-theme-card:hover { transform: translateY(-2px); }
.bh-theme-card.active { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-light); }
.bh-theme-prev { height: 82px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.bh-theme-prev .bar { height: 14px; border-radius: 4px; }
.bh-theme-prev .row { display: flex; gap: 6px; flex: 1; }
.bh-theme-prev .box { flex: 1; border-radius: 4px; }
.bh-theme-prev .dot { width: 18px; border-radius: 4px; }
.bh-theme-name {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; font-weight: 700; font-size: 13px;
  background: var(--surface); color: var(--ink);
  border-top: 1px solid var(--border);
}
.bh-theme-check { color: var(--gold); font-size: 15px; visibility: hidden; }
.bh-theme-card.active .bh-theme-check { visibility: visible; }
