.inbox-panel { overflow: hidden; }

.inbox-filter {
  display: grid;
  gap: 5px;
  min-width: 210px;
  color: #6d6370;
  font-size: 12px;
  font-weight: 800;
}

.channel-management {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--borda);
  border-radius: 14px;
  background: #fcfbfa;
}

.channel-heading,
.channel-form,
.channel-row,
.chat-header,
.chat-controls,
.reply-form {
  display: flex;
  align-items: end;
  gap: 12px;
}

.channel-heading { justify-content: space-between; }
.channel-heading p,
.qr-panel p { margin: 4px 0 0; color: #746e77; font-size: 13px; }
.channel-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 800; }
.channel-form input,
.reply-form textarea {
  border: 1px solid var(--borda);
  border-radius: 11px;
  padding: 11px 12px;
  background: #fff;
  color: var(--texto);
  font: inherit;
  outline: none;
}
.channel-form input:focus,
.reply-form textarea:focus { border-color: var(--lilas); box-shadow: 0 0 0 3px rgba(164,128,190,.2); }

.secondary-button {
  border: 1px solid var(--roxo);
  border-radius: 10px;
  padding: 11px 14px;
  background: #fff;
  color: var(--roxo);
  font-weight: 800;
}

.channel-list { display: grid; gap: 8px; margin-top: 16px; }
.channel-row {
  justify-content: space-between;
  padding: 11px 12px;
  border: 1px solid var(--borda);
  border-radius: 11px;
  background: #fff;
}
.channel-row div { display: grid; gap: 3px; }
.channel-row small { color: #756d78; }

.qr-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding: 18px;
  border-radius: 12px;
  background: #f2ebf5;
}
.qr-panel img { width: 220px; max-width: 42vw; height: auto; border-radius: 10px; background: #fff; }

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(240px, 32%) minmax(0, 1fr);
  height: clamp(560px, 68vh, 760px);
  min-height: 560px;
  margin-top: 24px;
  border: 1px solid var(--borda);
  border-radius: 15px;
  overflow: hidden;
}
.inbox-layout.has-crm { grid-template-columns: minmax(220px, 25%) minmax(430px, 1fr) minmax(260px, 28%); }

.conversation-column { min-height: 0; overflow-y: auto; background: #fbfaf9; border-right: 1px solid var(--borda); }
.conversation-list { display: grid; }
.conversation-item {
  width: 100%;
  padding: 15px;
  border: 0;
  border-bottom: 1px solid var(--borda);
  background: transparent;
  color: var(--texto);
  text-align: left;
}
.conversation-item:hover,
.conversation-item.active { background: #f1eaf4; }
.conversation-item strong,
.conversation-item span,
.conversation-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item span { margin: 6px 0; color: #615a63; }
.conversation-item small { color: #857c87; }

.chat-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: #fff; }
.conversation-crm-panel { min-width: 0; min-height: 0; overflow-y: auto; border-left: 1px solid var(--borda); background: #fbfaf9; }
.conversation-crm-panel > header { display: grid; gap: 5px; padding: 16px; border-bottom: 1px solid var(--borda); background: #fff; }
.conversation-crm-panel > header strong { font-size: 18px; }
.conversation-crm-form { display: grid; gap: 12px; padding: 16px; }
.conversation-crm-form label { display: grid; gap: 5px; color: #6d6370; font-size: 11px; font-weight: 800; }
.conversation-crm-form input,
.conversation-crm-form select { min-width: 0; width: 100%; padding: 9px 10px; border: 1px solid var(--borda); border-radius: 9px; background: #fff; color: var(--texto); }
.conversation-crm-form input:disabled,
.conversation-crm-form select:disabled { opacity: 1; background: #f3efec; cursor: default; }
.conversation-crm-form button { width: 100%; }
.chat-header { justify-content: space-between; min-height: 82px; padding: 15px 18px; border-bottom: 1px solid var(--borda); }
.chat-header > div:first-child { display: grid; gap: 4px; }
.chat-header span { color: #746e77; font-size: 13px; }
.chat-attribution {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}
.chat-attribution[hidden] { display: none; }
.attribution-chip {
  display: inline-flex;
  max-width: 260px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1eaf4;
  color: var(--roxo);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-controls label { display: grid; gap: 4px; min-width: 150px; color: #6d6370; font-size: 11px; font-weight: 800; }
.chat-controls select { padding: 8px 9px; }

.message-list { min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; background: #f7f5f3; }
.message-bubble { max-width: min(78%, 620px); padding: 10px 13px; border-radius: 13px; background: #fff; box-shadow: 0 3px 14px rgba(42,20,54,.06); }
.message-bubble.outbound { align-self: flex-end; background: #e9dff0; }
.message-sender { display: block; margin-bottom: 5px; color: var(--roxo); font-size: 12px; }
.message-media-image { display: block; width: min(360px, 100%); max-height: 420px; margin-bottom: 8px; border-radius: 9px; object-fit: contain; background: #eee; }
.message-media-file { display: inline-flex; max-width: 100%; margin-bottom: 8px; color: var(--roxo); font-weight: 800; overflow-wrap: anywhere; }
.message-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.message-bubble time { display: block; margin-top: 6px; color: #807783; font-size: 10px; text-align: right; }

.reply-form { padding: 14px; border-top: 1px solid var(--borda); }
.reply-input-wrap { flex: 1; min-width: 0; display: grid; gap: 4px; }
.reply-composer { display: flex; align-items: flex-end; gap: 8px; }
.reply-input-wrap textarea { flex: 1; width: 100%; min-width: 0; resize: vertical; }
.reply-input-wrap small { color: #817983; font-size: 10px; }
.reply-help { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.attachment-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--borda);
  border-radius: 11px;
  background: #fff;
  font-size: 20px;
  cursor: pointer;
}
.attachment-toggle:hover { border-color: var(--lilas); background: #f1eaf4; }
.attachment-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.attachment-name {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--roxo);
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.emoji-control { position: relative; flex: 0 0 auto; }
.emoji-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--borda);
  border-radius: 11px;
  background: #fff;
  font-size: 20px;
}
.emoji-toggle:hover,
.emoji-toggle[aria-expanded="true"] { border-color: var(--lilas); background: #f1eaf4; }
.emoji-picker {
  position: absolute;
  left: 0;
  bottom: 50px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 36px);
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--borda);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(42,20,54,.18);
}
.emoji-picker[hidden] { display: none; }
.emoji-option {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 20px;
}
.emoji-option:hover,
.emoji-option:focus-visible { background: #f1eaf4; outline: none; }
.empty-state { margin: auto; padding: 30px 18px; color: #817983; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .channel-heading,
  .channel-form,
  .chat-header { align-items: stretch; flex-direction: column; }
  .channel-form > * { width: 100%; }
  .inbox-layout,
  .inbox-layout.has-crm { height: auto; max-height: none; grid-template-columns: 1fr; }
  .conversation-column { max-height: 280px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--borda); }
  .chat-column { height: min(640px, 75vh); min-height: 520px; }
  .conversation-crm-panel { border-top: 1px solid var(--borda); border-left: 0; }
}

@media (max-width: 620px) {
  .chat-controls { align-items: stretch; flex-direction: column; }
  .reply-form { align-items: stretch; flex-direction: column; }
  .message-bubble { max-width: 92%; }
  .qr-panel { align-items: flex-start; flex-direction: column; }
  .qr-panel img { max-width: 100%; }
}
