/* ==========================================================================
   Вкладка «Исходящие» (app/web/outbox.js). Только на токенах app.css — тёмная и светлая
   темы работают сами. Все классы с префиксом ob-, чтобы не задеть остальной кабинет.
   Телефон — та же граница, что у каркаса кабинета (860 px: верхняя и нижняя панели).
   ========================================================================== */

/* Комфортная ширина на компьютере: карточка — это текст сообщения, а не таблица. */
.ob-wrap { max-width: 800px; margin: 0 auto; min-width: 0; }
.ob-slot:empty { display: none; }
.ob-slot { margin-bottom: 12px; }
.ob-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ob-spin { width: 14px; height: 14px; flex: none; display: inline-block; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* ── шапка: номера клуба чипами, сводка, разделы ── */
.ob-bar { position: sticky; top: 0; z-index: 15; background: var(--bg); padding: 8px 0; margin-bottom: 2px; }
.ob-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.ob-chips::-webkit-scrollbar { display: none; }
/* position: relative — иначе подпись для чтеца (ob-sr) выпадает из прокрутки и
   растягивает страницу на телефоне */
.ob-chip { flex: none; height: 36px; position: relative; }
.ob-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.ob-chip[aria-pressed="true"] .chip-count { color: var(--bg); }
.ob-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--faint); }
.ob-dot.lv-ok { background: var(--ok); }
.ob-dot.lv-busy { background: var(--warn); }
.ob-dot.lv-limited { background: var(--danger); }
.ob-dot.lv-off { background: var(--faint); }

.ob-stats { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 14px; font-size: 13px; color: var(--text-2); min-width: 0; }
.ob-stats:empty { display: none; }
.ob-stat-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 750; color: var(--text); }
.ob-stat-line { overflow-wrap: anywhere; }
.ob-level { display: block; font-weight: 650; font-size: 12.5px; line-height: 1.45; margin-top: 2px; overflow-wrap: anywhere; }
.ob-level > .ob-dot { margin-right: 7px; vertical-align: 1px; }
.ob-level.lv-ok { color: var(--ok); }
.ob-level.lv-busy { color: var(--warn); }
.ob-level.lv-limited { color: var(--danger); }
.ob-level.lv-off { color: var(--muted); }
.ob-raise { margin-left: 8px; vertical-align: 1px; }

.ob-seg { display: flex; width: max-content; max-width: 100%; margin-bottom: 14px; }
.ob-seg a { height: 36px; padding: 0 14px; font-size: 13px; }

/* ── список карточек: свой якорь прокрутки (outbox.js) — родной выключен, чтобы не
   сдвигать дважды ── */
.ob-body { min-width: 0; }
.ob-list { display: flex; flex-direction: column; gap: 12px; overflow-anchor: none; }
.ob-pill-wrap { position: sticky; top: 60px; z-index: 14; height: 0; display: flex; justify-content: center; }
.ob-pill { box-shadow: var(--shadow); background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ob-foot { margin: 18px 0 4px; text-align: center; }

/* ── карточка ── */
.ob-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; min-width: 0; scroll-margin-top: 72px; scroll-margin-bottom: 24px;
  transition: border-color .15s, box-shadow .15s;
}
.ob-card:focus-within { border-color: var(--accent-line); }
.ob-card:focus-visible { box-shadow: var(--focus); }
.ob-card.is-gone { opacity: .75; border-style: dashed; }
.ob-card.is-failed { border-color: var(--danger); }
@keyframes ob-arrive { from { background: var(--accent-soft); border-color: var(--accent-line); } }
.ob-arrive { animation: ob-arrive 2.2s var(--ease); }
@media (prefers-reduced-motion: reduce) { .ob-arrive { animation: none; } }

.ob-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.ob-name { margin: 0; font-size: 15.5px; font-weight: 750; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; min-width: 0; }
.ob-src {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px;
  font-size: 11.5px; font-weight: 700; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); white-space: nowrap;
}
.ob-src-instagram { color: #e1306c; }
:root:not([data-theme="light"]) .ob-src-instagram { color: #ff7aa8; }
.ob-src-telegram { color: var(--info); }
.ob-src-taplink, .ob-src-site { color: var(--accent-ink); }
.ob-age { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ob-age.is-fresh { color: var(--accent-ink); font-weight: 700; }
.ob-age.is-fresh::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 5px; vertical-align: 1px; }

.ob-sub { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.ob-sub a.tel { color: var(--text-2); font-variant-numeric: tabular-nums; }
.ob-from { display: inline-flex; align-items: center; gap: 4px; }
.ob-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ob-context {
  margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.ob-notes { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ob-notes .banner { flex-wrap: wrap; }
.ob-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; min-width: 0; }
.ob-inline .input { flex: 1 1 180px; min-width: 0; width: auto; }
.ob-phone-fix .banner-body > div:first-child { color: var(--text); }
.ob-numpick { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px dashed var(--accent-line); border-radius: var(--radius); }
.ob-numpick-q { font-weight: 700; font-size: 13px; }
.ob-numbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.ob-numbtn.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* текст сообщения: растёт по содержимому, вручную не тянется */
.ob-editor { margin-top: 12px; position: relative; }
textarea.input.ob-text { resize: none; overflow: hidden; min-height: 84px; font-size: 14.5px; line-height: 1.5; }
.ob-writing { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12.5px; font-weight: 650; color: var(--accent-ink); }
.ob-editor.is-writing .ob-text { border-style: dashed; }

.ob-hints:empty { display: none; }
.ob-hints { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; font-size: 12.5px; }
.ob-hint { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; color: var(--text-2); }
.ob-hint.muted { color: var(--muted); }
.ob-hint.warn { color: var(--warn); }
.ob-hint.accent { color: var(--accent-ink); font-weight: 650; }
.ob-hint .link-btn { font-size: 12.5px; padding: 4px 0; }

/* кнопки: на компьютере основная — «Отправить» */
.ob-actions { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ob-actions .ob-more { margin-left: auto; }
.ob-send { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 750; }
.ob-send:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.ob-btn-text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.ob-pace { font-size: 11px; font-weight: 600; opacity: .85; font-variant-numeric: tabular-nums; }
.ob-pace:empty { display: none; }
.ob-phone.has-pace { height: auto; min-height: 38px; padding-top: 5px; padding-bottom: 5px; }
.ob-phone.is-armed { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.ob-more-label { display: none; }
.ob-after { margin-top: 8px; color: var(--muted); }

/* панели под кнопками — в самой карточке, не окна */
.ob-panel { margin-top: 10px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.ob-panel-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.ob-panel .chips .chip { height: 36px; }
.ob-own { margin-top: 10px; }
.ob-chip-ghost { border-style: dashed; }
.ob-menu { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.ob-menu-item { justify-content: flex-start; width: 100%; height: 42px; }
.ob-menu-item.ob-danger { color: var(--danger); }
.ob-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* «Ждём, что ушло…» после «С телефона» */
.ob-pending { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ob-quote { margin: 0; padding: 10px 12px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.ob-pending-q { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.ob-pending.is-ask .ob-pending-q { color: var(--warn); }
.ob-pending.is-ask .ob-pending-q strong { color: var(--text); }
.ob-pending-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* свёрнутая строка после действия */
.ob-row {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); font-size: 13.5px; color: var(--text-2);
}
.ob-row-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ob-row-text strong { color: var(--text); }
.ob-row-icon { color: var(--ok); display: inline-flex; }
.ob-row-queued .ob-row-icon { color: var(--accent-ink); }
.ob-row-removed .ob-row-icon { color: var(--muted); }

/* ── «В очереди», «Ушло», «Снято» ── */
.ob-lines { display: flex; flex-direction: column; gap: 8px; }
.ob-group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ob-group-head:first-child { margin-top: 0; }
.ob-group-head .ob-level { text-transform: none; letter-spacing: 0; margin: 0; }
.ob-summary { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 4px; }
/* Чей текст ушёл: бота как есть / с правками / свой (полоса — как у сообщения в переписке, app.css) */
.ob-origin { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px 0 5px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.ob-origin-own { padding-left: 8px; }
.ob-origins { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.ob-origins > summary { cursor: pointer; font-weight: 650; color: var(--text-2); }
.ob-origins-body { display: grid; gap: 6px; margin-top: 10px; }
.ob-origins-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ob-origins-row .ob-origin { min-width: 112px; }
.ob-origins-num { min-width: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ob-origins-sub { margin-top: 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ob-origins-person { overflow-wrap: anywhere; }
.ob-line {
  display: flex; align-items: flex-start; gap: 12px; min-width: 0;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ob-line-main { flex: 1 1 auto; min-width: 0; }
.ob-line-title { font-size: 14px; overflow-wrap: anywhere; }
.ob-line-meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.ob-reason { color: var(--text-2); font-weight: 650; }
.ob-line-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.ob-pos { display: inline-block; min-width: 26px; margin-right: 6px; font-size: 11.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ob-eta { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.ob-line-text { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.ob-line-text summary { cursor: pointer; color: var(--muted); list-style: none; overflow-wrap: anywhere; }
.ob-line-text summary::-webkit-details-marker { display: none; }
.ob-line-text[open] summary { display: none; }
.ob-line-text > div { padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); line-height: 1.5; }

/* ── «Как вас называть гостям?», «+ Заявка», связь ── */
.ob-guest { align-items: flex-start; }
.ob-guest-q { display: block; font-weight: 750; color: var(--text); font-size: 13.5px; }
.ob-guest-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ob-guest .ob-inline .input { max-width: 260px; }
.ob-add { padding: 14px 18px 16px; }
.ob-add-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ob-add-head h2 { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.ob-add-body textarea.input { min-height: 96px; }
.ob-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 4px; }
.ob-add-grid .field { margin-bottom: 12px; }
.ob-add-actions { margin-top: 10px; }
.ob-warn-line { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--warn); }
.ob-warn-line .link-btn { font-size: 12px; }
.ob-offline .btn { flex: none; }

/* ── «Каналы» → номер: темп «Исходящих» (app.js, waNumberForm) ── */
.wa-pace { gap: 8px; }
.wa-pace .wa-pace-input { width: 90px; flex: none; }

/* ── телефон (и планшет без мыши): основная кнопка — «С телефона», всё под палец ── */
@media (max-width: 860px), (hover: none) and (pointer: coarse) {
  .ob-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .ob-actions .btn { height: auto; min-height: 46px; width: 100%; justify-content: center; padding: 6px 10px; }
  .ob-actions .ob-phone { order: -1; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 750; }
  /* с подсказкой темпа — во всю ширину: «лучше через пару минут · ≈ 1:40» не влезает в половину */
  .ob-actions .ob-phone.has-pace { grid-column: 1 / -1; }
  /* …и тогда остальные три — одним рядом, а не «Ещё» одна на строке */
  .ob-actions:has(.ob-phone.has-pace) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ob-actions:has(.ob-phone.has-pace) .btn { padding: 6px 6px; }
  .ob-actions .ob-phone.is-armed { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
  .ob-actions .ob-send { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); font-weight: 650; }
  .ob-actions .ob-more { margin-left: 0; border-color: var(--border-strong); }
  .ob-more-label { display: inline; }
  .ob-btn-text { align-items: center; }
}

@media (max-width: 860px) {
  .ob-wrap { max-width: none; }
  .ob-view .page-head { display: none; }        /* название — в верхней панели, «+» — там же */
  .ob-add-btn { display: none; }               /* на телефоне — «+» в верхней панели */
  .ob-bar { top: var(--topbar-h); margin: 0 -16px 2px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
  .ob-chip { height: 44px; padding: 0 14px; }
  .ob-pill-wrap { top: calc(var(--topbar-h) + 70px); }
  .ob-seg { width: 100%; }
  .ob-seg a { flex: 1 1 auto; justify-content: center; height: 40px; padding: 0 8px; }
  .ob-card { padding: 14px; scroll-margin-top: calc(var(--topbar-h) + 72px); scroll-margin-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
  .ob-name { font-size: 16px; }
  textarea.input.ob-text { font-size: 16px; }                     /* 16px — иначе iOS увеличивает страницу */
  .ob-inline .input, .ob-panel .input { font-size: 16px; height: 44px; }
  .ob-inline .btn, .ob-pending-actions .btn, .ob-numbtn, .ob-panel .chips .chip { min-height: 44px; }
  .ob-notes .banner .btn { width: auto; }
  .ob-hint .link-btn { padding: 12px 0; }
  .ob-notes .banner .btn, .ob-dev .btn { min-height: 44px; }
  .ob-raise { min-height: 32px; }
  .ob-pending-actions .btn { flex: 1 1 auto; }
  .ob-row { flex-wrap: wrap; padding: 10px 12px; }
  .ob-row .btn { min-height: 40px; }
  .ob-line { flex-direction: column; gap: 8px; }
  .ob-line-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .ob-line-side .btn { min-height: 40px; }
  .ob-eta { text-align: left; }
  .ob-add { padding: 12px 14px 14px; }
  .ob-add-grid, .ob-edit { grid-template-columns: minmax(0, 1fr); }
  .ob-guest .ob-inline .input { max-width: none; }
  .ob-guest .ob-inline .btn { width: auto; }
  .ob-foot { margin-bottom: 8px; }
  .ob-stat-more { display: none; }              /* доля ответов и темп — на компьютере */
  .wa-pace .wa-pace-input { width: 76px; }
}
