/* Modo embed Twenty: una sola conversación a ancho completo, scroll solo en mensajes. */
html.twenty-embed,
html.twenty-embed body {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  overflow: hidden !important;
}

html.twenty-embed #app,
html.twenty-embed #app > .flex.flex-grow,
html.twenty-embed main.flex.flex-1,
html.twenty-embed section.flex.w-full.h-full {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Barra lateral principal de Chatwoot */
html.twenty-embed aside.bg-n-background {
  display: none !important;
}

/* Lista de conversaciones: colapsar sin display:none (evita spinner colgado).
   Solo en modo "un solo hilo" (bridge por lead, chatwoot_bridge.html). El
   panel general de Conversaciones (ARR-13, twenty_embed_view=panel) SÍ
   necesita esta lista visible — es su split view lista+hilo. */
html.twenty-embed:not(.twenty-embed-panel) .conversations-list-wrap {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
}

/* ARR-132/D10: aquí vivía una regla que ocultaba TODOS los hermanos
   genéricos de `section.flex.w-full` salvo `.conversation-details-wrap`
   (`div:not(.conversation-details-wrap) { display: none !important }`),
   anclada a clases de utilidad (`flex`, `w-full`). Cuando Chatwoot cambia su
   markup, ese comodín puede tragarse el composer o el aviso de ventana 24h
   sin que nada lo avise — causa confirmada de "a veces no sale la barra para
   escribir". Se elimina en vez de reemplazarse por otro selector ancho:
   ocultar el panel de contacto derecho queda para otra card, con un ancla
   estable (`data-testid` o id) verificada contra el DOM real. */

html.twenty-embed .conversation-details-wrap {
  width: 100% !important;
  max-width: 100% !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  border: none !important;
}

html.twenty-embed .conversation-details-wrap > .flex.h-full.min-h-0 {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Solo el hilo de mensajes hace scroll */
html.twenty-embed .conversation-panel {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

html.twenty-embed .message-content,
html.twenty-embed .bubble,
html.twenty-embed .text-bubble {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Extras que no aportan en embed */
html.twenty-embed #mobile-sidebar-launcher,
html.twenty-embed [id="mobile-sidebar-launcher"],
html.twenty-embed .copilot-launcher {
  display: none !important;
}

/* Composer compacto: menos alto (Responder + textarea + Enviar) */
html.twenty-embed .reply-box {
  margin-bottom: 0.25rem !important;
}

html.twenty-embed .reply-box__top {
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}

html.twenty-embed .reply-box .h-\[3\.25rem\] {
  height: 2.25rem !important;
  min-height: 2.25rem !important;
}

html.twenty-embed .reply-box .flex.justify-between.p-3 {
  padding: 0.375rem 0.5rem !important;
}

html.twenty-embed .resizable-editor-wrapper {
  --editor-min-height: 2.5rem !important;
  --editor-max-height: 4rem !important;
  --editor-height: 2.75rem !important;
}

html.twenty-embed .ProseMirror-woot-style,
html.twenty-embed .resizable-editor-wrapper .ProseMirror-woot-style,
html.twenty-embed .reply-box .ProseMirror {
  min-height: 2.5rem !important;
  max-height: 4rem !important;
}

html.twenty-embed .ProseMirror-menubar-wrapper {
  gap: 0.25rem !important;
}

html.twenty-embed .ProseMirror-menubar-wrapper > .ProseMirror {
  font-size: 0.875rem !important;
  line-height: 1.35 !important;
}

/* Sin placeholder del editor en embed (Chatwoot usa p.empty-node) */
html.twenty-embed .reply-box .ProseMirror p.empty-node:first-child::before,
html.twenty-embed .reply-box .ProseMirror .empty-node::before {
  content: none !important;
  display: none !important;
  height: 0 !important;
}

/* Botón Plantilla + panel (composer embed) */
html.twenty-embed .a1-plantilla-root.a1-plantilla-floating {
  position: fixed;
  left: 12px;
  bottom: 72px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
html.twenty-embed .a1-plantilla-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 2rem;
  height: 2rem;
  margin-left: 0.25rem;
  padding: 0 8px;
  border: 1px solid #d9d6e5;
  border-radius: 0.5rem;
  background: #ececf8;
  color: #12063d;
  cursor: pointer;
  font-family: Manrope, "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 650;
}
html.twenty-embed .a1-plantilla-btn:hover {
  background: #6365b8;
  border-color: #6365b8;
  color: #fff;
}
html.twenty-embed .a1-plantilla-btn-label {
  display: none;
}
html.twenty-embed .a1-plantilla-floating .a1-plantilla-btn {
  height: 36px;
  padding: 0 12px;
  box-shadow: 0 6px 18px #12063d26;
}
html.twenty-embed .a1-plantilla-floating .a1-plantilla-btn-label {
  display: inline;
}

/* Aviso de ventana de 24h (ARR-132/D10): junto al botón, nunca en vez de
   él — el botón está siempre montado, con o sin aviso. */
html.twenty-embed .a1-plantilla-notice {
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid #f5d0a9;
  border-radius: 8px;
  background: #fff8ec;
  color: #7a4a00;
  font-family: Manrope, "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 4px 14px #12063d1a;
}
html.twenty-embed .a1-plantilla-notice[hidden] {
  display: none;
}
html.twenty-embed .a1-plantilla-panel {
  position: fixed;
  right: 16px;
  bottom: 88px;
  z-index: 9999;
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, 55vh);
  overflow: auto;
  padding: 14px 14px 12px;
  border: 1px solid #e4e2ec;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 30px #12063d22;
  color: #12063d;
  font-family: Manrope, "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
}
html.twenty-embed .a1-plantilla-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -2px 0 10px;
  padding: 2px 0 8px;
  background: #fff;
  font-weight: 650;
  font-size: 14px;
}
html.twenty-embed .a1-plantilla-head-title {
  flex: 1;
  min-width: 0;
}
html.twenty-embed .a1-plantilla-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -4px -4px -4px 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #5b5670;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
html.twenty-embed .a1-plantilla-close:hover {
  background: #f4f4f7;
  color: #12063d;
}
html.twenty-embed .a1-plantilla-label {
  display: block;
  margin: 8px 0 4px;
  color: #5b5670;
  font-size: 12px;
}
html.twenty-embed .a1-plantilla-select,
html.twenty-embed .a1-plantilla-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #e4e2ec;
  border-radius: 8px;
  font: inherit;
  color: #12063d;
  background: #fff;
}
html.twenty-embed .a1-plantilla-preview {
  margin-top: 4px;
  padding: 10px;
  border-radius: 8px;
  background: #ececf8;
  white-space: pre-wrap;
  line-height: 1.4;
}
html.twenty-embed .a1-plantilla-hint {
  margin-top: 10px;
  color: #5b5670;
  font-size: 12px;
}
html.twenty-embed .a1-plantilla-error {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3f2;
  color: #b42318;
}
html.twenty-embed .a1-plantilla-cancel {
  margin-top: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e4e2ec;
  border-radius: 8px;
  background: #f4f4f7;
  color: #12063d;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

