/* =========================================================
   Wasilbox app — tokens
   ========================================================= */
:root {
  --ink: #1b1b1f;
  --ink-2: #4a4a50;
  --muted: #74747a;
  --line: #e3e3de;
  --canvas: #f5f5f1;
  --surface: #ffffff;
  --dark: #1e1c19;
  --dark-2: #2a2723;
  --dark-line: #3a3630;
  --lime: #d4ec5a;
  --lime-ink: #22300a;
  --lime-soft: #f2f9cf;
  --red: #c8372d;
  --red-soft: #fbe9e7;
  --wa: #25d366; --ig: #e1306c; --fb: #1877f2; --cm: #f7b928;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --shadow: 0 1px 2px rgba(27,27,31,.06), 0 8px 24px -12px rgba(27,27,31,.18);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--canvas);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
p { margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--canvas); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { color: var(--ink-2); margin: 6px 0 22px; max-width: 60ch; }
.center { text-align: center; }
.link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--lime); text-decoration-thickness: 2px; }
.link:hover { text-decoration-color: var(--ink); }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--lime); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.8); opacity: .6; } }

/* =========================================================
   Controls
   ========================================================= */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 10px 16px;
  font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--lime); color: var(--lime-ink); }
.btn-primary:hover:not(:disabled) { background: #c9e347; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); border-color: #cfcfc9; }
.btn-ghost.danger { color: var(--red); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.is-busy { position: relative; color: transparent !important; }
.is-busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--lime-ink) transparent var(--lime-ink) var(--lime-ink); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; font: inherit; font-size: 16px; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--canvas); color: var(--ink); }
.lang-btn { background: none; border: 1px solid var(--dark-line); color: #d9d6cf; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.lang-btn.subtle { align-self: flex-start; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--lime-soft); outline: none; }
.input:disabled { background: var(--canvas); color: var(--ink-2); }
.input-sm { padding: 6px 8px; font-size: 13px; width: auto; }
select.input { padding-inline-end: 28px; }
.form-row-end { display: flex; justify-content: flex-end; margin: -6px 0 14px; }
.form-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 14px; }
.form-notice { background: var(--lime-soft); color: var(--lime-ink); padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 14px; }

/* =========================================================
   Auth — split layout
   ========================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 42%) 1fr; }
.auth-brand {
  background: var(--dark); color: #f4f2ec; padding: 40px; display: flex; flex-direction: column; gap: 18px; position: relative; overflow: hidden;
}
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: inherit; text-decoration: none; }
.wordmark.small { font-size: 18px; }
.auth-tagline { font-size: 28px; font-weight: 500; line-height: 1.3; max-width: 16ch; color: #f4f2ec; }
.auth-brand .lang-btn { position: absolute; bottom: 32px; inset-inline-start: 40px; }

/* the one expressive element: channel chips flowing into the box */
.auth-art { position: relative; flex: 1; min-height: 260px; margin-top: 20px; }
.auth-art .chip { position: absolute; width: 46px; height: 46px; border-radius: 14px; opacity: .95; animation: drift 4.8s ease-in-out infinite; }
.chip-wa { background: var(--wa); top: 6%;  inset-inline-start: 10%; animation-delay: 0s; }
.chip-ig { background: var(--ig); top: 26%; inset-inline-start: 52%; animation-delay: -1.2s; }
.chip-fb { background: var(--fb); top: 44%; inset-inline-start: 16%; animation-delay: -2.4s; }
.chip-cm { background: var(--cm); top: 12%; inset-inline-start: 76%; animation-delay: -3.6s; }
.chip-box {
  position: absolute; bottom: 8%; inset-inline-start: 34%; width: 120px; height: 120px; border-radius: 22px;
  background: var(--lime); box-shadow: 0 30px 60px -20px rgba(212,236,90,.5);
}
.chip-box::before { content: ''; position: absolute; inset: 22px; border-radius: 12px; border: 2px solid var(--lime-ink); opacity: .5; }
@keyframes drift { 50% { transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .auth-art .chip, .boot-mark { animation: none; } }

.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 22px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--ink-2); font-size: 14px; }

/* centered pages (onboarding / invite) */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.onb-card { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow); }
.onb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }

/* =========================================================
   Shell
   ========================================================= */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--dark); color: #d9d6cf; display: flex; flex-direction: column; padding: 14px; position: sticky; top: 0; height: 100vh; }
.org-switch { position: relative; margin-bottom: 18px; }
.org-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; background: var(--dark-2); border: 1px solid var(--dark-line); color: #f4f2ec;
  padding: 8px 10px; border-radius: var(--r-sm); font: inherit; cursor: pointer; text-align: start;
}
.org-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--lime); color: var(--lime-ink); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.org-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-caret { color: #9a968e; }
.menu { position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow); padding: 6px; z-index: 20; display: flex; flex-direction: column; }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: start; background: none; border: 0; font: inherit; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; color: inherit; }
.menu-item:hover { background: var(--canvas); }
.menu-item.active { background: var(--lime-soft); }
.menu-item small { color: var(--muted); }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: #cfcbc2; text-decoration: none; position: relative; }
.nav-link:hover { background: var(--dark-2); color: #fff; }
.nav-link.active { background: var(--dark-2); color: #fff; }
.nav-link.active::before { content: ''; position: absolute; inset-inline-start: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--lime); }
[dir='rtl'] .nav-link.active::before { border-radius: 3px 0 0 3px; }
.nav-icon { width: 20px; text-align: center; opacity: .8; }
.nav-link.is-soon { color: #7d7970; cursor: default; }
.soon { margin-inline-start: auto; font-size: 11px; background: var(--dark-2); color: #9a968e; padding: 1px 7px; border-radius: 999px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--dark-line); }
.user { display: flex; align-items: center; gap: 10px; }
.user-meta { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-meta b { font-weight: 600; color: #f4f2ec; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.user-meta small { color: #9a968e; font-size: 12px; }
.sidebar .icon-btn { color: #9a968e; }
.sidebar .icon-btn:hover { background: var(--dark-2); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--lime-soft); color: var(--lime-ink); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.sidebar .avatar { background: var(--dark-2); color: #f4f2ec; }

.content { padding: 36px 40px; }
.page { max-width: 880px; }
.page-head { margin-bottom: 26px; }
.page-head .muted { margin-top: 4px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 18px; }
.panel h2 + .panel h2 { margin-top: 20px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.pill { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--canvas); color: var(--ink-2); white-space: nowrap; }
.pill-owner { background: var(--lime); color: var(--lime-ink); }
.tag { font-size: 11px; margin-inline-start: 8px; padding: 1px 7px; border-radius: 999px; background: var(--lime-soft); color: var(--lime-ink); font-weight: 500; vertical-align: middle; }
.tag-off { background: var(--canvas); color: var(--muted); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.stat span { color: var(--muted); font-size: 13.5px; }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; position: relative; }
.step.done .step-check { background: var(--lime); border-color: var(--lime); }
.step.done .step-check::after { content: ''; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid var(--lime-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.step.is-soon { color: var(--muted); }
.step .soon { background: var(--canvas); color: var(--muted); }

/* lists */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row.is-off { opacity: .6; }
.list-row b { display: block; font-weight: 600; }
.list-row small { display: block; }
.copy-box { display: flex; gap: 8px; align-items: center; background: var(--canvas); padding: 10px; border-radius: var(--r-sm); margin-bottom: 12px; }
.copy-box code { flex: 1; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* dialogs & toasts */
.overlay { position: fixed; inset: 0; background: rgba(27,27,31,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.dialog { background: var(--surface); border-radius: var(--r-lg); padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.dialog-wide { max-width: 460px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.dialog-msg { margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
[dir='rtl'] .toasts { transform: translateX(50%); }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transform: translateY(8px); transition: .2s; box-shadow: var(--shadow); }
.toast.in { opacity: 1; transform: none; }
.toast-err { background: var(--red); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 24px; gap: 8px; }
  .auth-tagline { font-size: 20px; }
  .auth-art { display: none; }
  .auth-brand .lang-btn { position: static; align-self: flex-start; margin-top: 8px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar-foot { margin-top: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-link.active::before { display: none; }
  .content { padding: 20px 16px; }
  .stats { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .list-row { flex-wrap: wrap; }
}
