/* Painel da equipe — mesma identidade visual do site/app Acelerati. */
:root {
  --brand: #1f2150;
  --brand-2: #2d2f6b;
  --accent: #ff5a1f;
  --accent-2: #e84a0f;
  --bg: #fbf8f2;
  --surface: #fff;
  --text: #1a1814;
  --muted: #837a6f;
  --border: #e8dfce;
  --ok: #25d366;
  --danger: #e11d48;
  --font: 'Manrope', 'Segoe UI', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
button, select { font: inherit; cursor: pointer; }
button { border: 0; }

.btn { padding: 10px 20px; font-weight: 600; color: #fff; background: var(--accent); border-radius: 999px; transition: background .15s; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn--ghost { color: var(--brand); background: var(--surface); border: 1px solid var(--border); padding: 7px 14px; font-size: 13px; }
.btn--ghost:hover { background: #fff0e8; }
.btn--danger { color: var(--danger); }
.error { color: var(--danger); font-size: 12.5px; }
.ok-msg { color: #15803d; font-size: 12.5px; }
.spacer { flex: 1; }
.right { text-align: right; }

input, textarea, select { font: inherit; color: var(--text); padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; outline: 0; background: var(--surface); width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,90,31,.12); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--brand); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
label.check input { width: auto; }

/* ---------- Login ---------- */
.login { height: 100%; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); padding: 16px; }
.login__card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 28px; background: var(--surface); border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login__logo { height: 34px; width: auto; align-self: flex-start; background: var(--brand); padding: 8px 14px; border-radius: 12px; }
.login__card h1 { font-size: 22px; color: var(--brand); }
.login__card p { color: var(--muted); }

/* ---------- Estrutura: barra lateral + visão ---------- */
.app { height: 100%; display: grid; grid-template-columns: 92px 1fr; }
.view { min-width: 0; min-height: 0; }
.view--chats { display: grid; grid-template-columns: 320px 1fr; }

/* ---------- Barra lateral (canais) ---------- */
.rail { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 14px 8px; background: var(--brand); color: #fff; min-height: 0; overflow-y: auto; }
.rail__logo { height: 22px; width: auto; object-fit: contain; margin: 4px 0 14px; }
.rail__group { display: flex; flex-direction: column; gap: 6px; }
.rail__spacer { flex: 1; }
.rail__btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.72); background: transparent; border-radius: 14px; transition: background .15s, color .15s; }
.rail__btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.rail__btn.is-active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.rail__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail__badge { position: absolute; top: 4px; right: 14px; min-width: 18px; padding: 0 5px; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; color: #fff; background: var(--accent); border-radius: 999px; }
.rail__soon { font-size: 9.5px; font-weight: 500; opacity: .7; }
.avatar { display: grid; place-items: center; width: 26px; height: 26px; font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 50%; }

/* ---------- Lista de conversas ---------- */
.list-pane { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.list-pane__head { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); color: var(--brand); font-size: 16px; }
.conn { font-size: 12px; color: #16a34a; }
.conn.is-off { color: var(--danger); }
.list { list-style: none; padding: 0; overflow-y: auto; flex: 1; }
.empty, .chat__empty { padding: 24px; color: var(--muted); text-align: center; line-height: 1.5; }
.chat__empty { margin: auto; }

.item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.item:hover { background: var(--bg); }
.item.is-active { background: #fff0e8; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c9bfae; }
.dot.is-online { background: var(--ok); box-shadow: 0 0 0 3px rgba(37,211,102,.18); }
.item__main { min-width: 0; }
.item__name { font-weight: 700; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--muted); }
.unread { min-width: 20px; padding: 1px 6px; text-align: center; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; }

/* ---------- Conversa ---------- */
.chat { display: flex; min-width: 0; min-height: 0; }
.chat__view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat__head strong { display: block; font-size: 16px; color: var(--brand); }
.chat__head small { color: var(--muted); }
.chat__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chat__actions .btn { white-space: nowrap; }
.badge { padding: 4px 10px; font-size: 12px; font-weight: 700; border-radius: 999px; background: #e4ecf8; color: var(--brand); }
.badge.is-agent { background: #fff0e8; color: var(--accent-2); }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.msg { max-width: 70%; display: flex; flex-direction: column; }
.msg--customer { align-self: flex-start; }
.msg--assistant, .msg--agent { align-self: flex-end; align-items: flex-end; }
.msg__bubble { padding: 9px 13px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.msg--assistant .msg__bubble { background: #e4ecf8; border-color: #cfdcf1; }
.msg--agent .msg__bubble { color: #fff; background: var(--brand); border-color: var(--brand); }
.msg__meta { margin-top: 3px; font-size: 11px; color: var(--muted); }

.reply { display: flex; gap: 10px; align-items: flex-end; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.reply textarea { flex: 1; resize: none; max-height: 120px; border-radius: 16px; }

/* ---------- Usuários ---------- */
.view--users { display: flex; flex-direction: column; padding: 24px 28px; overflow-y: auto; }
.users__head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.users__head h2 { font-size: 22px; color: var(--brand); }
.users__head p { color: var(--muted); }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; display: flex; gap: 8px; justify-content: flex-end; }
.tag { padding: 3px 10px; font-size: 12px; font-weight: 700; border-radius: 999px; }
.tag--admin { background: #fff0e8; color: var(--accent-2); }
.tag--agent { background: #e4ecf8; color: var(--brand); }
.tag--on { background: #dcfce7; color: #15803d; }
.tag--off { background: #f1ede4; color: var(--muted); }
.you { color: var(--muted); font-size: 12px; }

/* ---------- Diálogos ---------- */
.dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--text); }
.dialog::backdrop { background: rgba(31,33,80,.45); }
.dialog form { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog h3 { font-size: 18px; color: var(--brand); }
.dialog h4 { font-size: 14px; color: var(--brand); margin-top: 4px; }
.dialog__actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 4px; }
.account__who { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.account__who small { color: var(--muted); }

@media (max-width: 900px) {
  .view--chats { grid-template-columns: 240px 1fr; }
}
@media (max-width: 640px) {
  .app { grid-template-columns: 70px 1fr; }
  .view--chats { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
}

/* ---------- Histórico ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input[type="search"] { flex: 1 1 220px; width: auto; }
.filters input[type="date"] { width: auto; }
.filters select { width: auto; }
.filters__date { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; color: var(--muted); }
.table--click tbody tr { cursor: pointer; }
.table--click tbody tr:hover { background: #fff0e8; }
.pager { display: flex; align-items: center; gap: 10px; padding: 14px 2px; color: var(--muted); font-size: 13px; }
.dialog--wide { width: min(760px, calc(100vw - 32px)); }
.transcript { display: flex; flex-direction: column; max-height: min(86vh, 760px); }
.transcript__head { padding: 20px 24px 12px; border-bottom: 1px solid var(--border); }
.transcript__head h3 { margin-bottom: 2px; }
.transcript__head small { display: block; color: var(--muted); line-height: 1.5; }
.transcript__messages { background: var(--bg); min-height: 200px; }
.transcript__actions { padding: 14px 24px; margin: 0; border-top: 1px solid var(--border); }

.convo-divider { align-self: stretch; margin-top: 8px; padding: 8px 0 2px; font-size: 12px; font-weight: 600; text-align: center; color: var(--brand); border-top: 1px dashed var(--border); }
.convo-divider:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

/* ---------- Transferência, responsável e avisos ---------- */
.badge--soft { background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.badge--soft.is-none { font-weight: 600; }
.seg { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.seg button { flex: 1; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; }
.seg button.is-active { color: #fff; background: var(--brand); }
.item__assignee { margin-top: 2px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__assignee.is-mine { color: var(--accent-2); font-weight: 700; }

.dialog__hint { color: var(--muted); font-size: 13px; margin-top: -6px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.pick { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; font-weight: 500; color: var(--text); }
.pick:hover { background: var(--bg); }
.pick:has(input:checked) { border-color: var(--accent); background: #fff0e8; }
.pick.is-disabled { opacity: .55; cursor: not-allowed; }
.pick input { width: auto; accent-color: var(--accent); }
.pick__who { display: flex; flex-direction: column; min-width: 0; }
.pick__who strong { color: var(--brand); }
.pick__who small { color: var(--muted); font-weight: 400; }
.pick__status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pick__status.is-online { color: #15803d; }
.pick__status .dot { display: inline-block; }
.pick__status.is-online .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(37,211,102,.18); }

.msg--system { align-self: center; align-items: center; max-width: 90%; }
.msg--system .msg__bubble { font-size: 12.5px; color: var(--muted); background: transparent; border: 1px dashed var(--border); text-align: center; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-size: 13.5px; color: #fff; background: var(--brand); border-radius: 14px; box-shadow: 0 12px 30px rgba(31,33,80,.35); animation: toast-in .2s ease-out; }
.toast span { flex: 1; }
.toast__action { padding: 5px 12px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; }
.toast__close { color: rgba(255,255,255,.7); background: transparent; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Monitoramento, triagem e avisos ---------- */
.list-subtitle { padding: 8px 16px 0; font-size: 12px; color: var(--muted); }
.warn { margin: 10px 12px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45; color: #8a3b00; background: #fff0e8; border: 1px solid #ffd6c0; border-radius: 12px; }
.view--users .warn { margin: 0 0 14px; }
.readonly-note { padding: 12px 20px; font-size: 13px; text-align: center; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.item__assignee.is-waiting { color: #8a3b00; font-weight: 600; }
.tag--triage { background: #e4ecf8; color: var(--brand); margin-left: 4px; }

.seg { flex-wrap: wrap; }
.seg button { padding: 5px 10px; font-size: 12.5px; white-space: nowrap; }

/* ---------- Arquivos anexados ---------- */
.btn--icon { padding: 9px 11px; line-height: 0; }
.btn--icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--icon:disabled { opacity: .45; cursor: not-allowed; }

.attachment { display: flex; flex-direction: column; gap: 8px; width: min(280px, 100%); padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.msg--agent .attachment, .msg--assistant .attachment { background: #fff; }
.attachment__thumb { display: block; width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px; background: var(--bg); cursor: zoom-in; }
.attachment__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attachment__name { color: var(--brand); overflow-wrap: anywhere; }
.attachment__info small { color: var(--muted); }
.attachment__status { font-weight: 600; }
.attachment__btn { align-self: flex-start; padding: 5px 12px; }
.dialog--image { width: min(900px, calc(100vw - 32px)); padding: 16px; text-align: center; }
.dialog--image img { max-width: 100%; max-height: 74vh; border-radius: 10px; margin-bottom: 12px; }
