/* BotForge web — واجهة مواقع البوتات ولوحات التحكم */
:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #101624; --muted: #667085; --line: #e4e7ec;
  --accent: #2563eb; --accent-fg: #ffffff; --ok: #12a150; --warn: #d97706; --danger: #d92d20;
  --radius: 18px; --radius-s: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .07);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--card));
  --ink: var(--accent);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017; --card: #171b24; --text: #f2f4f7; --muted: #98a2b3; --line: #262c38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --ink: color-mix(in srgb, var(--accent) 62%, white);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --card: #171b24; --text: #f2f4f7; --muted: #98a2b3; --line: #262c38;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --ink: color-mix(in srgb, var(--accent) 62%, white);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.65 var(--font); min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--ink); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; }
.wide { max-width: 1080px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.stack > *, .step > * { min-width: 0; }
.mt { margin-top: 16px; } .mt2 { margin-top: 28px; }
[hidden] { display: none !important; }

/* الرأس */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid transparent; }
.top.stuck { border-color: var(--line); }
.top .in { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.top .wide { max-width: 1080px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.15rem; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; font-size: 2.2rem; box-shadow: var(--shadow); }
.brand { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified { color: var(--accent); margin-inline-start: 4px; }

/* البطل */
.hero { padding: 26px 0 8px; display: grid; gap: 10px; justify-items: center; text-align: center; }
.hero p { color: var(--muted); max-width: 46ch; }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 600; transition: transform .08s ease, background .15s ease; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: .9rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; flex: none; position: relative; }
.dot { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-fg); font-size: .72rem; font-weight: 700; display: grid; place-items: center; }

/* البطاقات والشبكات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.pad0 { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid.one { grid-template-columns: 1fr; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: .92rem; font-weight: 500; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--accent-soft); color: var(--ink); }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, var(--card)); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, var(--card)); color: var(--warn); }
.badge.off { background: var(--line); color: var(--muted); }

/* منتج */
.prod { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-align: start; padding: 0; }
.prod .ph { aspect-ratio: 1 / 1; background: var(--accent-soft); display: grid; place-items: center; font-size: 2.2rem; overflow: hidden; }
.prod .ph img { width: 100%; height: 100%; object-fit: cover; }
.prod .bd { padding: 10px 12px 12px; display: grid; gap: 6px; flex: 1; align-content: start; }
.prod .nm { font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod .ds { color: var(--muted); font-size: .84rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-weight: 700; color: var(--ink); direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.prod .ft { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.line-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line-item:last-child { border-bottom: 0; }
.line-item .th { width: 64px; height: 64px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.5rem; overflow: hidden; flex: none; }
.line-item .th img { width: 100%; height: 100%; object-fit: cover; }
.qty { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.qty button { width: 34px; height: 34px; border: 0; background: transparent; font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.qty span { min-width: 22px; text-align: center; font-weight: 700; }

/* شريط سفلي وورقة */
.bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.bar .in { max-width: 728px; margin: 0 auto; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 20, .5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { width: 100%; max-width: 760px; max-height: 92dvh; overflow: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); transform: translateY(24px); transition: transform .2s ease; }
.scrim.open .sheet { transform: none; }
.sheet .grab { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 12px; }
@media (min-width: 720px) { .scrim { align-items: center; } .sheet { border-radius: 22px; } }

/* نماذج */
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; }
.input, textarea, select { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 84px; resize: vertical; }
.input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.search { position: relative; }
.search .input { padding-inline-start: 40px; background: var(--card); }
.search::before { content: "⌕"; position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 1.2rem; }

/* قوائم */
.list { display: grid; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--card); width: 100%; border-inline: 0; border-top: 0; text-align: start; }
.item:last-child { border-bottom: 0; }
.item .num { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: .86rem; flex: none; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty .big { font-size: 2.6rem; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 16px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .92rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.tab { border: 0; background: transparent; min-height: 40px; border-radius: 10px; font-weight: 600; color: var(--muted); font-size: .93rem; }
.tab.on { background: var(--accent); color: var(--accent-fg); }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.footer { text-align: center; color: var(--muted); font-size: .84rem; padding: 34px 16px 20px; }
.footer a { font-weight: 600; }
.notice { background: var(--accent-soft); border-radius: var(--radius-s); padding: 12px 14px; font-size: .92rem; }
.prose { white-space: pre-line; overflow-wrap: anywhere; }

/* لوحات الأرقام */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: .86rem; }
.kpi .d { font-size: .8rem; font-weight: 600; color: var(--ok); }
.kpi .d.neg { color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart .ax { stroke: var(--line); }
.chart text { fill: var(--muted); font: 11px var(--font); }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: var(--accent); opacity: .12; }
.chart .br { fill: var(--accent); }

/* المصحف */
.mushaf { font-family: "Amiri Quran", "Amiri", "Traditional Arabic", serif; font-size: 1.62rem; line-height: 2.5; text-align: justify; }
.mushaf .ay { cursor: pointer; border-radius: 8px; padding: 0 2px; }
.mushaf .ay.hl { background: var(--accent-soft); }
.mushaf .n { font-family: var(--font); font-size: .78rem; color: var(--ink); border: 1px solid var(--ink); border-radius: 50%; min-width: 26px; height: 26px; display: inline-grid; place-items: center; margin: 0 4px; vertical-align: middle; }
.basmala { font-family: "Amiri Quran", "Amiri", serif; font-size: 1.5rem; text-align: center; padding: 6px 0 10px; }
audio { width: 100%; height: 42px; }

/* بطاقات التعلم */
.flash { min-height: 190px; display: grid; place-items: center; text-align: center; gap: 6px; padding: 26px 16px; }
.flash .w { font-size: 2rem; font-weight: 700; direction: ltr; }
.opt { width: 100%; text-align: start; min-height: 50px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 500; direction: ltr; }
.opt.rtl { direction: rtl; }
.opt.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--card)); }
.opt.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slot { min-height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; direction: ltr; }
.slot.on, .day.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 66px; padding: 8px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--card); text-align: center; display: grid; gap: 0; }
.day b { font-size: 1.15rem; }
.day span { font-size: .78rem; color: inherit; opacity: .8; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step .n { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 700; flex: none; }
.links { display: grid; gap: 10px; }
.link { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 0 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-weight: 600; color: var(--text); width: 100%; text-align: start; }
.link:active { transform: scale(.99); }
.link .arr { color: var(--muted); }
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; }
.rich a { font-weight: 600; text-decoration: underline; }
.rich code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
.sec-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin: 26px 0 12px; }
.pill-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* داخل تيليجرام: رأس تيليجرام يعرض اسم البوت وصورته، فنختصر رأس الصفحة ونخفي ما يخص الموقع الخارجي */
.only-tg { display: none !important; }
.in-tg .only-tg { display: flex !important; }
.in-tg .only-web { display: none !important; }
.in-tg .top .avatar, .in-tg .top .small { display: none; }
.in-tg .hero { padding-top: 6px; }
.in-tg .hero .avatar.lg { display: none; }
.in-tg .hero h1 { display: none; }
.in-tg .wrap { padding-bottom: 104px; }
