/* Wallam dashboard. Same look as the website: white, airy, pill buttons, soft panels. */
:root {
  --bg: #ffffff; --page: #f6f7fb; --ink: #0f1a2b; --muted: #5d6675; --line: #e8eaf0; --soft: #f5f6fa;
  --accent: #3d5afe; --accent-soft: #eef1ff; --mint: #e6f6ef; --lavender: #efebff;
  --ok: #0f9d6b; --danger: #c8321e; --danger-soft: #fdeceA;
  --font: "Instrument Sans", "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
}
[dir="rtl"] { --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Instrument Sans", system-ui, sans-serif; }
:root { --display: "Bricolage Grotesque", "Instrument Sans", "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif; }
[dir="rtl"] { --display: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Bricolage Grotesque", system-ui, sans-serif; }
h1, h2, h3, .big, .plan-price b { font-family: var(--display); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15.5px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
[dir="rtl"] body { line-height: 1.85; }
h1, h2 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; }
[dir="rtl"] h1, [dir="rtl"] h2 { letter-spacing: 0; line-height: 1.5; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted, .hint { color: var(--muted); }
.hint { display: block; font-size: .88rem; font-weight: 400; }
.grow { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-name { font: 700 1.4rem/1 "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif; letter-spacing: -0.02em; }
.logo { display: block; height: 30px; width: auto; }

/* ---------- Buttons and fields ---------- */
.btn {
  font: 500 .98rem/1.2 var(--font); border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  padding: 11px 22px; min-height: 44px; transition: background-color .15s, border-color .15s;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #1b2a42; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 7px 15px; min-height: 36px; font-size: .88rem; }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
label, legend { display: block; font-weight: 600; font-size: .95rem; }
fieldset { border: 0; padding: 0; margin: 0; }
input[type=text], input[type=email], input[type=password], textarea, select {
  display: block; width: 100%; margin-top: 7px; padding: 11px 14px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
textarea { resize: vertical; line-height: 1.7; }
select.inline { width: auto; margin-top: 0; padding: 6px 10px; min-height: 36px; font-size: .88rem; border-radius: 999px; }
.error { color: var(--danger); font-weight: 600; min-height: 1.5em; }
.ok { color: var(--ok); font-weight: 600; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.form { display: grid; gap: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.checks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.checks label {
  font-weight: 500; display: inline-flex; gap: 10px; align-items: center; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; padding-inline-start: 11px;
  transition: background-color .15s, border-color .15s;
}
.checks label:hover { border-color: #c9cedb; }
.checks label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.checks label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #c3c9d6; background: #fff;
  display: inline-grid; place-content: center; transition: background-color .15s, border-color .15s;
}
input[type=checkbox]::before {
  content: ""; width: 5px; height: 10px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0); transition: transform .12s;
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::before { transform: rotate(45deg) scale(1); }
.checks input[type=checkbox]:focus-visible { outline: none; }
.starters-edit { display: grid; gap: 8px; margin-top: 4px; }
.starters-edit input { margin-top: 0; }

/* ---------- Sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(60% 50% at 20% 0%, rgb(61 90 254 / 0.10), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 410px; display: grid; gap: 16px; padding: 32px; box-shadow: 0 30px 70px rgb(15 26 43 / 0.10); }
.login-card .lang-select { margin-top: 4px; }
.text-link { color: var(--accent); font-weight: 600; font-size: .93rem; text-align: center; text-decoration: none; justify-self: center; padding: 2px 6px; border-radius: 6px; }
.text-link:hover { text-decoration: underline; }
.text-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.login-card .ok:empty, .login-card .error:empty { display: none; }

/* ---------- Shell: side menu and main area ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--bg); border-inline-end: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding-inline: 10px; }
.tabs { display: grid; gap: 4px; align-content: start; }
.tabs button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; cursor: pointer;
  font: 500 .96rem/1.3 var(--font); color: var(--muted); background: transparent; border: 0; border-radius: 12px; padding: 11px 12px;
}
.tabs button:hover { background: var(--soft); color: var(--ink); }
.tabs button[aria-selected=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs span { flex: 1; }
.count { font: 700 .75rem/1 "Instrument Sans", sans-serif; font-style: normal; background: var(--danger); color: #fff; border-radius: 999px; padding: 4px 8px; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding-inline: 4px; }
.who { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.lang-select { margin-top: 0; padding: 8px 12px; border-radius: 999px; font-size: .9rem; }

.main { padding: clamp(18px, 3vw, 36px); max-width: 1180px; width: 100%; }
.main > section > .card, .main > section > form.card { max-width: 820px; }
.page-title { margin-bottom: 22px; }
.section-title { margin: 30px 0 14px; }
.banner { margin-bottom: 18px; padding: 14px 18px; background: var(--danger-soft); background: #fdecea; color: var(--danger); border-radius: 14px; font-weight: 600; }
.totals { font-weight: 600; margin-bottom: 16px; }

/* ---------- Home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 22px; display: grid; gap: 8px; align-content: start; justify-items: start; }
.stat-accent { background: var(--lavender); border-color: transparent; }
.stat .label { font-size: .85rem; color: var(--muted); font-weight: 500; }
.big { font: 700 2.1rem/1.15 "Instrument Sans", "IBM Plex Sans Arabic", "Noto Sans Arabic", sans-serif; letter-spacing: -0.03em; }
.stat .btn { margin-top: 6px; }
.meter { width: 100%; height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.meter i.high { background: var(--danger); }
.guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.guide-item { text-align: start; cursor: pointer; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: grid; gap: 6px; align-content: start; }
.guide-item:hover { border-color: var(--ink); }
.guide-item span { color: var(--muted); font-size: .92rem; }

/* ---------- Conversations ---------- */
.chats { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.chat-list { display: grid; gap: 8px; max-height: calc(100vh - 150px); overflow-y: auto; }
.chat-item { text-align: start; font: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 13px 15px; cursor: pointer; display: grid; gap: 5px; color: var(--ink); width: 100%; }
.chat-item:hover { border-color: #c9cedb; }
.chat-item[aria-current=true] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-item .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.chat-item .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; line-height: 1.5; }
.tag.need { background: var(--danger); color: #fff; }
.tag.human { background: var(--mint); color: #0b6b49; }
.tag.bad { background: #fdecea; color: var(--danger); }
.tag.phone { background: var(--soft); color: var(--ink); }
.thread { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; min-height: 320px; padding: 18px; }
.empty { color: var(--muted); padding: 40px 12px; text-align: center; }
.thread-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.thread-log { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; max-height: calc(100vh - 330px); min-height: 200px; overflow-y: auto; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.msg small { display: block; font-size: .72rem; opacity: .7; font-weight: 600; }
.msg.visitor { align-self: flex-start; background: var(--soft); border-end-start-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--accent-soft); border-end-end-radius: 5px; }
.msg.agent { align-self: flex-end; background: var(--ink); color: #fff; border-end-end-radius: 5px; }
.msg .rated { margin-top: 6px; opacity: .85; }
.msg .teach { display: block; margin-top: 6px; padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.msg .teach:hover { text-decoration: underline; }
.reply { display: flex; gap: 8px; }
.reply input { margin-top: 0; border-radius: 999px; }
.thread .hint { margin-top: 8px; }

/* ---------- Lists inside cards ---------- */
.answer-row, .customer { display: grid; gap: 8px; padding: 16px 0; border-top: 1px solid var(--line); }
.answer-row p { white-space: pre-wrap; overflow-wrap: anywhere; }
.customer-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.key-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.key-row .muted { flex: 1; font-size: .88rem; min-width: 160px; }
.new-key { background: var(--mint); border-radius: 16px; padding: 16px 18px; display: grid; gap: 10px; }
.card.new-key { border-color: transparent; }
.new-key textarea, #snippet, #app-url, #webhook-secret, #owner-result-text { font-family: Consolas, "Cascadia Mono", monospace; font-size: .86rem; }
.keyline { display: block; padding: 10px 14px; font-size: .9rem; overflow-wrap: anywhere; }
pre { margin: 0; background: var(--ink); color: #dfe6ff; padding: 14px 16px; border-radius: 14px; overflow-x: auto; font: .84rem/1.6 Consolas, "Cascadia Mono", monospace; }
.notes { margin: 0; padding-inline-start: 20px; display: grid; gap: 8px; color: var(--muted); }

/* ---------- Small screens: the side menu becomes a top strip ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .tabs { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .tabs button { width: auto; white-space: nowrap; padding: 9px 12px; }
  .tabs span { flex: none; }
  .side-foot { margin-top: 0; margin-inline-start: auto; display: flex; align-items: center; }
  .who { display: none; }
  .stats, .guide, .chats, .grid2 { grid-template-columns: 1fr; }
  .chat-list { max-height: 260px; }
  .thread-log { max-height: 50vh; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* ---------- Designed dropdowns (see select.js) ---------- */
.dd { position: relative; margin-top: 7px; font-weight: 400; }
.side-foot .dd, .login-card .dd, .dd-inline { margin-top: 0; }
.dd-button {
  display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer; text-align: start;
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px; min-height: 46px;
}
.dd-button:hover { border-color: #c9cedb; }
.dd-button[aria-expanded=true] { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.dd-button:disabled { opacity: .55; cursor: default; }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chevron { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.dd-button[aria-expanded=true] .dd-chevron { transform: rotate(180deg); stroke: var(--accent); }
.dd-pill .dd-button { border-radius: 999px; padding: 8px 16px; min-height: 40px; font-size: .92rem; }
.dd-inline { display: inline-block; }
.dd-inline .dd-button { border-radius: 999px; padding: 6px 14px; min-height: 36px; font-size: .88rem; width: auto; min-width: 124px; }

.dd-pop {
  position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 6px); min-width: 180px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 6px;
  box-shadow: 0 18px 44px rgb(15 26 43 / 0.16);
}
.dd-up .dd-pop { top: auto; bottom: calc(100% + 6px); }
.dd-list { max-height: 280px; overflow-y: auto; display: grid; gap: 2px; }
.dd-option { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: .95rem; line-height: 1.5; }
.dd-option:hover, .dd-option:focus { background: var(--soft); outline: none; }
.dd-option[aria-selected=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dd-option[aria-selected=true]::after { content: ""; margin-inline-start: auto; flex: none; width: 16px; height: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.dd-search { margin: 0 0 6px !important; border-radius: 10px !important; padding: 9px 12px !important; font-size: .92rem; }
@media (prefers-reduced-motion: reduce) { .dd-chevron { transition: none; } }

/* ---------- Designed question and message boxes ---------- */
dialog.ask { border: 0; border-radius: 22px; padding: 28px; width: min(420px, calc(100vw - 32px)); background: #fff; color: var(--ink); box-shadow: 0 30px 80px rgb(15 26 43 / 0.25); }
dialog.ask::backdrop { background: rgb(15 26 43 / 0.45); }
.ask-text { font-size: 1.05rem; font-weight: 500; margin-bottom: 22px; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .checks label, input[type=checkbox], input[type=checkbox]::before { transition: none; } }

.admin-tag { background: var(--accent-soft); color: var(--accent); margin-inline-start: 2px; }

.customer .dd-inline .dd-button { min-width: 150px; }
/* Small dropdowns in a row: the list is as wide as its longest choice, so no line breaks in two. */
.dd-inline .dd-pop { inset-inline-end: auto; width: max-content; max-width: min(300px, 86vw); }
.dd-inline .dd-option { white-space: nowrap; }
