/* ============================================================
   Conversas — layout e bubbles (LG-2B)
   ============================================================ */

/* ─── Layout 3 colunas ─────────────────────────────────────── */
.conv-layout {
  display: grid;
  grid-template-columns: 320px 1fr;  /* padrão: painel de detalhes FECHADO */
  height: calc(100vh - var(--header-h, 56px));
  gap: 0;
  margin: -20px -24px;  /* anula exatamente o padding do .lg-main (20px 24px) */
  background: var(--bg);
  overflow: hidden;
}

/* Painel direito aberto: vira 3 colunas (controlado por classe) */
.conv-layout.detail-open {
  grid-template-columns: 320px 1fr 320px;
}

/* ─── Coluna esquerda: lista ───────────────────────────────── */
.conv-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(198, 202, 208, 0.12);
  background: var(--bg-2);
  overflow: hidden;
}

.conv-sidebar-header {
  padding: 16px 14px 10px;
  border-bottom: 1px solid rgba(198, 202, 208, 0.1);
}

.conv-search-wrap {
  margin-bottom: 12px;
}
.conv-search {
  font-size: 13px;
}

.conv-filters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conv-filter-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12.5px;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.conv-filter-btn:hover {
  background: rgba(198, 202, 208, 0.06);
  color: var(--gold-light);
}
.conv-filter-btn.active {
  background: rgba(198, 202, 208, 0.12);
  border-color: rgba(198, 202, 208, 0.32);
  color: var(--gold-light);
}
.conv-filter-count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(198, 202, 208, 0.16);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(198, 202, 208, 0.2) transparent;
}
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(198, 202, 208, 0.2); border-radius: 3px; }

.conv-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--mute);
  font-size: 13px;
  font-style: italic;
}

.conv-list-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(198, 202, 208, 0.06);
  cursor: pointer;
  transition: background 0.1s ease;
}
.conv-list-item:hover {
  background: rgba(198, 202, 208, 0.04);
}
.conv-list-item.active {
  background: rgba(198, 202, 208, 0.1);
  border-left: 3px solid var(--gold);
  padding-left: 11px;
}

.conv-list-item-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 8px;
}
.conv-list-name {
  font-weight: 500;
  color: var(--text);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.conv-list-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--mute);
  white-space: nowrap;
  flex-shrink: 0;
}

.conv-list-item-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.conv-list-preview {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.conv-unread-badge {
  background: var(--gold);
  color: var(--on-gold);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.conv-list-assignee {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--mute);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Priority dots */
.conv-priority-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conv-priority-high {
  background: #e8a89e;
  box-shadow: 0 0 6px rgba(232, 168, 158, 0.6);
}

/* ─── Coluna central: janela de mensagens ──────────────────── */
.conv-window {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.conv-window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(198, 202, 208, 0.12);
  background: var(--bg-2);
  flex-shrink: 0;
}
.conv-header-info {
  flex: 1;
  min-width: 0;
}
.conv-header-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-header-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.conv-header-channel {
  padding: 2px 8px;
  background: rgba(198, 202, 208, 0.1);
  border: 1px solid rgba(198, 202, 208, 0.2);
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.conv-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Empty state (sem conversa selecionada) */
.conv-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 60px 20px;
}
.conv-empty-icon {
  font-size: 56px;
  color: rgba(198, 202, 208, 0.18);
  font-family: var(--font-display);
  line-height: 1;
}
.conv-empty-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--gold-light);
}
.conv-empty-sub {
  font-size: 13px;
  color: var(--text-2);
  max-width: 320px;
}

/* Área de mensagens */
.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(198, 202, 208, 0.2) transparent;
}
.conv-messages::-webkit-scrollbar { width: 6px; }
.conv-messages::-webkit-scrollbar-thumb { background: rgba(198, 202, 208, 0.2); border-radius: 3px; }

.conv-messages-empty {
  text-align: center;
  color: var(--mute);
  font-style: italic;
  padding: 40px 0;
}

.conv-day-divider {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}
.conv-day-divider span {
  background: rgba(198, 202, 208, 0.08);
  border: 1px solid rgba(198, 202, 208, 0.16);
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 12px;
  border-radius: 12px;
  letter-spacing: 0.04em;
}

/* Bubbles */
.conv-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  position: relative;
  word-break: break-word;
  animation: bubble-in 0.18s ease;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.conv-bubble-in {
  align-self: flex-start;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.conv-bubble-out {
  align-self: flex-end;
  /* Platina do sistema (--gold-pure #c6cad0) */
  background: rgba(198, 202, 208, 0.16);
  border: 1px solid rgba(198, 202, 208, 0.42);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.conv-bubble.pending {
  opacity: 0.6;
}
.conv-bubble.failed {
  border-color: rgba(196, 70, 56, 0.4);
  background: rgba(196, 70, 56, 0.08);
}

.conv-bubble-sender {
  display: block;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.conv-bubble-text {
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.conv-bubble-muted {
  font-style: italic;
  color: var(--mute);
}

.conv-bubble-media img,
.conv-bubble-media video {
  display: block;
  max-width: 360px;
  max-height: 320px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 6px;
}

.conv-bubble-audio { width: 100%; }
.conv-bubble-audio audio {
  width: 100%;
  max-width: 280px;
  height: 36px;
}
/* Bolha de áudio precisa de largura pro player respirar, sem estourar */
.conv-bubble:has(.conv-bubble-audio) {
  width: 300px;
  max-width: 80%;
}

/* Figurinha: pequena, transparente, sem moldura de bolha */
.conv-bubble-sticker img {
  display: block;
  width: 128px;
  height: 128px;
  object-fit: contain;
}
.conv-bubble:has(.conv-bubble-sticker) {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px 0 !important;
}

.conv-bubble-document {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  text-decoration: none;
  color: inherit;
}
.conv-doc-icon {
  font-size: 28px;
}
.conv-doc-info { display: flex; flex-direction: column; }
.conv-doc-name { font-weight: 500; font-size: 13px; }
.conv-doc-size {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--mute);
}

.conv-bubble-caption {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}

.conv-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--mute);
}
.conv-msg-status {
  font-size: 11px;
  letter-spacing: -2px;
}
.conv-status-delivered { color: var(--text-2); }
.conv-status-read      { color: #6fd17e; }
.conv-status-failed    { color: #e8a89e; }

/* ─── Composer ─────────────────────────────────────────────── */
.conv-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 22px 16px;
  border-top: 1px solid rgba(198, 202, 208, 0.12);
  background: var(--bg-2);
  flex-shrink: 0;
}
.conv-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid rgba(198, 202, 208, 0.22);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 18px;
  transition: background 0.12s ease;
}
.conv-attach-btn:hover {
  background: rgba(198, 202, 208, 0.08);
  color: var(--gold-light);
}

/* Botão de microfone (mesma pegada do anexo) */
.conv-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid rgba(198, 202, 208, 0.22);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 18px;
  transition: background 0.12s ease;
}
.conv-mic-btn:hover {
  background: rgba(198, 202, 208, 0.08);
  color: var(--gold-light);
}

/* Barra de gravação de áudio */
.conv-recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.conv-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5484d;
  animation: conv-rec-pulse 1s ease-in-out infinite;
}
@keyframes conv-rec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
.conv-rec-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-weight: 600;
  min-width: 42px;
}
.conv-rec-cancel {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-2);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}
.conv-rec-cancel:hover { color: #e5484d; border-color: #e5484d; }
.conv-composer-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid rgba(198, 202, 208, 0.22);
  color: var(--gold-light);
  border-radius: 6px;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  min-height: 38px;
  max-height: 140px;
  outline: none;
  transition: border-color 0.12s ease;
}
.conv-composer-input:focus {
  border-color: rgba(198, 202, 208, 0.5);
}

.conv-composer-disabled {
  padding: 14px 22px 18px;
  border-top: 1px solid rgba(198, 202, 208, 0.12);
  background: var(--bg-2);
  text-align: center;
  font-size: 12.5px;
  color: var(--mute);
  font-style: italic;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

/* ─── Coluna direita: painel de detalhes ──────────────────── */
.conv-detail-panel {
  border-left: 1px solid rgba(198, 202, 208, 0.12);
  background: var(--bg-2);
  overflow-y: auto;
  padding: 22px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(198, 202, 208, 0.2) transparent;
}
.conv-detail-panel::-webkit-scrollbar { width: 6px; }
.conv-detail-panel::-webkit-scrollbar-thumb { background: rgba(198, 202, 208, 0.2); border-radius: 3px; }

.conv-detail-header {
  text-align: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(198, 202, 208, 0.1);
  margin-bottom: 18px;
}
.conv-detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(198, 202, 208, 0.2) 0%, rgba(198, 202, 208, 0.05) 100%);
  border: 1px solid rgba(198, 202, 208, 0.32);
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}
.conv-detail-name {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text);
  margin-bottom: 4px;
}
.conv-detail-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.conv-detail-name-row .conv-detail-name { margin-bottom: 0; }
.conv-name-edit {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(198, 202, 208, 0.3);
  border-radius: 7px;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: all .15s ease;
}
.conv-name-edit:hover {
  color: var(--gold-pure, #c6cad0);
  border-color: rgba(198, 202, 208, 0.6);
}
.conv-detail-phone {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

.conv-detail-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(198, 202, 208, 0.08);
}
.conv-detail-section:last-child {
  border-bottom: none;
}
.conv-detail-label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  margin-bottom: 6px;
}
.conv-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.conv-detail-actions .lg-btn {
  flex: 1 1 calc(50% - 4px);
  justify-content: center;
}
.conv-detail-value {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.conv-detail-muted {
  font-size: 12.5px;
  color: var(--mute);
  font-style: italic;
}
.conv-detail-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--mute);
  margin-top: 6px;
}

.conv-priority-buttons {
  display: flex;
  gap: 4px;
}
.conv-priority-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(198, 202, 208, 0.18);
  color: var(--text-2);
  padding: 6px 4px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.conv-priority-btn:hover {
  background: rgba(198, 202, 208, 0.06);
}
.conv-priority-btn.active {
  background: rgba(198, 202, 208, 0.16);
  border-color: rgba(198, 202, 208, 0.5);
  color: var(--gold-light);
}

/* ─── Responsividade ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .conv-detail-panel {
    display: none !important;
  }
  .conv-layout {
    grid-template-columns: 300px 1fr;
  }
}
@media (max-width: 720px) {
  /* Mobile tratado na seção LG-20.1 abaixo (lista ↔ chat) */
  .conv-layout {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════════════════════
   LG-2C — Template autocomplete + Tags + Notas no painel
   ════════════════════════════════════════════════════════════ */

/* Wrap do composer (pra posicionar autocomplete acima) */
.conv-composer-wrap {
  position: relative;
}

/* Autocomplete de templates */
.conv-template-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 22px;
  right: 22px;
  margin-bottom: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-soft-2) transparent;
}

.conv-template-ac-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--mute);
  text-transform: uppercase;
  background: var(--bg-2);
}
.conv-template-ac-hint {
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 10px;
  color: var(--mute-2);
}

.conv-template-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 80ms ease;
}
.conv-template-ac-item:last-child { border-bottom: none; }
.conv-template-ac-item.active {
  background: var(--gold-soft);
}
.conv-template-ac-item:hover {
  background: var(--gold-soft);
}

.conv-template-ac-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.conv-template-ac-shortcut {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
}
.conv-template-ac-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.conv-template-ac-preview {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tags no painel direito */
.conv-tag-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid var(--line-2);
  color: var(--gold);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  transition: all 120ms ease;
}
.conv-tag-add-btn:hover {
  background: var(--gold-soft-2);
  border-color: var(--gold-dark);
  color: var(--gold-light);
}

.conv-detail-label {
  display: flex;
  align-items: center;
}

.conv-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.conv-tag-applied {
  position: relative;
  padding-right: 24px;
}
.conv-tag-remove {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  transition: opacity 100ms ease;
}
.conv-tag-remove:hover { opacity: 1; }

/* Picker flutuante de tags */
.conv-tag-picker {
  z-index: 9999;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  max-width: 320px;
  padding: 6px;
  max-height: 340px;
  overflow-y: auto;
}
.conv-tag-picker-header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.conv-tag-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conv-tag-picker-item {
  background: transparent;
  border: none;
  text-align: left;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 100ms ease;
}
.conv-tag-picker-item:hover {
  background: var(--gold-soft);
}

/* Notas internas */
.conv-note-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.conv-note-input {
  font-size: 12.5px;
  resize: vertical;
  min-height: 50px;
}

.conv-note-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conv-note {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.conv-note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--mute);
  letter-spacing: 0.04em;
}
.conv-note-author {
  color: var(--gold-light);
  font-weight: 500;
}
.conv-note-when { color: var(--mute); }
.conv-note-del {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--mute-2);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 100ms ease;
}
.conv-note-del:hover { color: #e8a89e; }

.conv-note-body {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   Ajustes de tema claro — conversas (LG-9)
   ============================================================ */
:root[data-theme="light"] .conv-status-read   { color: #3f7a2f; }
:root[data-theme="light"] .conv-status-failed { color: #b23a2d; }

/* Bolha enviada com mais presença no claro */
:root[data-theme="light"] .conv-bubble-out {
  background: rgba(198, 202, 208, 0.20);
  border-color: rgba(198, 202, 208, 0.5);
}
:root[data-theme="light"] .conv-bubble-in {
  background: #FFFFFF;
}

/* ============================================================
   Cabeçalho estilo Uzitech + nova conversa (LG-9.3)
   ============================================================ */
.conv-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.conv-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-title-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-light);
  background: var(--gold-soft-2);
  padding: 2px 9px;
  border-radius: 999px;
}
.conv-new-btn {
  background: var(--gold-gradient);
  color: var(--on-gold);
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s ease, transform 0.1s ease;
}
.conv-new-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* Tabs de atribuição */
.conv-tabs {
  display: flex;
  gap: 2px;
  margin: 10px 0 8px;
  border-bottom: 1px solid var(--line);
}
.conv-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--mute);
  padding: 7px 4px;
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.conv-tab:hover { color: var(--text-2); }
.conv-tab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  font-weight: 600;
}
.conv-tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.8;
}

/* Pills de status */
.conv-status-filters {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.conv-status-pill {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.conv-status-pill:hover { border-color: var(--line-3); color: var(--text); }
.conv-status-pill.active {
  background: var(--gold-soft-2);
  border-color: rgba(198, 202, 208, 0.4);
  color: var(--gold-light);
  font-weight: 600;
}
.conv-pill-count { font-family: var(--font-mono); font-size: 10px; opacity: 0.85; }

/* ─── Modal nova conversa ──────────────────────────────────── */
.cv-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.cv-modal {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
}
.cv-modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.cv-modal-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 20px;
}
.cv-field { margin-bottom: 14px; }
.cv-field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}
.cv-field-input { width: 100%; box-sizing: border-box; }
textarea.cv-field-input { resize: vertical; font-family: var(--font-body); }
.cv-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ============================================================
   Respostas rápidas — botão + painel visual (LG-9.5)
   ============================================================ */
.conv-quick-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--gold-light);
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.conv-quick-btn:hover {
  background: var(--gold-soft);
  border-color: var(--line-2);
}

.conv-quick-panel {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  margin-bottom: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.45);
  max-height: 320px;
  overflow: hidden;
  z-index: 50;
}
.conv-quick-head {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  border-bottom: 1px solid var(--line);
}
.conv-quick-list {
  max-height: 270px;
  overflow-y: auto;
  padding: 6px;
}
.conv-quick-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "shortcut label" "shortcut preview";
  gap: 1px 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  padding: 9px 11px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.12s ease;
}
.conv-quick-item:hover { background: var(--surface-hover); }
.conv-quick-shortcut {
  grid-area: shortcut;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-light);
  background: var(--gold-soft-2);
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.conv-quick-label {
  grid-area: label;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.conv-quick-preview {
  grid-area: preview;
  font-size: 11.5px;
  color: var(--mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-quick-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}
.conv-quick-empty span { font-size: 11px; color: var(--mute); }

/* ============================================================
   SLA — tempo sem resposta (LG-9.6)
   ============================================================ */
.conv-list-item-row3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.conv-sla-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.conv-sla-warn {
  background: rgba(198, 202, 208, 0.16);
  color: var(--gold-light);
}
.conv-sla-crit {
  background: rgba(196, 70, 56, 0.18);
  color: #e8897d;
}
/* Borda esquerda na linha conforme o nível */
.conv-list-item.conv-sla-row-warn { border-left: 2px solid var(--gold); }
.conv-list-item.conv-sla-row-crit { border-left: 2px solid #c44638; }

/* Pill "Paradas" */
.conv-status-pill.conv-pill-sla { border-color: rgba(196, 70, 56, 0.3); }
.conv-status-pill.conv-pill-sla.active {
  background: rgba(196, 70, 56, 0.15);
  border-color: rgba(196, 70, 56, 0.45);
  color: #e8897d;
}

/* ─── Mobile (LG-20.1) ────────────────────────────────────── */
.conv-back-btn { display: none; }
.conv-detail-back { display: none; }

@media (max-width: 768px) {
  /* Layout vira uma coluna só; alterna lista ↔ chat */
  .conv-layout {
    display: block;            /* abandona o grid no mobile */
    height: auto;
    min-height: calc(100vh - var(--header-h, 56px) - 28px);
    margin: -14px -12px;       /* anula o padding mobile do .lg-main */
    position: relative;
  }
  /* Lista ocupa toda a largura/altura */
  .conv-sidebar {
    width: 100%;
    height: calc(100vh - var(--header-h, 56px) - 28px);
  }

  /* Por padrão (sem conversa aberta): mostra a lista, esconde a janela */
  .conv-window { display: none; }
  .conv-detail-panel { display: none !important; }

  /* Com conversa aberta: esconde a lista, mostra a janela em tela cheia */
  .conv-layout.conv-mobile-chat .conv-sidebar { display: none; }
  /* Com conversa aberta: janela em tela cheia REAL, cobrindo o header global.
     position:fixed + 100dvh resolve (a) o cabeçalho com o ponto verde
     aparecendo e (b) o espaço escuro abaixo do composer (agora ele cola no
     fundo real da tela, respeitando a barra do navegador). */
  .conv-layout.conv-mobile-chat .conv-window {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 200;            /* acima do .lg-header (z-index 100) */
    height: 100vh;
    height: 100dvh;          /* viewport dinâmico p/ a barra do navegador */
    background: var(--bg);
  }
  /* Esconde o header global do app enquanto o chat está aberto no mobile */
  body.conv-chat-open .lg-header { display: none !important; }

  /* Botão voltar visível só no mobile */
  .conv-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    margin-right: 6px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    border-radius: var(--radius);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .conv-back-btn:hover { background: var(--surface-hover); }

  /* Header da conversa: tudo numa linha — [←] [nome/número] [Detalhes] */
  .conv-window-header {
    flex-wrap: nowrap;
    padding: 10px 12px;
    gap: 8px;
    align-items: center;
  }
  .conv-header-info {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }
  .conv-back-btn { order: 0; }
  .conv-header-name { font-size: 16px; margin-bottom: 2px; }
  .conv-header-meta { font-size: 11px; gap: 6px; flex-wrap: wrap; }
  /* Ações ficam à DIREITA, na mesma linha do número (não descem mais) */
  .conv-header-actions {
    order: 2;
    flex: 0 0 auto;
  }
  .conv-header-actions .lg-btn { white-space: nowrap; }

  /* Composer: nunca quebra linha; botões compactos e o input toma o resto.
     padding-bottom respeita a barra de gestos do Android. */
  .conv-composer {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .conv-composer-input {
    font-size: 14px;
    min-width: 0;          /* deixa o input encolher em vez de empurrar/quebrar */
  }
  .conv-attach-btn,
  .conv-mic-btn,
  .conv-quick-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    font-size: 16px;
  }
  .conv-composer .lg-btn {
    flex-shrink: 0;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
  }

  /* Painel de detalhes vira overlay full quando aberto */
  .conv-layout.conv-mobile-chat .conv-detail-panel[style*="block"] {
    display: block !important;
    position: fixed;            /* fixed + z-index acima do window (200) */
    inset: 0;
    z-index: 210;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-2);
    overflow-y: auto;
    padding: 0 0 calc(20px + env(safe-area-inset-bottom, 0px));
  }
  /* Conteúdo do painel ganha respiro lateral (já que o painel perdeu o padding) */
  .conv-layout.conv-mobile-chat .conv-detail-panel[style*="block"] .conv-detail-header,
  .conv-layout.conv-mobile-chat .conv-detail-panel[style*="block"] .conv-detail-section {
    padding-left: 18px;
    padding-right: 18px;
  }
  .conv-layout.conv-mobile-chat .conv-detail-panel[style*="block"] .conv-detail-header {
    padding-top: 18px;
    margin-top: 0;
  }
  /* Botão voltar: barra sólida fixa no topo, conteúdo começa abaixo dela */
  .conv-detail-back {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-3);
    border: none;
    border-bottom: 1px solid var(--line);
    color: var(--gold-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: sticky;
    top: 0;
    z-index: 5;
  }
}
