/* BOS — shared tokens & primitives */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;

  --night: #070b14;      /* landing / logo background */
  --night-2: #0d1424;
  --night-3: #141d33;
  --side: #f8fafc;       /* app sidebar */
  --side-2: #e8f0fe;
  --side-ink: #0f172a;
  --side-muted: #64748b;

  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-400: #3b82f6;
  --blue-300: #60a5fa;
  --blue-50: #eff6ff;
  --cyan: #38bdf8;
  --grad: linear-gradient(135deg, #1e40af 0%, #2563eb 45%, #38bdf8 100%);

  --c1: #2563eb; --c2: #0d9488; --c3: #d97706; --c4: #9333ea; /* chart series */
  --good: #15803d; --good-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2;
  --info-bg: #e0f2fe;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .62em 1.2em; border-radius: 8px; border: 1px solid transparent;
  background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600;
  text-decoration: none !important; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-grad { background: var(--grad); color: #fff; box-shadow: 0 8px 24px rgba(37, 99, 235, .35); }
.btn-grad:hover { filter: brightness(1.07); }
.btn-outline { border-color: var(--line-2); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(100, 116, 139, .12); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-success { background: var(--good); color: #fff; }
.btn-sm { padding: .38em .8em; font-size: .875rem; }
.btn-lg { padding: .85em 1.8em; font-size: 1.08rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; min-width: 0; }
.field > label { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--bad); }
.field .hint { font-size: .78rem; color: var(--muted); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; padding: .62em .8em; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input.invalid { border-color: var(--bad); }
.input-group { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.input-group:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input-group .input, .input-group .select { border: 0; box-shadow: none !important; border-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 .8em; background: var(--surface-2); color: var(--muted); font-size: .9rem; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.error-text { color: var(--bad); font-size: .875rem; margin: .25rem 0 .75rem; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 40px; height: 22px; border-radius: 99px; background: #94a3b8; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: #16a34a; }
.switch input:checked + .track::after { transform: translateX(-18px); }
[dir='ltr'] .switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(37, 99, 235, .35); }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: .3em; padding: .12em .6em; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: #0369a1; border-color: transparent; }
.badge.blue { background: var(--blue-50); color: var(--blue-600); border-color: transparent; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Toasts */
.toasts { position: fixed; bottom: 1.25rem; inset-inline-start: 50%; transform: translateX(50%); z-index: 1000; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
[dir='ltr'] .toasts { transform: translateX(-50%); }
.toast { background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .92rem; animation: toast-in .2s ease-out; pointer-events: auto; max-width: min(92vw, 460px); }
.toast.good { background: #166534; }
.toast.bad { background: #991b1b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Brand logo */
.logo { display: inline-flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none !important; }
.logo svg { width: 38px; height: 38px; flex: none; }
.logo b { font-size: 1.55rem; letter-spacing: .02em; font-weight: 800; font-family: 'Inter', var(--font); line-height: 1; }
.logo small { display: block; font-size: .62rem; letter-spacing: .04em; opacity: .75; font-weight: 500; font-family: 'Inter', var(--font); margin-top: 2px; }
.logo .logo-text { display: flex; flex-direction: column; direction: ltr; text-align: left; }

/* WhatsApp floating button + AI assistant (widgets.js) */
.wa-fab, .ai-fab {
  position: fixed; bottom: 1.25rem; z-index: 900; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; border: 0; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.wa-fab:hover, .ai-fab:hover { transform: scale(1.06); text-decoration: none; }
.wa-fab { inset-inline-start: 1.25rem; background: #25d366; color: #fff; }
.wa-fab svg { width: 32px; height: 32px; }
.ai-fab { inset-inline-end: 1.25rem; background: #fff; color: #fff; width: 64px; height: 64px; border: 2px solid #dbe7ff; box-shadow: 0 12px 30px rgba(37, 99, 235, .3); }
.ai-fab .robo-head { width: 48px; height: 44px; }
.ai-fab .ping { position: absolute; top: 4px; inset-inline-end: 4px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
.wa-tip { position: fixed; bottom: 1.6rem; inset-inline-start: 5.3rem; z-index: 899; background: #fff; color: #0f172a; padding: .45rem .8rem; border-radius: 10px; font-size: .85rem; box-shadow: var(--shadow); white-space: nowrap; }
@media (max-width: 560px) { .wa-tip { display: none; } }

.ai-panel {
  position: fixed; bottom: 5.6rem; inset-inline-end: 1.25rem; z-index: 950; width: min(390px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 7.5rem)); background: #fff; color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line);
  animation: toast-in .18s ease-out;
}
.ai-head { background: #f1f5f9; color: var(--ink); border-bottom: 1px solid var(--line); padding: .9rem 1rem; display: flex; align-items: center; gap: .7rem; }
.ai-head .avatar { width: 44px; height: 44px; border-radius: 50%; background: #fff; border: 1px solid #dbe7ff; display: grid; place-items: center; flex: none; }
.ai-head .avatar svg { width: 34px; height: 32px; }
.ai-head h3 { font-size: 1rem; margin: 0; }
.ai-head p { margin: 0; font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.ai-head p::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.ai-head .x { margin-inline-start: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 1.4rem; line-height: 1; padding: .2rem .4rem; }
.ai-body { flex: 1; overflow-y: auto; padding: 1rem; background: var(--surface-2); display: flex; flex-direction: column; gap: .6rem; }
.ai-msg { max-width: 86%; padding: .6rem .85rem; border-radius: 14px; font-size: .92rem; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-start-start-radius: 4px; }
.ai-msg.me { background: var(--blue); color: #fff; align-self: flex-end; border-start-end-radius: 4px; }
.ai-msg.typing { color: var(--muted); }
.ai-msg a { color: inherit; text-decoration: underline; }
.ai-quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.ai-quick button { border: 1px solid var(--blue-300); color: var(--blue-600); background: #fff; border-radius: 99px; padding: .3rem .75rem; font-size: .82rem; cursor: pointer; }
.ai-quick button:hover { background: var(--blue-50); }
.ai-foot { border-top: 1px solid var(--line); padding: .6rem; display: flex; gap: .5rem; background: #fff; }
.ai-foot textarea { flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: 12px; padding: .55rem .75rem; max-height: 110px; outline: none; }
.ai-foot textarea:focus { border-color: var(--blue-400); }
.ai-foot button { width: 44px; border-radius: 12px; border: 0; background: var(--blue); color: #fff; cursor: pointer; display: grid; place-items: center; }
.ai-foot button svg { width: 20px; height: 20px; }
[dir='rtl'] .ai-foot button svg { transform: scaleX(-1); }
.ai-handoff { font-size: .78rem; color: var(--muted); text-align: center; padding: .35rem; background: #fff; border-top: 1px solid var(--line); }
.ai-handoff a { color: #128c7e; font-weight: 600; }

/* ---------- Brand mark & Robo the robot ---------- */
.bos-mark { display: block; }
.robo { display: block; overflow: visible; }
.robo .robo-body { animation: robo-float 4s ease-in-out infinite; transform-box: view-box; }
.robo .robo-shadow { animation: robo-shadow 4s ease-in-out infinite; transform-origin: 60px 145px; transform-box: view-box; }
.robo .robo-eyes { animation: robo-blink 5s infinite; transform-origin: 60px 48px; transform-box: view-box; }
.robo .robo-wave { animation: robo-wave 2.6s ease-in-out infinite; transform-origin: 94px 92px; transform-box: view-box; }
.robo .robo-ant-glow { animation: robo-glow 2s ease-in-out infinite; }
.robo-head .robo-body, .robo-head .robo-shadow { animation: none; }
@keyframes robo-float { 50% { transform: translateY(-5px); } }
@keyframes robo-shadow { 50% { transform: scaleX(.8); opacity: .6; } }
@keyframes robo-blink { 0%, 44%, 50%, 100% { transform: scaleY(1); } 47% { transform: scaleY(.1); } }
@keyframes robo-wave { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(10deg); } }
@keyframes robo-glow { 50% { opacity: .2; } }
.robo-bubble { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: .6rem .9rem; box-shadow: var(--shadow); font-weight: 600; font-size: .92rem; color: var(--ink); }
.robo-bubble::after { content: ''; position: absolute; bottom: -7px; inset-inline-start: 22px; width: 12px; height: 12px; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .robo * { animation: none !important; } }

/* Parent-company lockup */
.parent-lockup { display: inline-flex; align-items: center; gap: .55rem; font-size: .78rem; letter-spacing: .14em; font-weight: 700; color: var(--ink); text-decoration: none !important; font-family: 'Inter', var(--font); direction: ltr; }
.parent-lockup span { color: var(--muted); font-weight: 500; }
.parent-lockup i { width: 1px; height: 14px; background: var(--line-2); }
