/* Chassi-Bora — provisório. Tela de Atendimento apenas. Light/clean. */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --sidebar: #F7F8FA;
  --content: #FAFBFC;
  --line: #E5E7EB;
  --line-strong: #D1D5DB;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6B7280;
  --muted-soft: #9CA3AF;
  --accent: #2563EB;
  --accent-soft: #DBEAFE;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --aniv: #7C3AED;
  --rsv: #0EA5E9;
  --prog: #059669;
  --pos: #DB2777;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
}
.logo-slot {
  font-weight: 700;
  font-size: 16px;
  padding: 4px 10px 18px;
  letter-spacing: -.01em;
}
.logo-slot small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item, a.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--ink-soft); text-decoration: none;
  cursor: pointer; font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: rgba(0,0,0,.04); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 16px; height: 16px; stroke-width: 2; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }

.sidebar-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-top: 1px solid var(--line); margin-top: 8px;
}
.sidebar-foot .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}
.sidebar-foot .uinfo { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-foot .uinfo b { font-size: 13px; font-weight: 600; }
.sidebar-foot .uinfo span { font-size: 11px; color: var(--muted); }
.sidebar-foot .logout {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-decoration: none;
}
.sidebar-foot .logout:hover { color: var(--ink); background: rgba(0,0,0,.04); }
.sidebar-foot .logout svg { width: 14px; height: 14px; stroke-width: 2; }

/* ---------- Main + topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: 48px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  font-weight: 600; font-size: 14px; color: var(--ink-soft);
}
.topbar .tag-prov {
  margin-left: auto;
  font-size: 11px; font-weight: 500; color: var(--warn);
  background: var(--warn-soft); padding: 3px 8px; border-radius: 4px;
}

.content { flex: 1; overflow: hidden; background: var(--content); }
.content-fixed { display: flex; }

/* ---------- Chat (3 colunas) ---------- */
.chat {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  width: 100%; height: 100%;
}

/* Coluna 1 — conversas */
.conv-col { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.conv-head { padding: 12px; border-bottom: 1px solid var(--line); }
.conv-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); background: var(--bg);
  font-size: 13px; margin-bottom: 10px;
}
.conv-search svg { width: 14px; height: 14px; stroke-width: 2; }

.conv-filters { display: flex; gap: 6px; }
.fpill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 999px; font-size: 12px; color: var(--ink-soft); cursor: pointer;
}
.fpill .ct { font-size: 11px; background: var(--ink-soft); color: white; border-radius: 999px; padding: 0 6px; }
.fpill.alert { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }
.fpill.alert .ct { background: var(--warn); }
.fpill.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.conv-scroll { flex: 1; overflow-y: auto; }
.conv {
  display: flex; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.conv:hover { background: #F9FAFB; }
.conv.active { background: var(--accent-soft); }

.av {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: white;
  background: var(--muted-soft);
}
.av.f { background: #F472B6; }
.av.m { background: #60A5FA; }

.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.conv-line { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.conv-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.chan { width: 13px; height: 13px; display: inline-flex; align-items: center; justify-content: center; }
.chan svg { width: 100%; height: 100%; }
.chan.wa { color: #25D366; }
.chan.ig { color: #E1306C; }
.chan.ms { color: #0084FF; }

.tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 500; color: white; }
.tag.aniv { background: var(--aniv); }
.tag.rsv { background: var(--rsv); }
.tag.prog { background: var(--prog); }
.tag.pos { background: var(--pos); }

/* Coluna 2 — thread */
.thread { background: var(--content); display: flex; flex-direction: column; min-width: 0; }
.thread-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.thread-head .th-id { display: flex; flex-direction: column; line-height: 1.2; }
.thread-head .th-id b { font-size: 14px; font-weight: 600; }
.thread-head .th-id span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 80%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.msg.out .bubble { background: var(--accent); color: white; border-color: var(--accent); }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; padding: 0 4px; }
.by { font-weight: 600; padding: 1px 5px; border-radius: 3px; font-size: 10px; }
.by.ia { background: var(--accent-soft); color: var(--accent); }
.by.human { background: #ECFDF5; color: #059669; }

.photo { width: 160px; height: 100px; background: var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.photo svg { width: 32px; height: 32px; stroke-width: 1.5; }
.audio { display: flex; align-items: center; gap: 10px; }
.audio .play { width: 28px; height: 28px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.audio .play svg { width: 14px; height: 14px; }
.msg.out .audio .play { background: white; color: var(--accent); }
.audio .wave { flex: 1; min-width: 60px; height: 2px; background: rgba(255,255,255,.4); border-radius: 2px; }
.audio .dur { font-size: 11px; opacity: .8; }

.composer { padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); position: relative; }

/* ----- Popup do Acervo (mensagens salvas) ----- */
.acervo-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 16px;
  width: 360px;
  max-height: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  z-index: 100;
}
.acervo-popup[hidden] { display: none; }

.ap-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.ap-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.ap-new {
  font-size: 12px; padding: 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 4px; cursor: pointer;
  font-weight: 500; font-family: inherit;
}
.ap-new:hover { background: var(--accent); color: white; }

.ap-search { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ap-search[hidden] { display: none; }
.ap-search input {
  width: 100%; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 4px;
  font-size: 12px; font-family: inherit; color: var(--ink);
  background: var(--bg);
}
.ap-search input:focus { outline: none; border-color: var(--accent); }

.ap-list { flex: 1; overflow-y: auto; max-height: 280px; }
.ap-list[hidden] { display: none; }
.ap-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px; cursor: pointer;
  border-bottom: 1px solid #F3F4F6;
}
.ap-item:hover { background: #F9FAFB; }
.ap-item:last-child { border-bottom: none; }
.ap-item-main { flex: 1; min-width: 0; }
.ap-item-title { font-size: 12px; font-weight: 600; color: var(--ink); }
.ap-item-preview {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ap-item-actions {
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.ap-item:hover .ap-item-actions { opacity: 1; }
.ap-item-actions button {
  width: 22px; height: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted-soft);
}
.ap-item-actions button:hover { color: var(--ink); border-color: var(--line-strong); }
.ap-item-actions button svg { width: 12px; height: 12px; stroke-width: 2; }
.ap-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 12px; }

.ap-form { padding: 12px 14px; }
.ap-form[hidden] { display: none; }
.ap-form input,
.ap-form textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 4px;
  font-family: inherit; font-size: 12px; color: var(--ink); background: var(--bg);
  margin-bottom: 8px;
}
.ap-form textarea { min-height: 80px; resize: vertical; line-height: 1.4; }
.ap-form input:focus,
.ap-form textarea:focus { outline: none; border-color: var(--accent); }
.ap-form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ap-form-actions button {
  padding: 6px 14px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.ap-cancel { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }
.ap-save { background: var(--accent); color: white; border: 1px solid var(--accent); }
.ap-save:hover { background: #1D4ED8; }

/* ----- Agendamento de envio ----- */
.schedule-btn {
  width: 36px; height: 36px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-family: inherit;
}
.schedule-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.schedule-btn svg { width: 16px; height: 16px; stroke-width: 2; }

.schedule-popup {
  position: absolute; bottom: calc(100% + 8px); right: 16px;
  width: 280px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  padding: 12px 14px; z-index: 100;
}
.schedule-popup[hidden] { display: none; }
.sp-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.schedule-popup input[type="datetime-local"] {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 4px;
  font-family: inherit; font-size: 12px; color: var(--ink); background: var(--bg);
  margin-bottom: 10px;
}
.schedule-popup input[type="datetime-local"]:focus { outline: none; border-color: var(--accent); }
.sp-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sp-actions button {
  padding: 6px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.sp-cancel { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }
.sp-save { background: var(--accent); color: white; border: 1px solid var(--accent); }
.sp-save:hover { background: #1D4ED8; }

.msg.scheduled .bubble {
  background: #F3F4F6; color: var(--ink-soft);
  border: 1px dashed var(--line);
}
.schedule-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); margin-bottom: 6px;
  padding-bottom: 6px; border-bottom: 1px dashed var(--line);
}
.schedule-meta svg { width: 12px; height: 12px; stroke-width: 2; }
.schedule-cancel {
  margin-left: auto;
  background: none; border: none; font-size: 16px; color: var(--muted);
  cursor: pointer; padding: 0 6px; border-radius: 4px; line-height: 1;
}
.schedule-cancel:hover { color: var(--ink); background: rgba(0,0,0,.06); }
.suggest-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 500; border-radius: 4px; margin-bottom: 8px;
}
.suggest-tag svg { width: 12px; height: 12px; }
.suggest-tag .clr { margin-left: 6px; cursor: pointer; opacity: .7; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 2; }
.composer textarea {
  flex: 1; min-height: 36px; max-height: 120px; resize: none;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 13px; line-height: 1.5; color: var(--ink);
  background: var(--bg);
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--accent); color: white;
  border: none; border-radius: 6px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.send-btn svg { width: 14px; height: 14px; stroke-width: 2; }

/* Coluna 3 — painel */
.panel { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; }
.p-sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.p-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.dial { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.dial button { flex: 1; padding: 6px 10px; border: none; background: var(--bg); color: var(--ink-soft); font-size: 12px; font-weight: 500; cursor: pointer; }
.dial button.on { background: var(--accent); color: white; }
.dial-note { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.ficha-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.ficha-row .k { color: var(--muted); }
.ficha-row .v { color: var(--ink); font-weight: 500; }

.an-item { margin-bottom: 8px; }
.an-k { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.an-v { font-size: 12px; color: var(--ink); font-weight: 500; }
.an-v.warn { color: var(--warn); }

.resumo { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }

.act {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  cursor: pointer; margin-bottom: 6px;
}
.act svg { width: 14px; height: 14px; stroke-width: 2; }
.act.primary { background: var(--accent); color: white; border: 1px solid var(--accent); }
.act.ghost { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }
