:root {
  --bg: #0f1013;
  --panel: #17181d;
  --panel-2: #1e2026;
  --text: #f2f0ea;
  --muted: #9a978f;
  --gold: #c9a86a;
  --gold-2: #e0c893;
  --ok: #3fbe7c;
  --warn: #d9a441;
  --err: #d05959;
  --border: #26282f;
  --border-2: #2c2e35;
  --btn-fg: #121212;
  --panel-glass: rgba(15, 16, 19, 0.92);
  --radius: 14px;
  --accent-1: #7c5cff;
  --accent-2: #ff8a5c;
  --accent-grad: linear-gradient(120deg, #7c5cff, #c9a86a 60%, #ff8a5c);
  --glow: rgba(124, 92, 255, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--gold-2); text-decoration: none; }

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary { background: var(--accent-grad); background-size: 180% 180%; color: #fff; font-weight: 700; border: 0; transition: background-position 0.35s ease, transform 0.15s ease, box-shadow 0.25s ease; }
.btn-primary:hover { background-position: 100% 50%; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(124, 92, 255, 0.28); }
.btn-ok:hover { filter: brightness(1.07); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

.stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field input {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--gold); }

/* ===== Auth ===== */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1000px 400px at 15% -10%, rgba(124, 92, 255, 0.18), transparent),
    radial-gradient(900px 500px at 105% 110%, rgba(255, 138, 92, 0.16), transparent),
    radial-gradient(1200px 600px at 60% 30%, rgba(201, 168, 106, 0.10), transparent),
    var(--bg);
}
.auth-wrap::before,
.auth-wrap::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(6px);
  pointer-events: none;
  animation: floatShape 16s ease-in-out infinite;
}
.auth-wrap::before {
  width: 340px; height: 340px;
  top: -60px; right: -40px;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.25), transparent 65%);
}
.auth-wrap::after {
  width: 420px; height: 420px;
  bottom: -110px; left: -70px;
  background: radial-gradient(circle, rgba(255, 138, 92, 0.22), transparent 65%);
  animation-delay: -8s;
}
@keyframes floatShape {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -18px) scale(1.05); }
  66% { transform: translate(-18px, 14px) scale(0.97); }
}
@keyframes enterTop {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-card {
  width: min(400px, 90vw);
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: enterTop 0.5s ease both;
}
.auth-card .brand { display: block; margin-bottom: 6px; }
.auth-title { font-size: 1.5rem; margin: 6px 0 22px; }
.auth-card form { text-align: right; }

/* ===== Shell / Admin ===== */
/* minmax(0,1fr) — وليس 1fr: الـ1fr يقفل العمود على أصغر عرض يقدر المحتوى
   يعيش فيه (1280px)، فتخرج الصفحة برا الشاشات الأصغر. */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav-label { color: var(--muted); font-size: 0.8rem; margin: 12px 12px 4px; }
.side-nav-label:first-child { margin-top: 0; }
.side-nav-item {
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--muted);
  cursor: default;
}
.side-logout { margin-top: auto; }

.topbar-start { display: flex; align-items: center; gap: 10px; }

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  place-items: center;
}
.nav-toggle:hover { color: var(--gold); }
.nav-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.nav-overlay { display: none; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0;
    right: 0;
    width: min(264px, 84vw);
    z-index: 80;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
  }
  .sidebar.is-open { transform: translateX(0); }
  .nav-overlay.is-visible {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 70;
  }
  .nav-toggle { display: grid; }
  .content { padding: 16px; }
}

.content { padding: 22px 28px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.sync-pill {
  font-size: 0.85rem;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
}
.sync-pill.is-online { color: var(--ok); }
.sync-pill.is-stale { color: var(--warn); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin: 0 0 10px; font-size: 1rem; color: var(--gold-2); }
.card p { margin: 4px 0; color: var(--muted); font-size: 0.92rem; }
.card p strong { color: var(--text); }

.card.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-value { font-size: 1.9rem; line-height: 1.2; color: var(--text); }
.stat-sub { font-size: 0.82rem; color: var(--gold-2); }
.stat-sub a { color: inherit; }

.mini-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--muted); }
.mini-list li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.mini-list li:last-child { border-bottom: 0; }

/* ===== Error ===== */
.error-wrap { min-height: 100vh; display: grid; place-items: center; }
.error-card { text-align: center; }
.error-code { font-size: 4rem; font-weight: 700; color: var(--gold); }

/* ===== Theme toggle ===== */
.theme-toggle {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--gold-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { color: var(--gold); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .ico-moon { display: block; }
.theme-toggle .ico-sun { display: none; }
[data-theme="light"] .theme-toggle .ico-moon { display: none; }
[data-theme="light"] .theme-toggle .ico-sun { display: block; }

/* ===== Light mode (زاهٍ ومبهج + لمسات عصرية) ===== */
[data-theme="light"] {
  --bg: #fff8ec;
  --panel: #ffffff;
  --panel-2: #fbf0dc;
  --text: #2b241a;
  --muted: #6e5f43;
  --gold: #e09a1f;
  --gold-2: #8a5f0d;
  --ok: #129058;
  --warn: #b07612;
  --err: #cf3f3f;
  --border: #efe3cb;
  --border-2: #e2d0ab;
  --btn-fg: #241c0d;
  --panel-glass: rgba(255, 255, 255, 0.88);
  --accent-1: #6a4cf5;
  --accent-2: #ff7a45;
  --accent-grad: linear-gradient(120deg, #6a4cf5, #ffb020 60%, #ff7a45);
  --glow: rgba(106, 76, 245, 0.30);
}
[data-theme="light"] .btn-primary:hover { background-position: 100% 50%; }
[data-theme="light"] .auth-wrap {
  background:
    radial-gradient(900px 380px at 10% -10%, rgba(231, 151, 36, 0.28), transparent),
    radial-gradient(800px 420px at 110% 115%, rgba(106, 76, 245, 0.18), transparent),
    radial-gradient(900px 500px at 55% 20%, rgba(255, 122, 69, 0.12), transparent),
    var(--bg);
}
[data-theme="light"] .auth-wrap::before { background: radial-gradient(circle, rgba(106, 76, 245, 0.30), transparent 65%); }
[data-theme="light"] .auth-wrap::after { background: radial-gradient(circle, rgba(255, 122, 69, 0.28), transparent 65%); }
[data-theme="light"] .theme-toggle { box-shadow: 0 4px 16px rgba(140, 100, 30, 0.16); }

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #fff8ec; --panel: #ffffff; --panel-2: #fbf0dc; --text: #2b241a; --muted: #6e5f43;
    --gold: #e09a1f; --gold-2: #8a5f0d; --ok: #129058; --warn: #b07612; --err: #cf3f3f;
    --border: #efe3cb; --border-2: #e2d0ab; --btn-fg: #241c0d; --panel-glass: rgba(255, 255, 255, 0.88);
    --accent-1: #6a4cf5; --accent-2: #ff7a45; --accent-grad: linear-gradient(120deg, #6a4cf5, #ffb020 60%, #ff7a45); --glow: rgba(106, 76, 245, 0.30);
  }
}

/* ===== Phase 7: admin helpers + animations ===== */
.js-anim .reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js-anim .reveal.is-in { opacity: 1; transform: translateY(0); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; }

.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .field { min-width: 160px; }
.filter-bar select, .filter-bar input { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 12px; color: var(--text); font-family: inherit; }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--gold); }

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.banner-thumb { width: 110px; height: 62px; }

.danger-link { color: var(--err) !important; }
.danger-link:hover { color: var(--err); opacity: 0.85; }

.inline-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-row input { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px 12px; color: var(--text); font-family: inherit; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.img-cell { border: 2px solid var(--border); border-radius: 12px; padding: 6px; text-align: center; }
.img-cell.is-cover { border-color: var(--gold); }
.img-cell img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; }
.img-cell .img-actions { margin-top: 6px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
/* ربط الصورة بلون المنتج (P2-13) — قائمة صغيرة داخل خلية الصورة. */
.img-cell .img-color { margin-top: 6px; display: flex; gap: 6px; }
.img-cell .img-color select {
  flex: 1; min-width: 0; min-height: 32px; padding-inline: 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 12px;
}
.img-cell .img-color .btn { min-height: 32px; padding: 0 10px; font-size: 12px; }
.img-color-badge { display: inline-block; margin-top: 6px; }

.block-row { border: 1px dashed var(--border-2); border-radius: 12px; padding: 12px 14px; margin: 12px 0; background: var(--panel); }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.pager { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.pager a { border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; color: var(--gold-2); }

.mono { font-family: 'Consolas', 'Courier New', monospace; direction: ltr; display: inline-block; }
/* استثناء لازم: لو حملها <td> فهي تخرج من شبكة الجدول (inline-block تغلب
   table-cell) فينهار الصف ويظهر فراغ مكان الخلية. */
.table td.mono { display: table-cell; }

@media (prefers-reduced-motion: reduce) {
  .js-anim .reveal { opacity: 1; transform: none; transition: none; }
  .auth-wrap::before, .auth-wrap::after { animation: none; }
  .auth-card { animation: none; }
}
/* ---------------------------------------------------------------------------
   حقل كلمة المرور + زر الإظهار
   ---------------------------------------------------------------------------
   الزر داخل الحقل (يمين في RTL) لا يكبّره ولا يزيح النص: الحقل يأخذ
   المساحة كلها والزر يطفو فوقها بـpadding على جهة النهاية (inline-end).
   --------------------------------------------------------------------------- */

.auth-password-field { position: relative; }

.auth-password-wrap { position: relative; }

.auth-password-wrap input {
  width: 100%;
  padding-inline-end: 44px;
}

.auth-eye {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted, #8c7480);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-eye:hover { color: var(--text, #2a1d26); background: var(--panel-2, #f6eef2); }
.auth-eye:focus-visible { outline: 2px solid var(--gold, #c9a86a); outline-offset: 1px; }
.auth-eye.is-on { color: var(--gold, #c9a86a); }
.auth-eye svg { width: 19px; height: 19px; display: block; }

/* ===== بدائيات المتجر المشتركة (نُقلت من admin.css — P3-01) =====
   المتجر كان يستعير قواعد التنبيهات والتلميحات من admin.css لأنها كانت
   مكتوبة بلا عزل، فتُحمَّل 109KB على كل صفحة متجر مقابل 4 قواعد. نُقلت هنا
   بنفس القيم المجمّعة (قاعدة أولى + تجاوز لاحق دُمجا في تعريف واحد)
   حتى تُحمَّل admin.css في اللوحة وحدها بلا أي تغيير بصري في المتجر. */
.flash {
  padding: 11px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  border: 1px solid transparent;
  border-inline-start: 4px solid var(--muted);
}
.flash-ok {
  background: rgba(63, 190, 124, 0.14);
  color: var(--ok);
  border-color: rgba(63, 190, 124, 0.35);
  border-inline-start-color: var(--ok);
}
.flash-err {
  background: rgba(208, 89, 89, 0.14);
  color: var(--err);
  border-color: rgba(208, 89, 89, 0.35);
  border-inline-start-color: var(--err);
}
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }