/* AllAxis AI. As cores --brand e --menu vêm da configuração da plataforma (painel administrativo). */
:root {
  --brand: #0f7a5c; --brand-2: color-mix(in srgb, var(--brand) 82%, #000); --brand-soft: color-mix(in srgb, var(--brand) 12%, #fff);
  --menu: #14322a; --menu-text: #e8efec;
  --bg: #f3f5f7; --panel: #fff; --line: #e4e7eb; --text: #1b2228; --muted: #69737d;
  --in: #fff; --out: color-mix(in srgb, var(--brand) 14%, #fff); --note: #fff4c2;
  --danger: #c0392b; --warn: #a15c00; --chat: #ece8e1; --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14.5px; color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.2; }
button:hover { background: #f5f6f8; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--danger); border-color: #ecc7c2; }
button.danger:hover { background: #fdf1ef; }
button.small { padding: 4px 10px; font-size: 13px; }
button.icon { padding: 7px; border-color: transparent; background: transparent; color: var(--muted); }
button.icon:hover { background: #eef1f3; color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid #cfd5db; border-radius: 8px; padding: 9px 11px; background: #fff; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 38px; width: 64px; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent); border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
label.check { display: flex; gap: 9px; align-items: center; color: var(--text); font-size: 14.5px; font-weight: 400; }
a { color: var(--brand-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: #f1f3f5; padding: 2px 6px; border-radius: 5px; word-break: break-all; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--menu), color-mix(in srgb, var(--menu) 60%, var(--brand))); }
.login { width: 100%; max-width: 380px; background: var(--panel); padding: 30px 28px; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 18px; color: var(--brand-2); }
.login-brand img { max-height: 44px; max-width: 160px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login > button { width: 100%; margin-top: 20px; padding: 11px; }
.error { color: var(--danger); margin-top: 10px; min-height: 18px; }
.captcha:not(:empty) { margin-top: 14px; min-height: 65px; }

/* ---------- estrutura ---------- */
.app { display: flex; height: 100%; height: 100dvh; }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main { flex: 1; display: flex; min-height: 0; }
.page { flex: 1; overflow: auto; padding: 22px 26px; }

.rail { width: 228px; flex: none; background: var(--menu); color: var(--menu-text); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; min-height: 52px; }
.rail-brand img { max-height: 40px; max-width: 64px; border-radius: 8px; background: #fff; padding: 3px; }
.rail-names { display: flex; flex-direction: column; min-width: 0; }
.rail-names .brand-name { font-weight: 700; font-size: 16px; }
.rail-names small { opacity: .7; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail button { background: transparent; border: 0; color: inherit; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 9px; opacity: .82; position: relative; width: 100%; text-align: left; }
.rail button:hover { background: rgba(255,255,255,.08); opacity: 1; }
.rail button.on { background: rgba(255,255,255,.14); opacity: 1; font-weight: 600; }
.rail button.on::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); filter: brightness(1.4); }
.rail .dot { position: absolute; left: 26px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: #2ecc71; border: 2px solid var(--menu); }
.rail-spacer { flex: 1; }
.rail-me { border-top: 1px solid rgba(255,255,255,.1) !important; border-radius: 0 !important; padding-top: 14px !important; margin-top: 6px; }
.rail-me-txt { display: flex; flex-direction: column; min-width: 0; }
.rail-me-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.rail-me-txt small { opacity: .65; font-size: 12px; }

.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; overflow: hidden; background-size: cover; background-position: center; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 88px; height: 88px; font-size: 28px; }
.rail .avatar { background-color: rgba(255,255,255,.15); color: #fff; }

/* ---------- lista de conversas ---------- */
.sidebar { width: 360px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 14px 14px 8px; }
.side-head h2 { margin: 0; font-size: 19px; flex: 1; }
.search { padding: 4px 14px 10px; }
.search input { background: #f1f3f5; border-color: transparent; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 13px; background: #fff; white-space: nowrap; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #e9ecef; color: #3d464f; font-size: 11.5px; text-align: center; }
.tabs button.on .count { background: rgba(255,255,255,.25); color: #fff; }
.list { flex: 1; overflow-y: auto; }
.item { padding: 11px 14px; border-bottom: 1px solid #f1f2f4; cursor: pointer; display: flex; gap: 11px; }
.item:hover { background: #f7f8fa; }
.item.on { background: var(--brand-soft); }
.item .info { flex: 1; min-width: 0; }
.item .top { display: flex; justify-content: space-between; gap: 6px; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 11.5px; color: var(--muted); flex: none; }
.item .prev { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 3px; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: #eceff2; color: #46505a; white-space: nowrap; }
.badge.bot { background: #e6e9fb; color: #3949ab; }
.badge.queue { background: #fdecc8; color: var(--warn); }
.badge.open { background: var(--brand-soft); color: var(--brand-2); }
.badge.closed { background: #eee; color: #777; }
.unread { background: #25d366; color: #fff; border-radius: 10px; font-size: 11.5px; padding: 1px 7px; font-weight: 700; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- conversa ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat); }
.chat-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 9px 16px; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.chat-head .title { flex: 1; min-width: 220px; }
.chat-head .title b { display: block; font-size: 15.5px; }
.chat-head .title .muted { font-size: 13px; }
.chat-head .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 7%; display: flex; flex-direction: column; gap: 4px; }
.bubble { max-width: 68%; padding: 7px 10px 5px; border-radius: 10px; background: var(--in); box-shadow: 0 1px 1px rgba(0,0,0,.07); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.bubble.out { background: var(--out); align-self: flex-end; }
.bubble.note { align-self: center; background: var(--note); font-size: 12.5px; max-width: 85%; text-align: center; box-shadow: none; }
.bubble .who { font-size: 11.5px; font-weight: 700; color: var(--brand-2); margin-bottom: 2px; }
.bubble .who.bot { color: #3949ab; }
.bubble .foot { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble .err { color: var(--danger); font-size: 11.5px; }
.bubble img, .bubble video { max-width: 280px; max-height: 320px; border-radius: 7px; display: block; cursor: pointer; }
.bubble audio { width: 260px; max-width: 100%; }
.tick.read { color: #34b7f1; }
.day { align-self: center; background: #e1f2fb; font-size: 12px; padding: 3px 11px; border-radius: 7px; margin: 8px 0; color: #4a5560; }
.composer { background: #f3f4f6; padding: 9px 12px; border-top: 1px solid var(--line); position: relative; padding-bottom: max(9px, env(safe-area-inset-bottom)); }
.composer .row { align-items: flex-end; gap: 4px; }
.composer textarea { resize: none; max-height: 160px; min-height: 42px; border-radius: 21px; padding: 10px 15px; }
.composer.note-mode textarea { background: var(--note); }
.composer .send { border-radius: 21px; padding: 9px 16px; }
.composer #noteBtn.on { color: var(--warn); background: var(--note); }
.warnbar { background: #fff3cd; color: #6b4e00; padding: 9px 14px; font-size: 13.5px; display: flex; align-items: center; gap: 10px; }
.quick { position: absolute; bottom: 100%; left: 12px; right: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: 240px; overflow-y: auto; box-shadow: 0 -6px 18px rgba(0,0,0,.1); }
.quick div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f2f2f2; }
.quick div:hover, .quick div.on { background: var(--brand-soft); }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); background: #f7f8fa; text-align: center; }
.placeholder svg { width: 56px; height: 56px; opacity: .35; }

/* ---------- páginas ---------- */
.page > h1, .page-title { font-size: 21px; margin: 0 0 16px; }
.card { background: var(--panel); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; border: 1px solid var(--line); max-width: 940px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; font-size: 16.5px; }
.card h3 { margin: 18px 0 6px; font-size: 14.5px; }
.card > button, .card .row > button { margin-top: 4px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.subtabs button { border-radius: 20px; padding: 6px 14px; font-size: 13.5px; }
.subtabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.help { font-size: 13px; color: var(--muted); line-height: 1.55; }
.foto-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-prev { max-height: 64px; max-width: 220px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.sound-row { display: flex; gap: 8px; align-items: center; }
.sound-row select { flex: 1; }

/* ---------- janelas ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,20,25,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 500px; max-height: 90vh; overflow: auto; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 70; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.viewer img { max-width: 95vw; max-height: 95vh; }

/* edição e exclusão: nada some, fica riscado */
.bubble .old { text-decoration: line-through; color: var(--muted); font-size: 12.5px; }
.bubble.deleted .txt, .bubble.deleted img, .bubble.deleted audio, .bubble.deleted video, .bubble.deleted a { text-decoration: line-through; opacity: .55; }
.bubble .tag { font-size: 11px; color: var(--muted); font-style: italic; }
.bubble .tag.del { color: var(--danger); }
.bubble .acts { display: none; gap: 4px; margin-top: 4px; justify-content: flex-end; }
.bubble:hover .acts { display: flex; }
.bubble .acts button { padding: 2px 7px; font-size: 11.5px; background: rgba(255,255,255,.75); }
@media (hover: none) { .bubble .acts { display: flex; } }

pre.terms { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; line-height: 1.55; background: #f7f8fa; border: 1px solid var(--line); border-radius: 10px; padding: 14px; max-height: 50vh; overflow: auto; }
a.small { font-size: 12.5px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; color: inherit; display: inline-block; }
.qr { background: #fff; display: inline-block; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.qr svg { display: block; width: 220px; height: 220px; fill: initial; stroke: none; }
.back { display: none !important; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .rail { width: 72px; padding: 12px 8px; }
  .rail-names, .rail button > span:not(.avatar), .rail-me-txt { display: none; }
  .rail button { justify-content: center; padding: 11px 0; }
  .rail-brand { justify-content: center; padding: 4px 0 14px; }
  .rail .dot { left: auto; right: 14px; }
  .sidebar { width: 320px; }
}

/* ---------- celular ---------- */
@media (max-width: 760px) {
  :root { font-size: 15px; }
  .app { flex-direction: column-reverse; }
  .rail { width: 100%; flex-direction: row; padding: 4px 4px max(4px, env(safe-area-inset-bottom)); gap: 0; border-top: 1px solid rgba(255,255,255,.08); }
  .rail-brand, .rail-spacer, .rail-out { display: none !important; }
  .rail button { flex: 1; flex-direction: column; gap: 3px; padding: 7px 0 5px; font-size: 11px; border-radius: 8px; }
  .rail button > span:not(.avatar) { display: block; font-size: 11px; }
  .rail-me { border: 0 !important; padding-top: 7px !important; margin: 0; }
  .rail-me-txt { display: flex !important; }
  .rail-me-txt b { display: none; }
  .rail .avatar.sm { width: 22px; height: 22px; font-size: 9px; }
  .rail button.on::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 3px; }
  .rail .dot { right: calc(50% - 18px); top: 4px; }
  .app.chat-aberto .rail { display: none; }
  .admin .rail-out { display: flex !important; }
  .page { padding: 14px; }
  .subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 14px; padding: 0 14px; }
  .subtabs button { flex: none; }
  .tabs button { padding: 5px 10px; }
  .card { padding: 15px; border-radius: 10px; }
  .sidebar { width: 100%; border-right: 0; }
  .main.chat-open .sidebar { display: none; }
  .main:not(.chat-open) .chat, .main:not(.chat-open) .placeholder { display: none; }
  .msgs { padding: 10px; }
  .bubble { max-width: 86%; }
  .grid2 { grid-template-columns: 1fr; }
  .chat-head { padding: 7px 8px; gap: 8px; }
  .chat-head .title { min-width: 0; }
  .chat-head .title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-head .actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .chat-head .actions button { flex: none; }
  .back { display: inline-flex !important; }
  .composer .send span { display: none; }
  .composer .send { padding: 10px 12px; }
  .side-head #newConv { padding: 6px 10px; }
  input, select, textarea { font-size: 16px; } /* evita zoom no iPhone */
  .modal { padding: 18px; }
}
