/* ============================================================
   CONVERSA AO LADO (10/out) · modules/crm/conversa-lado.js
   1. .cc-*  coluna da última conversa no perfil da lead
   2. .rx-*  "Sobre a conversa" ao lado do chat no inbox
   Tokens da casa (--v2-*), zero azul, zero vermelho, nada de contador.
   ============================================================ */

/* ── 1 · PERFIL DA LEAD em duas colunas ─────────────────────── */
.crm-perfil-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); grid-template-areas: "main conv"; gap: 18px; align-items: start; }
.crm-perfil-main { grid-area: main; min-width: 0; }
.cc-col { grid-area: conv; position: sticky; top: 14px; min-width: 0; }
@media (max-width: 1180px) {
  .crm-perfil-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "conv" "main"; }
  .cc-col { position: static; }
  /* empilhado: a conversa vem primeiro, compacta, pra ficha aparecer logo abaixo */
  .cc-col .cc-thread { max-height: 230px; min-height: 150px; }
  .cc-head { padding: 12px 16px 8px; }
  .cc-foot { padding: 10px 16px 12px; }
}

.cc-card { background: var(--card, #FFFFFF); border: 1px solid var(--v2-line); border-radius: 18px; box-shadow: 0 1px 2px rgba(46,42,38,.05), 0 10px 30px rgba(46,42,38,.06); overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 28px); }
.cc-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.cc-ico { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; background: #F4EEE4; color: #7A5F26; display: inline-flex; align-items: center; justify-content: center; }
.cc-head-txt { min-width: 0; }
.cc-eyebrow { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: #9B7B3E; }
.cc-tit { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--v2-ink); line-height: 1.2; margin-top: 2px; }
.cc-sub { font-size: 11px; color: var(--v2-sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cc-abas { display: flex; gap: 6px; padding: 0 18px 10px; flex-wrap: wrap; }
.cc-abas button { border: 1px solid var(--v2-line); background: #FFFFFF; border-radius: 999px; padding: 4px 11px; font-size: 10.5px; color: var(--v2-sub); cursor: pointer; font-family: var(--font-body); }
.cc-abas button.on { background: var(--v2-sidebar); border-color: var(--v2-sidebar); color: #F3EEE5; }

.cc-status { display: flex; align-items: center; gap: 8px; margin: 0 18px 10px; padding: 8px 12px; border-radius: 10px; background: #F7F3EC; font-size: 11.5px; color: var(--v2-sub); line-height: 1.4; }
.cc-status.dela { background: #F5EDD9; color: #7A5F26; }
.cc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--v2-ter); flex: 0 0 7px; }
.cc-status.dela .cc-dot { background: var(--v2-gold); }

.cc-thread { flex: 1 1 auto; min-height: 220px; max-height: 52vh; overflow-y: auto; padding: 14px 14px 16px; border-top: 1px solid var(--v2-line); border-bottom: 1px solid var(--v2-line); }
.cc-thread .wa-bubble { max-width: 86%; font-size: 12px; }
.cc-thread .wa-bubble img { max-width: 220px; }
.cc-thread .wa-edit-btn { display: none; }   /* editar e reenviar moram no inbox */

.cc-foot { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 7px; }
.cc-abrir { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--v2-sidebar); color: #F3EEE5; font-family: var(--font-body); font-size: 13px; font-weight: 600; letter-spacing: .01em; cursor: pointer; transition: background .15s ease, transform .15s ease; }
.cc-abrir:hover { background: #2E2822; }
.cc-abrir:active { transform: translateY(1px); }
.cc-abrir:focus-visible { outline: 2px solid var(--v2-gold); outline-offset: 2px; }
.cc-abrir svg:last-child { opacity: .7; }
.cc-hint { font-size: 10.5px; color: var(--v2-ter); text-align: center; line-height: 1.4; }

.cc-vazio { padding: 26px 22px 22px; text-align: center; border-top: 1px solid var(--v2-line); color: var(--v2-sub); font-size: 12.5px; line-height: 1.55; }
.cc-vazio p { margin: 0 0 6px; }
.cc-vazio-ico { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; background: #F7F3EC; color: #B9A68C; display: flex; align-items: center; justify-content: center; }
.cc-link { border: 0; background: none; padding: 0; color: #7A5F26; text-decoration: underline; cursor: pointer; font: inherit; }

.cc-esqueleto { display: flex; flex-direction: column; gap: 10px; background: var(--v2-canvas); }
.cc-esqueleto span { display: block; height: 30px; width: 62%; border-radius: 12px; background: linear-gradient(90deg, #EFE8DC 0%, #F7F2EA 50%, #EFE8DC 100%); background-size: 200% 100%; animation: cc-brilho 1.4s ease-in-out infinite; }
.cc-esqueleto span.d { align-self: flex-end; width: 48%; }
@keyframes cc-brilho { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── 2 · INBOX · "Sobre a conversa" ─────────────────────────── */
/* com a leitura aberta a terceira coluna é dela, em qualquer largura
   acima de 1320 (a do agente vira faixa no topo só quando ela está fechada) */
.wa-wrap.rx-on, .wa-wrap.rx-on.ag-off { grid-template-columns: 300px minmax(0, 1fr) 344px; grid-template-rows: minmax(0, 1fr); grid-template-areas: "list chat agent"; }
.wa-wrap.rx-on .wa-panel.agent { display: none; }
.wa-panel.rx { grid-area: agent; min-width: 0; background: #FDFBF7; }
@media (max-width: 1500px) {
  .wa-wrap.rx-on, .wa-wrap.rx-on.ag-off { grid-template-columns: 256px minmax(0, 1fr) 308px; min-height: 620px; }
}
/* tela estreita: gaveta por cima do chat, aberta pelo botão "Sobre a conversa"
   (abaixo de 1320 a terceira coluna deixaria o chat com menos de 420px) */
@media (max-width: 1320px) {
  .wa-wrap.rx-on, .wa-wrap.rx-on.ag-off { grid-template-columns: 286px minmax(0, 1fr); grid-template-areas: "list chat"; position: relative; }
  .wa-wrap.rx-on .wa-panel.rx { display: none; }
  .wa-wrap.rx-on.rx-gaveta .wa-panel.rx { display: flex; position: absolute; top: 0; right: 0; bottom: 0; width: min(360px, 92%); z-index: 30; box-shadow: -18px 0 40px rgba(33,29,24,.16); }
}
@media (max-width: 900px) {
  .wa-wrap.rx-on, .wa-wrap.rx-on.ag-off { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "list" "chat"; }
  .wa-wrap.rx-on.rx-gaveta .wa-panel.rx { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); border-radius: 0; z-index: 1000; }
}

.wa-rx-btn.on { border-color: rgba(176,138,46,.55); color: #7A5F26; background: #FBF6EA; }

.rx-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--v2-line); background: #FFFFFF; }
.rx-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rx-eyebrow { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: #9B7B3E; }
.rx-x { border: 0; background: transparent; cursor: pointer; color: var(--v2-ter); font-size: 13px; width: 26px; height: 26px; border-radius: 50%; }
.rx-x:hover { background: #F4EEE4; color: var(--v2-ink); }
.rx-nome { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--v2-ink); line-height: 1.2; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-sub { font-size: 11px; color: var(--v2-sub); margin-top: 2px; }
.rx-head-acts { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rx-ficha { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--v2-line); background: #FFFFFF; border-radius: 999px; padding: 5px 12px; font-size: 11px; font-weight: 600; color: var(--v2-ink); cursor: pointer; font-family: var(--font-body); }
.rx-ficha:hover { border-color: var(--v2-gold); }
.rx-lido { font-size: 10px; color: var(--v2-ter); display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rx-link { border: 0; background: none; padding: 0; color: var(--v2-sub); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; font-size: inherit; }
.rx-link:hover { color: var(--v2-ink); }

.rx-body { flex: 1; overflow-y: auto; padding: 14px 14px 22px; display: flex; flex-direction: column; gap: 14px; }

.rx-parou { background: #FFFFFF; border: 1px solid var(--v2-line); border-left: 3px solid var(--v2-ter); border-radius: 12px; padding: 11px 13px; }
.rx-parou.equipe { border-left-color: var(--v2-gold); background: #FFFCF5; }
.rx-parou.ela { border-left-color: var(--v2-verde); }
.rx-parou-lab { display: flex; align-items: center; gap: 7px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--v2-sub); margin-bottom: 4px; }
.rx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--v2-ter); }
.rx-parou.equipe .rx-dot { background: var(--v2-gold); }
.rx-parou.ela .rx-dot { background: var(--v2-verde); }
.rx-parou p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--v2-ink); }

.rx-sec { display: flex; flex-direction: column; gap: 7px; }
.rx-lab { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--v2-ter); }
.rx-resumo { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--v2-ink); }

.rx-passos { margin: 0; padding: 0; list-style: none; counter-reset: rx; display: flex; flex-direction: column; gap: 8px; }
.rx-passos li { counter-increment: rx; position: relative; padding: 0 0 0 28px; display: flex; flex-direction: column; gap: 2px; }
.rx-passos li::before { content: counter(rx); position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: #F4EEE4; color: #7A5F26; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rx-passos b { font-size: 12.5px; font-weight: 600; color: var(--v2-ink); line-height: 1.45; }
.rx-passos span { font-size: 11.5px; color: var(--v2-sub); line-height: 1.45; }
.rx-tarefa { align-self: flex-start; font-size: 10.5px; margin-top: 1px; }

.rx-obj { background: #FFFFFF; border: 1px solid var(--v2-line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.rx-tema { align-self: flex-start; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; color: #8A4A33; background: #F7ECE6; border-radius: 6px; padding: 2px 8px; }
.rx-obj q { font-size: 12px; font-style: italic; color: var(--v2-sub); line-height: 1.5; quotes: "“" "”"; }
.rx-obj p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--v2-ink); }

.rx-atencao, .rx-comb { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rx-atencao li { font-size: 12px; line-height: 1.5; color: var(--v2-ink); padding: 7px 10px; border-radius: 8px; background: #F9F1EC; border-left: 3px solid var(--v2-terracota); }
.rx-comb li { font-size: 12px; line-height: 1.5; color: var(--v2-ink); padding-left: 14px; position: relative; }
.rx-comb li::before { content: ''; position: absolute; left: 2px; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--v2-gold); }

.rx-msg { background: #FFFFFF; border: 1px solid var(--v2-line); border-radius: 14px; padding: 11px 12px 10px; display: flex; flex-direction: column; gap: 7px; transition: border-color .15s ease, box-shadow .15s ease; }
.rx-msg:hover { border-color: rgba(176,138,46,.45); box-shadow: 0 6px 18px rgba(46,42,38,.06); }
.rx-msg-int { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; color: #9B7B3E; }
.rx-msg p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--v2-ink); white-space: pre-wrap; background: #F7F1E6; border-radius: 10px 10px 10px 3px; padding: 9px 11px; }
.rx-msg-acts { display: flex; gap: 6px; justify-content: flex-end; }
.rx-usar { border: 0; background: var(--v2-sidebar); color: #F3EEE5; border-radius: 999px; padding: 6px 15px; font-size: 11px; font-weight: 700; cursor: pointer; font-family: var(--font-body); }
.rx-usar:hover { background: #2E2822; }
.rx-copiar { border: 1px solid var(--v2-line); background: #FFFFFF; color: var(--v2-sub); border-radius: 999px; padding: 6px 13px; font-size: 11px; cursor: pointer; font-family: var(--font-body); }
.rx-copiar:hover { border-color: var(--v2-gold); color: var(--v2-ink); }
.rx-usar:focus-visible, .rx-copiar:focus-visible, .rx-ficha:focus-visible, .rx-link:focus-visible { outline: 2px solid var(--v2-gold); outline-offset: 2px; }
.rx-nota { font-size: 10.5px; color: var(--v2-ter); line-height: 1.45; }

.rx-aviso { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--v2-sub); background: #F7F3EC; border-radius: 10px; padding: 8px 11px; line-height: 1.45; }
.rx-vazio { font-size: 12px; color: var(--v2-sub); line-height: 1.6; text-align: center; padding: 26px 10px; }
.rx-carregando p { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--v2-sub); margin: 6px 0 0; line-height: 1.5; }
.rx-sk { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.rx-sk span { display: block; height: 11px; border-radius: 6px; background: linear-gradient(90deg, #EFE8DC 0%, #F7F2EA 50%, #EFE8DC 100%); background-size: 200% 100%; animation: cc-brilho 1.4s ease-in-out infinite; }
.rx-sk span.c { width: 64%; }
.rx-lendo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--v2-gold); flex: 0 0 7px; animation: rx-pulso 1.4s ease-in-out infinite; display: inline-block; }
@keyframes rx-pulso { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .rx-lendo-dot, .rx-sk span, .cc-esqueleto span { animation: none; }
}
