/* ==========================================================================
   Barra de digitação Ion — painel de atendimento (v2, visual aprovado)
   --------------------------------------------------------------------------
   Aplica ao editor de resposta do Chatwoot (ReplyBox) o protótipo aprovado:
   vidro escuro translúcido, texto em uma linha que cresce suavemente e, abaixo,
   uma barra compacta com ícones de traço fino à esquerda (emoji, anexo,
   microfone, respostas prontas) e IA, expandir e enviar à direita.

   Só CSS (e /ion-composer.js para o botão de respostas prontas); o painel Vue
   não é recompilado. Vale apenas no modo normal do editor (quando a linha de
   ferramentas .left-wrap existe); no modo Copilot, o layout original continua.
   Para desfazer: remover o <link> e o <script> de ion-composer em layouts/vueapp.
   ========================================================================== */

/* ---------- Tokens: tema claro (padrão) e escuro ---------- */
.reply-box {
  --ic-glass: rgba(255, 255, 255, 0.78);
  --ic-glass-focus: rgba(255, 255, 255, 0.92);
  --ic-edge: rgba(15, 23, 42, 0.1);
  --ic-edge-focus: rgba(39, 129, 246, 0.45);
  --ic-sheen: rgba(255, 255, 255, 0.9);
  --ic-sheen-focus: rgba(39, 129, 246, 0.5);
  --ic-shadow: 0 14px 32px -14px rgba(15, 23, 42, 0.25), 0 2px 6px rgba(15, 23, 42, 0.06);
  --ic-text: #1c2430;
  --ic-muted: #7a8494;
  --ic-icon: #6b7483;
  --ic-icon-hover: #1c2430;
  --ic-hover: rgba(15, 23, 42, 0.06);
  --ic-press: rgba(15, 23, 42, 0.1);
  --ic-send: #2781f6;
  --ic-send-hover: #1f6fdc;
  --ic-send-idle: rgba(15, 23, 42, 0.06);
  --ic-ai: #7c5ce0;
}
.dark .reply-box {
  --ic-glass: rgba(24, 29, 37, 0.62);
  --ic-glass-focus: rgba(25, 31, 40, 0.74);
  --ic-edge: rgba(255, 255, 255, 0.07);
  --ic-edge-focus: rgba(96, 152, 255, 0.42);
  --ic-sheen: rgba(255, 255, 255, 0.14);
  --ic-sheen-focus: rgba(120, 170, 255, 0.55);
  --ic-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.25);
  --ic-text: #e7ebf1;
  --ic-muted: #7c8594;
  --ic-icon: #8a93a1;
  --ic-icon-hover: #e7ebf1;
  --ic-hover: rgba(255, 255, 255, 0.06);
  --ic-press: rgba(255, 255, 255, 0.1);
  --ic-send: #2781f6;
  --ic-send-hover: #3a8ff8;
  --ic-send-idle: rgba(255, 255, 255, 0.06);
  --ic-ai: #a78bfa;
}

/* ---------- Caixa: vidro flutuante ---------- */
.reply-box:has(> div > .left-wrap) {
  position: relative;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "meta   meta meta"
    "editor editor editor"
    "tools  ai   send";
  align-items: center;
  gap: 0 !important;
  padding: 0 !important;
  margin: 6px 14px 12px !important;
  border: 1px solid var(--ic-edge) !important;
  border-radius: 14px !important;
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.04), var(--ic-shadow);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.reply-box:has(> div > .left-wrap):not(.is-private) {
  background: var(--ic-glass) !important;
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}
/* reflexo luminoso na borda superior, que some nas pontas */
.reply-box:has(> div > .left-wrap)::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ic-sheen), transparent);
  pointer-events: none;
  transition: background 180ms ease;
  z-index: 1;
}
/* foco: borda e reflexo acendem, halo azul discreto */
.reply-box:has(> div > .left-wrap):not(.is-private):focus-within {
  background: var(--ic-glass-focus) !important;
  border-color: var(--ic-edge-focus) !important;
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.05),
    0 0 0 3px rgba(39, 129, 246, 0.14),
    0 0 24px -4px rgba(39, 129, 246, 0.28),
    var(--ic-shadow);
}
.reply-box:has(> div > .left-wrap):not(.is-private):focus-within::before {
  background: linear-gradient(90deg, transparent, var(--ic-sheen-focus), transparent);
}

/* qualquer filho não previsto ocupa a largura toda */
.reply-box:has(> div > .left-wrap) > * { grid-column: 1 / -1; }

/* ---------- Linha superior original (contador + IA/expandir) entra na grade ---------- */
.reply-box:has(> div > .left-wrap) > div:first-child { display: contents !important; }
.reply-box:has(> div > .left-wrap) > div:first-child > div:first-child {
  grid-area: meta;
  margin: 0 !important;
  padding: 8px 14px 0;
  font-size: 12px;
}
.reply-box:has(> div > .left-wrap) > div:first-child > div:first-child:not(:has(*)),
.reply-box:has(> div > .left-wrap) > div:first-child > div:first-child:empty { display: none; }
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) {
  grid-area: ai;
  display: flex;
  align-items: center;
  gap: 2px !important;
  padding: 4px 0 6px;
}

/* ---------- Texto: uma linha que cresce ---------- */
.reply-box:has(> div > .left-wrap) > .reply-box__top {
  grid-area: editor;
  min-width: 0;
  margin: 0 !important;
  padding: 11px 14px 2px !important;
}
/* O Chatwoot 4.18 dá ao editor uma ALTURA fixa (.resizable-editor-body:
   clamp(80px, --editor-height = 120px, ...)), controlada pela alça de arrastar
   e pelo botão expandir. Aqui a altura acompanha o texto: começa em uma linha
   (22px) e a altura mínima segue --editor-height descontado o resto da barra,
   então arrastar a alça ou expandir continuam funcionando. */
.reply-box:has(> div > .left-wrap) .ProseMirror,
.reply-box:has(> div > .left-wrap) .ProseMirror.resizable-editor-body,
.reply-box:has(> div > .left-wrap) .ProseMirror.ProseMirror-woot-style {
  height: auto !important;
  min-height: max(22px, calc(var(--editor-height, 120px) - 98px)) !important;
  max-height: max(176px, calc(var(--editor-height, 120px) - 98px)) !important;
  overflow-y: auto;
}
.reply-box:has(> div > .left-wrap) .ProseMirror {
  padding: 0 !important;
  font-size: 14px !important;
  line-height: 22px !important;
  color: var(--ic-text);
}
.reply-box:has(> div > .left-wrap) .ProseMirror p { margin: 0 !important; }
.reply-box:has(> div > .left-wrap):not(.is-private) .ProseMirror p.empty-node:first-child::before {
  content: "Escreva uma mensagem (/ abre as respostas prontas)" !important;
}
.reply-box:has(> div > .left-wrap) .ProseMirror p.empty-node:first-child::before {
  color: var(--ic-muted) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- Barra inferior compacta ---------- */
.reply-box > div:has(> .left-wrap) { display: contents !important; }
.reply-box:has(> div > .left-wrap) .left-wrap {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px !important;
  padding: 4px 6px 6px;
  min-width: 0;
}
.reply-box:has(> div > .left-wrap) .right-wrap {
  grid-area: send;
  display: flex;
  align-items: center;
  padding: 4px 6px 6px 0;
}
/* divisor fino entre IA/expandir e enviar */
.reply-box:has(> div > .left-wrap) .right-wrap::before {
  content: "";
  width: 1px;
  height: 16px;
  margin: 0 6px 0 4px;
  background: var(--ic-edge);
}

/* botões de ícone: transparentes, 30px, traço fino */
.reply-box:has(> div > .left-wrap) .left-wrap button,
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button {
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--ic-icon) !important;
  box-shadow: none !important;
  outline: none;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease !important;
}
.reply-box:has(> div > .left-wrap) .left-wrap button:hover:not(:disabled),
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button:hover:not(:disabled) {
  background: var(--ic-hover) !important;
  color: var(--ic-icon-hover) !important;
}
.reply-box:has(> div > .left-wrap) .left-wrap button:active:not(:disabled),
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button:active:not(:disabled) {
  background: var(--ic-press) !important;
  transform: scale(0.94);
}
.reply-box:has(> div > .left-wrap) .left-wrap button:focus-visible,
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button:focus-visible,
.reply-box:has(> div > .left-wrap) .right-wrap button:focus-visible {
  outline: 2px solid rgba(120, 170, 255, 0.8) !important;
  outline-offset: 1px;
}
.reply-box:has(> div > .left-wrap) .left-wrap button [class*="i-"],
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button [class*="i-"] {
  width: 17px !important;
  height: 17px !important;
}
/* IA em violeta, como no Copilot */
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button:has(.i-ph-sparkle-fill) { color: var(--ic-ai) !important; }
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) button:has(.i-ph-sparkle-fill):hover { background: rgba(167, 139, 250, 0.12) !important; }
/* microfone gravando: vermelho suave */
.reply-box:has(> div > .left-wrap) .left-wrap button:has(.i-ph-microphone-slash) { color: #f47c7c !important; background: rgba(244, 124, 124, 0.12) !important; }

/* ícones de traço fino (mesmos do protótipo aprovado) */
.reply-box:has(> div > .left-wrap) .i-ph-smiley-sticker {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M8.5 14.5s1.3 1.8 3.5 1.8 3.5-1.8 3.5-1.8'/><path d='M9 9.5h.01M15 9.5h.01' stroke-width='2'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M8.5 14.5s1.3 1.8 3.5 1.8 3.5-1.8 3.5-1.8'/><path d='M9 9.5h.01M15 9.5h.01' stroke-width='2'/></svg>") !important;
}
.reply-box:has(> div > .left-wrap) .i-ph-paperclip {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='m20.5 11.5-8.4 8.4a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='m20.5 11.5-8.4 8.4a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9'/></svg>") !important;
}
.reply-box:has(> div > .left-wrap) .i-ph-microphone {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='9' y='3' width='6' height='11' rx='3'/><path d='M18.5 11a6.5 6.5 0 0 1-13 0M12 17.5V21'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='9' y='3' width='6' height='11' rx='3'/><path d='M18.5 11a6.5 6.5 0 0 1-13 0M12 17.5V21'/></svg>") !important;
}
.reply-box:has(> div > .left-wrap) .i-ph-sparkle-fill {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M12 4.5 13.6 9a2 2 0 0 0 1.4 1.4l4.5 1.6-4.5 1.6a2 2 0 0 0-1.4 1.4L12 19.5 10.4 15A2 2 0 0 0 9 13.6L4.5 12 9 10.4A2 2 0 0 0 10.4 9Z'/><path d='M19 3v3M17.5 4.5h3'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M12 4.5 13.6 9a2 2 0 0 0 1.4 1.4l4.5 1.6-4.5 1.6a2 2 0 0 0-1.4 1.4L12 19.5 10.4 15A2 2 0 0 0 9 13.6L4.5 12 9 10.4A2 2 0 0 0 10.4 9Z'/><path d='M19 3v3M17.5 4.5h3'/></svg>") !important;
}
.reply-box:has(> div > .left-wrap) .i-lucide-maximize-2 {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M14.5 4.5h5v5M9.5 19.5h-5v-5M19.5 4.5 13.5 10.5M4.5 19.5l6-6'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M14.5 4.5h5v5M9.5 19.5h-5v-5M19.5 4.5 13.5 10.5M4.5 19.5l6-6'/></svg>") !important;
}
/* ícone do botão de respostas prontas (criado por /ion-composer.js) */
.reply-box .ion-i-canned {
  display: inline-block;
  width: 17px;
  height: 17px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3.5' y='3.5' width='17' height='17' rx='4'/><path d='m14.5 8-5 8'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3.5' y='3.5' width='17' height='17' rx='4'/><path d='m14.5 8-5 8'/></svg>") center / contain no-repeat;
}

/* ---------- Enviar: quadrado azul discreto com seta ---------- */
.reply-box:has(> div > .left-wrap) .right-wrap button[type="submit"] {
  position: relative;
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  overflow: hidden;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 140ms ease, opacity 160ms ease !important;
}
.reply-box:has(> div > .left-wrap):not(.is-private) .right-wrap button[type="submit"] {
  background: var(--ic-send) !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 12px -4px rgba(39, 129, 246, 0.6) !important;
}
.reply-box:has(> div > .left-wrap):not(.is-private) .right-wrap button[type="submit"]:hover:not(:disabled) {
  background: var(--ic-send-hover) !important;
}
/* o rótulo "Enviar (↵)" continua para leitores de tela, só fica invisível */
.reply-box:has(> div > .left-wrap) .right-wrap button[type="submit"] > span {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.reply-box:has(> div > .left-wrap) .right-wrap button[type="submit"]::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5.5 11.5 12 5l6.5 6.5'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5.5 11.5 12 5l6.5 6.5'/></svg>") center / contain no-repeat;
}
.reply-box:has(> div > .left-wrap):not(.is-private) .right-wrap button[type="submit"]:disabled {
  background: var(--ic-send-idle) !important;
  color: var(--ic-muted) !important;
  box-shadow: inset 0 0 0 1px var(--ic-edge) !important;
  opacity: 1 !important;
}
.reply-box:has(> div > .left-wrap) .right-wrap button[type="submit"]:active:not(:disabled) {
  transform: scale(0.94);
}

/* seletor de emoji sobe acima da barra */
.reply-box:has(> div > .left-wrap) .emoji-dialog {
  left: 0 !important;
  right: auto !important;
  bottom: calc(100% + 10px) !important;
  top: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  .reply-box:has(> div > .left-wrap),
  .reply-box:has(> div > .left-wrap) *,
  .reply-box:has(> div > .left-wrap)::before {
    transition: none !important;
  }
}

/* [Ion] v76 — menus que abrem no canto da barra (ex.: assistente de IA) não
   herdam o formato de "botão de ícone de 30px": itens com largura e texto. */
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) .n-dropdown-body button,
.reply-box:has(> div > .left-wrap) .left-wrap .n-dropdown-body button {
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 28px !important;
  padding: 4px 8px !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  color: rgb(var(--slate-12)) !important;
  white-space: nowrap !important;
  transform: none !important;
}
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) .n-dropdown-body button:hover:not(:disabled),
.reply-box:has(> div > .left-wrap) .left-wrap .n-dropdown-body button:hover:not(:disabled) {
  background: var(--ic-hover) !important;
  color: rgb(var(--slate-12)) !important;
}
.reply-box:has(> div > .left-wrap) > div:first-child > div:nth-child(2) .n-dropdown-body button [class*="i-"],
.reply-box:has(> div > .left-wrap) .left-wrap .n-dropdown-body button [class*="i-"] {
  width: 15px !important;
  height: 15px !important;
  flex-shrink: 0 !important;
}
.reply-box:has(> div > .left-wrap) .n-dropdown-body {
  min-width: 14rem !important;
}
