/* Valure Inbox. The same tokens as the help centre: brand blue on white and soft
   greys, Rethink Sans, no gradients. Laid out like a Mac app: sidebar, list, detail. */
@font-face { font-family: "Rethink Sans"; src: url("fonts/RethinkSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rethink Sans"; src: url("fonts/RethinkSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Rethink Sans"; src: url("fonts/RethinkSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --brand: #0207ff;
  --brand-hover: #0005d1;
  --brand-soft: #eef0ff;
  --brand-ring: rgba(2, 7, 255, 0.16);
  --ink: #0a0b12;
  --ink-2: #2f3340;
  --muted: #646a78;
  --line: #e6e6e6;
  --control: #8a8f9c;
  --grey: #f4f4f5;
  --white: #fff;
  --error: #b3261e;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --side-open: 248px;
  --side-closed: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font-family: "Rethink Sans", system-ui, -apple-system, sans-serif; line-height: 1.45; color: var(--ink); background: var(--white); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon { display: block; flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- The chat's spinner ---------- */
.loader { display: grid; place-items: center; color: var(--brand); padding: 48px; transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }
.loader--page { position: fixed; inset: 0; z-index: 20; padding: 0; background: var(--white); }
.loader.is-done { opacity: 0; transform: scale(0.8); pointer-events: none; }
.loader svg { animation: spin 1.3s cubic-bezier(0.4, 0.12, 0.6, 0.88) infinite; }
.loader circle { animation: arc 1.3s cubic-bezier(0.4, 0.12, 0.6, 0.88) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes arc {
  0% { stroke-dasharray: 4 159; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 100 63; stroke-dashoffset: -30; }
  100% { stroke-dasharray: 4 159; stroke-dashoffset: -163; }
}

/* ---------- Controls ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 22px;
  border: 0; border-radius: 999px; font: inherit; font-size: 0.9375rem; font-weight: 600; color: var(--white); background: var(--brand);
  cursor: pointer; transition: background-color 0.15s;
}
.button:hover { background: var(--brand-hover); }
.button:disabled { opacity: 0.5; cursor: default; }
.button--quiet { color: var(--brand); background: var(--brand-soft); }
.button--quiet:hover { background: #e2e5ff; }
.error { font-size: 0.875rem; color: var(--error); }

input, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--control); border-radius: 10px;
  font: inherit; color: var(--ink); background: var(--white); outline: none;
}
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
textarea { display: block; resize: vertical; }

/* ---------- Sign in ---------- */
.sign-in { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 360px; margin: 0 auto; padding: 96px 16px; }
.sign-in form { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 8px; }
.sign-in label { font-weight: 600; }
.sign-in__logo { width: 64px; height: 64px; object-fit: contain; }

/* ---------- Sidebar ---------- */
.app { display: grid; grid-template-columns: var(--side-open) minmax(0, 1fr); height: 100%; transition: grid-template-columns 0.3s var(--ease); }
.app.is-collapsed { grid-template-columns: var(--side-closed) minmax(0, 1fr); }

.side { display: flex; flex-direction: column; gap: 20px; min-width: 0; padding: 16px 12px; overflow: hidden; background: var(--grey); border-right: 1px solid var(--line); }
.side__top { display: flex; align-items: center; gap: 10px; min-height: 44px; padding-left: 8px; }
.side__logo { flex: none; width: 30px; height: 30px; object-fit: contain; }
.side__title { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.side__toggle {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; margin-left: auto; padding: 0;
  border: 0; border-radius: 10px; color: var(--muted); background: none; cursor: pointer;
}
.side__toggle:hover { color: var(--ink); background: rgba(10, 11, 18, 0.06); }

.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__gap { height: 16px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; font: inherit; font-size: 0.9375rem; text-align: left; white-space: nowrap;
  color: var(--ink-2); background: none; cursor: pointer;
}
.nav-item:hover { background: rgba(10, 11, 18, 0.06); }
.nav-item[aria-current="page"] { font-weight: 600; color: var(--brand); background: var(--brand-soft); }
.nav-item__label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item__count { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.nav-item__count--alert { min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center; color: var(--white); background: var(--brand); }
.nav-item kbd { font: inherit; font-size: 0.8125rem; color: var(--muted); }

.side__foot { display: flex; flex-direction: column; gap: 2px; min-height: 44px; margin-top: auto; padding: 0 12px; white-space: nowrap; }
.presence { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; color: var(--ink-2); }
.presence::before { content: ""; flex: none; width: 8px; height: 8px; margin: 0 7px; border-radius: 50%; background: var(--control); }
.presence.is-active::before { background: var(--brand); }
.side__name { padding-left: 40px; font-size: 0.8125rem; color: var(--muted); }

.is-collapsed .side__title, .is-collapsed .nav-item__label, .is-collapsed .nav-item kbd, .is-collapsed .side__name { display: none; }
.is-collapsed .side__top { flex-direction: column; gap: 8px; padding-left: 0; }
.is-collapsed .side__toggle { margin-left: 0; }
.is-collapsed .nav-item { position: relative; justify-content: center; padding: 0; }
.is-collapsed .nav-item__count { position: absolute; top: 2px; right: 4px; min-width: 18px; padding: 0 5px; font-size: 0.6875rem; line-height: 18px; }
.is-collapsed .nav-item__count:not(.nav-item__count--alert) { display: none; }
.is-collapsed .side__foot { align-items: center; padding: 0; }
.is-collapsed .presence { gap: 0; font-size: 0; }
.is-collapsed .presence::before { margin: 0; }

/* ---------- List and thread ---------- */
.view { min-width: 0; height: 100%; overflow: hidden; }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100%; }
.pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.pane__head { padding: 24px 20px 12px; }
.pane__head p { margin-top: 2px; font-size: 0.875rem; color: var(--muted); }
.pane__list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 16px; overflow-y: auto; }
.pane__empty { padding: 32px 8px; text-align: center; font-size: 0.9375rem; color: var(--muted); }

.item {
  display: block; width: 100%; padding: 12px 14px; border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; text-align: left; color: var(--ink); background: none; cursor: pointer;
}
.item:hover { background: var(--grey); }
.item[aria-current="true"] { background: var(--brand-soft); }
.item__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.item time { flex: none; font-size: 0.8125rem; color: var(--muted); }
.item__preview {
  display: -webkit-box; margin-top: 2px; overflow: hidden; overflow-wrap: anywhere; font-size: 0.875rem; color: var(--muted);
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.thread__empty { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }
.thread__head { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.thread__who { flex: 1; min-width: 0; }
.thread__who h2 { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.thread__who p { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.thread__back { display: none; }
.thread__actions { display: flex; flex: none; gap: 8px; }
.thread__body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 24px; overflow-y: auto; }
.thread__compose { display: flex; flex-direction: column; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.thread__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.thread__hint { font-size: 0.875rem; color: var(--muted); }

.bubble { max-width: 72%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.bubble small { display: block; margin-bottom: 2px; font-size: 0.75rem; opacity: 0.75; }
.bubble--visitor { align-self: flex-start; background: var(--grey); }
.bubble--assistant { align-self: flex-start; color: var(--muted); background: var(--white); border: 1px solid var(--line); }
.bubble--agent { align-self: flex-end; color: var(--white); background: var(--brand); }
.bubble--auto { align-self: flex-end; color: var(--brand); background: var(--brand-soft); }

/* ---------- Pages: like Settings on a Mac ---------- */
.page { height: 100%; padding: 32px 24px 48px; overflow-y: auto; background: var(--grey); }
.page__inner { display: flex; flex-direction: column; gap: 24px; max-width: 680px; margin: 0 auto; }
.page__lead { margin-top: 4px; color: var(--muted); }
.group { display: flex; flex-direction: column; gap: 8px; }
.group > h2 { padding-left: 16px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 10px 16px; }
.row + .row { border-top: 1px solid var(--line); }
.row__text { min-width: 0; }
.row__title { font-size: 1rem; font-weight: 600; }
.row__text p { font-size: 0.875rem; color: var(--muted); }
.row__value { flex: none; color: var(--muted); }
.response { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-2); }

/* ---------- Search: like Spotlight ---------- */
.search {
  width: min(640px, calc(100% - 32px)); max-height: 70vh; margin: 12vh auto auto; padding: 0; overflow: hidden;
  color: var(--ink); background: var(--white); border: 0; border-radius: 18px; box-shadow: 0 24px 64px rgba(10, 11, 18, 0.28);
}
.search[open] { display: flex; flex-direction: column; }
.search::backdrop { background: rgba(10, 11, 18, 0.4); }
.search__field { display: flex; flex: none; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.search__icon { color: var(--muted); }
.search__field input, .search__field input:focus { padding: 12px 0; border: 0; border-radius: 0; font-size: 1.125rem; box-shadow: none; outline: none; }
.search__results { flex: 1; padding: 8px; overflow-y: auto; }
.search__results h3 { padding: 8px 12px 4px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.search__hint { padding: 24px 12px; text-align: center; color: var(--muted); }
.article { padding: 8px 12px 16px; }
.article h2 { font-size: 1.25rem; font-weight: 700; }
.article__topic { font-size: 0.8125rem; color: var(--muted); }
.article__summary { margin: 8px 0; font-weight: 600; }
.article__body { color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.article__actions { position: sticky; bottom: -16px; display: flex; gap: 8px; margin: 12px -12px -16px; padding: 12px; background: var(--white); border-top: 1px solid var(--line); }
.article__actions a { text-decoration: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 30; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px;
  font-size: 0.9375rem; color: var(--white); background: var(--ink); transform: translateX(-50%);
}

/* ---------- Phones: the menu stays small, and the thread takes over the screen ---------- */
@media (max-width: 760px) {
  .side__toggle { display: none; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .pane { border-right: 0; }
  .split.has-thread .pane { display: none; }
  .split:not(.has-thread) .thread { display: none; }
  .thread__back { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin-left: -12px; padding: 0; border: 0; color: var(--brand); background: none; cursor: pointer; }
  .thread__head, .thread__compose { padding-inline: 16px; }
  .thread__body { padding: 16px; }
  .bubble { max-width: 88%; }
  .page { padding: 24px 16px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .app, .loader { transition: none; }
}
