/* ==========================================================================
   Botgy design system v2: هادي ونضيف.
   الهوية (اللوجو والألوان) زي ما هي. الشكل: خلفية سادة، أسطح بيضا بحواف خفيفة، مسافات واسعة،
   والبرتقالي بس للفعل الأهم. نقط الكتابة بتظهر في اللوجو والحالات الفاضية.
   ========================================================================== */

:root {
  --bg: #FBFAF7;  --surface: #FFFFFF;  --surface-2: #F6F4EE;
  --ink: #1A1713; --ink-2: #6B645A;
  --line: #ECE8DF; --line-strong: #D9D3C6;
  --signal: #FF6A3D; --signal-hover: #F25A2B; --signal-soft: #FFE8DF; --on-signal: #1A1713;
  --ultra: #3B4BFF; --ultra-soft: #E4E7FF;
  --ok: #1B8A5C; --ok-soft: #DDF3E8;
  --err: #C8372D; --err-soft: #FBE3E0;
  --shadow: 0 1px 2px rgba(26,23,19,.04), 0 8px 24px rgba(26,23,19,.04);
  --side: #FFFFFF; --hero-bg: linear-gradient(155deg, #FFF3EC 0%, #FFE2D4 100%);
  --mk-bubble: var(--ink); --mk-dot: var(--surface);
  --radius: 14px;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

/* الوضع الغامق: بالزرار بس (الفاتح هو الأساسي) */
:root[data-theme="dark"] {
  --bg: #0F0E0C; --surface: #181612; --surface-2: #1E1B16;
  --ink: #F2EDE3; --ink-2: #A59D8F; --line: #2A2620; --line-strong: #3B362D;
  --signal-soft: #3A2018; --ultra: #4B59F5; --ultra-soft: #20244F;
  --ok: #4CC38A; --ok-soft: #14301F; --err: #FF7B72; --err-soft: #3E1F1D;
  --shadow: 0 0 0 transparent; --side: #12100D; --hero-bg: #14110D;
  --mk-bubble: var(--ink); --mk-dot: var(--bg);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 400 15px/1.75 var(--f-body); overflow-x: clip; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.3; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 3.4vw, 30px); } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.mute { color: var(--ink-2); font-size: 14px; }
.num, [dir="ltr"] { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ اللوجو */
.mark { display: block; flex: none; }
.mark-bubble { fill: var(--mk-bubble); }
.mark-d1, .mark-d2 { fill: var(--mk-dot); }
.mark-d3 { fill: var(--signal); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; }
.brand .word { font: 700 22px/1 var(--f-display); letter-spacing: -.03em; direction: ltr; }
.brand .word i { font-style: normal; color: var(--signal); }

.dots { display: inline-flex; gap: 5px; align-items: center; vertical-align: middle; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); animation: bounce 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; background: var(--signal); width: 9px; height: 9px; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; } }

/* ------------------------------------------------------------ الهيكل */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); border-inline-end: 1px solid var(--line); padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; overflow-y: auto;
}
.side .brand { padding: 0 10px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h4 { margin: 20px 10px 6px; font: 500 12px/1 var(--f-body); color: var(--ink-2); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-weight: 500; color: var(--ink-2); transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--signal-soft); color: var(--ink); font-weight: 600; position: relative; }
.nav a.on::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--signal); }
.nav .ic { width: 16px; text-align: center; font-size: 13px; opacity: .85; }
.nav .pill { margin-inline-start: auto; font-size: 12px; font-weight: 600; background: var(--signal); color: var(--on-signal); padding: 0 8px; border-radius: 99px; line-height: 20px; }
.side-foot { margin-top: auto; padding: 0 10px; }
.side button.link { background: none; border: 0; padding: 0; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; box-shadow: none; }
.side button.link:hover { color: var(--ink); transform: none; box-shadow: none; }

.main { width: 100%; max-width: 1040px; margin-inline: auto; padding: 40px clamp(16px, 4vw, 40px) 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head .sub { color: var(--ink-2); margin-top: 6px; }
.crumb { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .side .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; gap: 4px; }
  .side .nav h4 { display: none; }
  .side-foot { margin: 0 auto 0 0; order: 2; }
  .main { padding-top: 24px; }
}

/* ------------------------------------------------------------ كروت وأزرار */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card > h2 { margin-bottom: 4px; }
.card > .hint { color: var(--ink-2); margin: 0 0 20px; font-size: 14px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap;
  background: var(--signal); color: var(--on-signal); border: 0; border-radius: 10px; padding: 0 20px; height: 42px;
  font: 600 14px/1 var(--f-body); transition: background .12s, transform .06s;
}
button:hover, .btn:hover { background: var(--signal-hover); color: var(--on-signal); }
button:active, .btn:active { transform: scale(.98); }
button.ghost, .btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
button.danger { background: transparent; color: var(--err); height: 32px; padding: 0 12px; font-weight: 500; }
button.danger:hover { background: var(--err-soft); color: var(--err); }
.inline { display: inline; }

label { display: block; font: 500 13px/1.4 var(--f-body); margin: 18px 0 6px; }
label small { font-weight: 400; color: var(--ink-2); }
input, select, textarea {
  width: 100%; height: 44px; padding: 0 14px; background: var(--surface); color: var(--ink); font: inherit;
  border: 1px solid var(--line-strong); border-radius: 10px; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 96px; padding: 11px 14px; resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: .6; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; gap: 0; } }
.actions { margin-top: 22px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; margin: 10px 0 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .15s; }
.switch input:checked + .track { background: var(--signal); }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ------------------------------------------------------------ جداول وتاجات */
.tablewrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font: 500 12px/1 var(--f-body); color: var(--ink-2); padding: 0 12px 12px; }
td { padding: 14px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover td, table tr:not(:first-child):hover td { background: var(--surface-2); }
td a { font-weight: 600; } td a:hover { color: var(--signal); }
.tag { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-body); padding: 5px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--signal-soft); color: var(--ink); border-color: transparent; }
.tag.bot { background: var(--ultra-soft); color: var(--ultra); border-color: transparent; }
.tag.off { color: var(--ink-2); }
.tag .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-bottom: 4px; }
.bar i { display: block; height: 100%; background: var(--signal); border-radius: 99px; }

/* ------------------------------------------------------------ إحصائيات */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.stat { padding: 20px 24px; border-inline-start: 1px solid var(--line); }
.stat:first-child { border-inline-start: 0; }
.stat b { display: block; font: 700 30px/1.2 var(--f-display); }
.stat span { color: var(--ink-2); font-size: 13px; }
.stat.hot b { color: var(--signal); }
.stat.hot span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); margin-inline-end: 6px; }
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-inline-start: 0; } .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ------------------------------------------------------------ تبويبات */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 24px; flex-wrap: wrap; max-width: 100%; }
.tabs a { padding: 8px 16px; border-radius: 9px; font-weight: 500; color: var(--ink-2); font-size: 14px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }
.js .pane { display: none; } .js .pane.on { display: block; }

/* ------------------------------------------------------------ المحادثة */
.thread { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.day { align-self: center; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; margin: 10px 0 14px; }
.msg { max-width: min(76%, 520px); padding: 10px 14px 8px; border-radius: 18px; word-break: break-word; margin-bottom: 8px; line-height: 1.65; }
.msg .txt { white-space: pre-wrap; }
.msg .who { display: block; font: 500 11px/1 var(--f-body); margin-bottom: 5px; opacity: .7; }
.msg time { display: block; font-size: 11px; opacity: .55; margin-top: 4px; direction: ltr; text-align: end; }
.msg.customer { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-end-start-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--ultra); color: #fff; border-end-end-radius: 5px; }
.msg.owner { align-self: flex-end; background: var(--signal); color: var(--on-signal); border-end-end-radius: 5px; }
.banner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--signal-soft); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; }
.banner p { font-weight: 600; flex: 1 1 240px; }

/* ------------------------------------------------------------ حالة فاضية وتنبيهات */
.empty { text-align: center; padding: 40px 12px; color: var(--ink-2); }
.empty .dots { margin-bottom: 14px; } .empty b { display: block; color: var(--ink); font: 600 16px var(--f-display); margin-bottom: 4px; }
.toasts { position: fixed; top: 16px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 18px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: pop .25s ease-out, fade .4s 4.2s forwards; }
.toast.ok::before { content: "✓ "; color: var(--ok); } .toast.err { background: var(--err); color: #fff; }
@keyframes pop { from { transform: translateY(-12px); opacity: 0; } } @keyframes fade { to { opacity: 0; visibility: hidden; } }

/* ------------------------------------------------------------ الدخول */
.entry { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.entry .hero {
  position: relative; overflow: hidden; background: var(--hero-bg); color: var(--ink); padding: clamp(28px, 6vw, 72px);
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.entry .hero::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; inset-inline-start: -160px; bottom: -200px; background: radial-gradient(closest-side, rgba(255,106,61,.22), transparent); pointer-events: none; }
.entry .hero > * { position: relative; }
.entry .hero h1 { font-size: clamp(34px, 4.6vw, 54px); line-height: 1.2; max-width: 11em; }
.entry .hero h1 em { font-style: normal; color: var(--signal); }
.entry .hero p { color: var(--ink-2); max-width: 28em; margin-top: 18px; font-size: 16px; }
.chatdemo { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.chatdemo .msg { margin: 0; font-size: 14px; }
.chatdemo .msg.customer { background: #fff; border-color: var(--line); color: var(--ink); }
.entry .formside { display: grid; place-items: center; padding: 32px 20px; }
.entry .card { width: 100%; max-width: 380px; margin: 0; padding: 32px; }
@media (max-width: 860px) { .entry { grid-template-columns: 1fr; } .chatdemo { display: none; } .entry .hero { gap: 28px; } }

/* ------------------------------------------------------------ صفحة الهوية */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 14px; }
.sw { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.sw i { display: block; height: 72px; }
.sw div { padding: 10px 12px; font-size: 13px; color: var(--ink-2); } .sw b { display: block; font-size: 14px; color: var(--ink); }
.logo-stage { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 14px; }
.logo-stage > div { border: 1px solid var(--line); border-radius: 12px; padding: 28px 16px; display: grid; place-items: center; gap: 12px; min-height: 150px; }
.type-sample { font: 700 38px/1.2 var(--f-display); } .type-body { font-size: 18px; }
.voice { padding-inline-start: 20px; } .voice li { margin: 6px 0; }
.card p + .logo-stage, .card .hint + .swatches { margin-top: 4px; }
@media (max-width: 520px) { .msg { max-width: 92%; } .card { padding: 20px 16px; } }

/* ------------------------------------------------------------ تنظيم v3 */
.summary { display: grid; grid-template-columns: 1.1fr 1.4fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }
.summary > div { padding: 18px 22px; border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; justify-content: center; min-width: 0; }
.summary > div:first-child { border-inline-start: 0; }
.summary .k { font-size: 12px; color: var(--ink-2); }
.summary .v { font: 700 22px/1.2 var(--f-display); }
.summary .v small { font: 400 13px var(--f-body); color: var(--ink-2); }
.summary .ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.summary button { height: 34px; padding: 0 14px; font-size: 13px; }
@media (max-width: 860px) {
  .summary { grid-template-columns: 1fr; }
  .summary > div { border-inline-start: 0; border-top: 1px solid var(--line); } .summary > div:first-child { border-top: 0; }
}
.savebar { position: sticky; bottom: 0; z-index: 5; margin: 0 -12px; padding: 16px 12px 14px; display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  background: linear-gradient(to top, var(--bg) 65%, transparent); }
.savebar .mute { margin-inline-end: auto; }
.inline-form { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: end; }
.inline-form label { margin-top: 0; }
@media (max-width: 760px) { .inline-form { grid-template-columns: 1fr; } }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title .mute { font-size: 13px; }
.theme-btn { background: none; border: 1px solid var(--line); color: var(--ink-2); height: 34px; padding: 0 14px; font-size: 13px; font-weight: 500; border-radius: 99px; }
.theme-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-foot { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }


/* ------------------------------------------------------------ محاكاة واتساب */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sim { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.phone { display: flex; flex-direction: column; height: min(680px, calc(100vh - 320px)); min-height: 420px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); }
.phone-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.phone-top b { display: block; font: 600 15px/1.3 var(--f-display); }
.phone-top small { color: var(--ink-2); font-size: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--signal-soft); display: grid; place-items: center; font: 700 16px var(--f-display); flex: none; }
.wall { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.wa { max-width: 82%; padding: 8px 12px 6px; border-radius: 14px; line-height: 1.6; word-break: break-word; font-size: 14.5px; }
.wa .txt { white-space: pre-wrap; }
.wa time { display: block; font-size: 10.5px; opacity: .55; margin-top: 2px; direction: ltr; text-align: end; }
.wa.out { align-self: flex-start; background: var(--ok-soft); border-end-start-radius: 4px; }
.wa.in { align-self: flex-end; background: var(--surface); border: 1px solid var(--line); border-end-end-radius: 4px; }
.wa.owner { background: var(--signal-soft); border-color: transparent; }
.wa-note { align-self: center; font-size: 12.5px; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line-strong); padding: 6px 12px; border-radius: 99px; text-align: center; }
.wa-empty { margin: auto; color: var(--ink-2); font-size: 14px; text-align: center; }
.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer input { flex: 1; min-width: 0; border-radius: 99px; }
.composer button { border-radius: 99px; padding-inline: 20px; }
.sim-side { display: grid; gap: 16px; }
@media (max-width: 860px) { .sim { grid-template-columns: minmax(0, 1fr); } .phone { height: 70vh; } }
