/* ============================================================
 * EG Brand — الهوية البصرية
 * لوحة ألوان مستوحاة من التراث المصري:
 *   بردي/رملي للخلفية، أزرق نيلي غامق، ذهبي، وطيني.
 * الخط: Cairo (Google Fonts). الاتجاه RTL بالكامل.
 * ============================================================ */
:root {
  --sand: #f6efe0;
  --sand2: #efe4cc;
  --ink: #2b2118;
  --nile: #1e4d5c;
  --nile-deep: #12333d;
  --gold: #c9a227;
  --gold-soft: #e7cf7a;
  --clay: #b3542e;
  --ok: #2e7d32;
  --err: #b3261e;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(43, 33, 24, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--sand);
  color: var(--ink);
  line-height: 1.7;
}
a { color: var(--nile); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; display: block; }

/* شريط الوضع (ديمو/لايف) */
.modebar {
  text-align: center; font-size: 0.85rem; padding: 6px 12px;
  position: sticky; top: 0; z-index: 60;
}
.modebar.demo { background: repeating-linear-gradient(45deg, #f3e2b3, #f3e2b3 12px, #edd695 12px, #edd695 24px); color: #6b5310; font-weight: 600; }
.modebar.live { background: #dcefe0; color: var(--ok); }

/* الهيدر */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--nile-deep); color: var(--sand);
  border-bottom: 6px solid;
  border-image: repeating-linear-gradient(90deg, var(--gold) 0 18px, var(--clay) 18px 36px, var(--nile) 36px 54px) 1;
}
.topbar a { color: var(--sand); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  color: var(--gold);
  width: 52px; height: 52px; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(201,162,39,.22), transparent 70%);
  border: 2px solid var(--gold); border-radius: 50%;
}
.brand b { font-size: 1.35rem; color: #fff; display: block; line-height: 1.2; }
.brand small { color: var(--gold-soft); font-size: 0.78rem; }
.mainnav { display: flex; gap: 16px; margin-inline-start: 12px; font-weight: 600; }
.mainnav a:hover { color: var(--gold-soft); text-decoration: none; }
.top-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.cartbtn { position: relative; font-size: 1.3rem; padding: 6px 10px; }
.badge {
  position: absolute; top: -4px; inset-inline-start: -4px;
  background: var(--clay); color: #fff; border-radius: 999px;
  font-size: 0.7rem; min-width: 18px; height: 18px; display: grid; place-items: center;
}

/* الأزرار */
.btn {
  font-family: inherit; cursor: pointer; border: 0; border-radius: 10px;
  padding: 8px 18px; font-size: 0.95rem; font-weight: 700; display: inline-block;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn.primary { background: var(--clay); color: #fff; box-shadow: var(--shadow); }
.btn.outline { background: transparent; border: 2px solid var(--nile); color: var(--nile); }
.top-actions .btn.outline, .top-actions .btn.ghost { color: var(--sand); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.big { padding: 12px 28px; font-size: 1.05rem; }
.btn.block { display: block; width: 100%; text-align: center; margin-top: 8px; }

/* الهيرو */
.hero {
  position: relative; text-align: center; padding: 70px 20px 60px;
  background:
    radial-gradient(ellipse at top, rgba(201,162,39,.18), transparent 60%),
    linear-gradient(180deg, var(--sand2), var(--sand));
  overflow: hidden;
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.16; pointer-events: none; }
.hero > *:not(.hero-img) { position: relative; }
.hero-pattern {
  position: absolute; inset-inline: 0; bottom: 0; height: 26px; opacity: .8;
  background:
    repeating-linear-gradient(90deg, var(--gold) 0 14px, transparent 14px 28px),
    repeating-linear-gradient(-45deg, var(--clay) 0 10px, var(--nile) 10px 20px);
  background-blend-mode: multiply;
  clip-path: polygon(0 100%, 3% 0, 6% 100%, 9% 0, 12% 100%, 15% 0, 18% 100%, 21% 0, 24% 100%, 27% 0, 30% 100%, 33% 0, 36% 100%, 39% 0, 42% 100%, 45% 0, 48% 100%, 51% 0, 54% 100%, 57% 0, 60% 100%, 63% 0, 66% 100%, 69% 0, 72% 100%, 75% 0, 78% 100%, 81% 0, 84% 100%, 87% 0, 90% 100%, 93% 0, 96% 100%, 99% 0, 100% 100%);
}
.hero h1 { font-size: 2.6rem; font-weight: 900; color: var(--nile-deep); }
.hero h1 span { color: var(--clay); }
.hero p { max-width: 620px; margin: 14px auto 22px; font-size: 1.1rem; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* الأقسام */
.section { max-width: 1150px; margin: 0 auto; padding: 40px 20px; }
.section.narrow { max-width: 640px; }
.section.center { text-align: center; }
.section h2 { color: var(--nile-deep); margin-bottom: 18px; font-size: 1.6rem; }
.section h3 { color: var(--nile-deep); margin: 18px 0 8px; }
.note { color: #7a6a55; font-size: 0.85rem; font-weight: 400; }
.empty { text-align: center; padding: 60px 20px; font-size: 1.1rem; color: #7a6a55; }

/* بطاقات التصنيفات */
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.catcard {
  background: #fff; border-radius: var(--radius); padding: 20px 16px;
  border-top: 4px solid var(--gold); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; text-align: center;
}
.catcard:hover { text-decoration: none; transform: translateY(-3px); transition: transform .15s; }
.caticon { font-size: 2.2rem; }
.catcard b { color: var(--nile-deep); }
.catcard small { color: #7a6a55; }

/* بطاقات المنتجات */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.pcard { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.pimg { width: 100%; height: 190px; object-fit: cover; }
.pbody { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pbody h3 { font-size: 1.02rem; line-height: 1.5; }
.pbody h3 a { color: var(--ink); }
.ptag { font-size: 0.78rem; color: var(--clay); font-weight: 700; }
.pseller { font-size: 0.85rem; color: #7a6a55; }
.pfoot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.price { color: var(--nile-deep); font-size: 1.1rem; }
.price.big { font-size: 1.6rem; display: block; margin: 8px 0; }
.chip { background: var(--sand2); border-radius: 999px; padding: 2px 12px; font-size: 0.78rem; }
.chip.ok { background: #dcefe0; color: var(--ok); }
.chip.demo { background: #fdf0d5; color: #8a6d10; }
.chip.err { background: #f8d7d5; color: var(--err); }
.err-text { color: var(--err); }

/* صفحة المنتج */
.pdetail { display: grid; grid-template-columns: 1fr 1.2fr; gap: 30px; align-items: start; }
.pdetail .part .pimg { height: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.pinfo { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* الفلاتر والفورم */
.filters { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 200px; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; padding: 10px 14px;
  border: 2px solid #d8c9a8; border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
.form { display: flex; flex-direction: column; gap: 14px; background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form fieldset { border: 2px dashed #d8c9a8; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.form legend { font-weight: 700; padding: 0 8px; }
.payopt { flex-direction: row !important; align-items: flex-start; gap: 10px !important; font-weight: 400 !important; cursor: pointer; }
.payopt input { width: auto; margin-top: 6px; }
.checkline { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkline input { width: auto; }
.warnbox { background: #fdf0d5; border-inline-start: 5px solid var(--gold); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.demobox { margin-top: 18px; background: var(--sand2); border-radius: 10px; padding: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demobox .btn { color: var(--nile); }

/* السلة */
.cartlist { display: flex; flex-direction: column; gap: 12px; }
.cartline { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.cartart { width: 90px; flex-shrink: 0; }
.cartart .pimg { height: 70px; border-radius: 8px; }
.cartinfo { flex: 1; display: flex; flex-direction: column; }
.carttotal { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; background: var(--sand2); padding: 16px 20px; border-radius: var(--radius); font-size: 1.1rem; flex-wrap: wrap; gap: 10px; }

/* لوحات التحكم */
.dashnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.dashnav a { background: #fff; border-radius: 999px; padding: 6px 18px; font-weight: 700; box-shadow: var(--shadow); }
.dashnav a.active { background: var(--nile); color: #fff; text-decoration: none; }
.olist { display: flex; flex-direction: column; gap: 14px; }
.ocard { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.ohead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ohead select { width: auto; padding: 4px 10px; }
.oline { padding: 3px 0; border-bottom: 1px dashed #e8dcc0; font-size: 0.95rem; }
.ofoot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 8px; }

/* المحادثات */
.thread { background: var(--sand2); border-radius: 12px; padding: 12px; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.msg { background: #fff; border-radius: 12px 12px 12px 2px; padding: 8px 14px; max-width: 80%; align-self: flex-start; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.msg.mine { background: #d9ecdf; align-self: flex-end; border-radius: 12px 12px 2px 12px; }
.msg small { display: block; color: #8a7a65; font-size: 0.7rem; margin-top: 2px; }
.msgform { display: flex; gap: 8px; }
.msgform input { flex: 1; }

/* الجداول والإحصائيات */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 10px 14px; text-align: right; border-bottom: 1px solid #eee2c8; }
.table th { background: var(--nile-deep); color: #fff; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat b { font-size: 2rem; color: var(--nile-deep); display: block; }
.stat.warn b { color: var(--clay); }

/* خطوات "إزاي بيشتغل" */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.steps div { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-top: 4px solid var(--nile); }
.ticks { list-style: none; }
.ticks li { padding: 4px 0; }
.ticks li::before { content: ''; display: inline-block; width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); margin-inline-end: 8px; }
.bigcheck { font-size: 3.5rem; }

/* الفوتر */
.footer { text-align: center; padding: 30px 16px; background: var(--nile-deep); color: var(--sand2); display: flex; flex-direction: column; gap: 4px; }
.footer small { color: #9db8b0; }

/* الشات بوت */
#egbot-fab {
  position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 80;
  width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--gold);
  background: var(--nile-deep); color: var(--gold); font-size: 1.6rem; cursor: pointer;
  box-shadow: var(--shadow);
}
#egbot-panel[hidden] { display: none; }
#egbot-panel {
  position: fixed; bottom: 92px; inset-inline-start: 22px; z-index: 80;
  width: 330px; max-width: calc(100vw - 44px); background: #fff;
  border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
#egbot-head { background: var(--nile-deep); color: #fff; padding: 10px 14px; display: flex; flex-direction: column; }
#egbot-head small { color: var(--gold-soft); font-size: 0.7rem; }
#egbot-close { position: absolute; top: 8px; inset-inline-end: 10px; background: none; border: 0; color: #fff; font-size: 1rem; cursor: pointer; }
#egbot-msgs { height: 260px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--sand); }
.botmsg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 0.9rem; }
.botmsg.bot { background: #fff; align-self: flex-start; }
.botmsg.user { background: var(--nile); color: #fff; align-self: flex-end; }
#egbot-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #eee; }
#egbot-form input { flex: 1; border-radius: 999px; }
#egbot-form button { border-radius: 50%; width: 42px; height: 42px; border: 0; background: var(--clay); color: #fff; cursor: pointer; }

/* الأيقونات المحمولة */
.icn { display: inline-flex; width: 1.15em; height: 1.15em; vertical-align: -0.18em; }
.icn svg { width: 100%; height: 100%; }
.icn-xl { width: 52px; height: 52px; }
.icn-brand { width: 30px; height: 30px; }
.ok-text { color: var(--ok); }
.caticon { color: var(--clay); }
.caticon .icn { width: 40px; height: 40px; }
.cartbtn { display: inline-flex; align-items: center; }
.cartbtn .icn { width: 24px; height: 24px; }
#egbot-fab { display: grid; place-items: center; }
#egbot-fab .icn { width: 26px; height: 26px; }
#egbot-form button { display: grid; place-items: center; }
#egbot-form button .icn { width: 18px; height: 18px; }
.modebar .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--clay); }
.modebar.live .dot { background: var(--ok); }

/* صور المنتجات البديلة (لو البائع مرفعش صورة) */
.pimg.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: rgba(255,255,255,.92); font-weight: 700; }
.pal-copper { background: linear-gradient(160deg, #8a5a2a, #5f3c17); }
.pal-khos { background: linear-gradient(160deg, #7a8a3a, #4f5c20); }
.pal-arabesque { background: linear-gradient(160deg, #6e4a7e, #452a52); }
.pal-pottery { background: linear-gradient(160deg, #a05a3a, #6e3a20); }
.pal-alabaster { background: linear-gradient(160deg, #a89468, #6e5c3a); }
.pal-textile { background: linear-gradient(160deg, #3a6a7e, #20414f); }
.pal-lanterns { background: linear-gradient(160deg, #7e3a4a, #4f2030); }

/* التوست */
.toast {
  position: fixed; bottom: 24px; right: 50%; transform: translateX(50%) translateY(80px);
  background: var(--nile-deep); color: #fff; padding: 12px 26px; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; transition: all .3s; z-index: 90; font-weight: 700;
}
.toast.err { background: var(--err); }
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

/* الموبايل */
@media (max-width: 820px) {
  .pdetail { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand b { font-size: 1.1rem; }
  .mainnav { order: 3; width: 100%; justify-content: center; }
  .hero h1 { font-size: 1.9rem; }
  .section { padding: 26px 14px; }
}

.flinks a { color: var(--sand2); text-decoration: underline; margin: 0 4px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.center { text-align: center; }
.modebar:empty { display: none; }

/* إتاحة + أداء */
.skip { position: absolute; top: -60px; inset-inline-start: 8px; background: #fff; color: #000; padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#app:focus { outline: none; }
.pimg { display: block; }
picture { display: block; }
.hero picture { display: contents; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.btn, button, select, input { min-height: 44px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type=search] { flex: 2 1 220px; width: auto; }
.filters select { flex: 1 1 150px; width: auto; }
.filters input[type=number] { flex: 0 1 110px; width: 110px; }
.filters .btn { flex: 0 0 auto; }
