/* n8n Webhook AI Chatbot - styles */
.n8nwc-root.floating { position: fixed; z-index: 999999; right: 20px; bottom: 20px; }
.n8nwc-root.pos-br { right: 20px; bottom: 20px; left:auto; }
.n8nwc-root.pos-bl { left: 20px; bottom: 20px; right:auto; }

.n8nwc-launcher { z-index: 1000002;
  display:flex; align-items:center; gap:8px;
  background: var(--n8nwc-primary, #8b5cf6); color:#fff;
  border-radius: 999px; padding:10px 14px; box-shadow:0 8px 24px rgba(0,0,0,.18);
  cursor:pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.n8nwc-launcher:hover { transform: translateY(-1px); box-shadow:0 10px 28px rgba(0,0,0,.22); }
.n8nwc-launcher img { width:24px; height:24px; display:block; }
.n8nwc-cta { font-size:14px; font-weight:600; }

.n8nwc-window { box-sizing:border-box;
  position: fixed;
  width: min(380px, 92vw);
  height: min(640px, 85vh);
  bottom: 20px;
  right: 20px;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  display:none;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  transform: translateY(12px);
  opacity:0;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2147483646;
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}
.n8nwc-root.pos-bl .n8nwc-window {
  position: fixed;
  width: min(380px, 92vw);
  height: min(640px, 85vh);
  bottom: 20px;
  right: 20px;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  display:none;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  transform: translateY(12px);
  opacity:0;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2147483646;
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}

.n8nwc-header{ grid-area: header; 
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px; background:var(--n8nwc-primary, #8b5cf6); color:#fff;
}
.n8nwc-h-left{ display:flex; gap:10px; align-items:center; }
.n8nwc-avatar{ width:36px; height:36px; border-radius:999px; object-fit:cover; background:#fff; }
.n8nwc-title{ font-weight:700; line-height:1; }
.n8nwc-subtitle{ font-size:12px; opacity:.9; }

.n8nwc-close{ background:transparent; border:none; color:#fff; font-size:24px; cursor:pointer; }

.n8nwc-body{
  grid-area: body;
  overflow: hidden;
  background:#fafafa;
  padding:12px;
  gap:8px;
  display:flex;
  flex-direction:column;
  min-height:0; /* allow messages to shrink within body track */
  box-sizing:border-box;
}
.n8nwc-messages{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-right:2px;
  box-sizing:border-box;
}

.n8nwc-msg{ display:flex; }
.n8nwc-row{ display:grid; grid-template-columns: auto 1fr auto; align-items:end; gap:8px; width:100%; }
.n8nwc-msg.from-user .n8nwc-row{ grid-template-columns: auto 1fr auto; }
.n8nwc-avatar{ width:32px; height:32px; border-radius:999px; object-fit:cover; background:#eee; }
.n8nwc-meta{ font-size:11px; color:#9ca3af; padding:0 4px; }

.n8nwc-msg.from-user{ justify-content:flex-end; }
.n8nwc-msg .n8nwc-bubble{ margin: 0 4px;
  max-width: 82%;
  padding:10px 12px; border-radius:14px; line-height:1.35; font-size:14px;
  background:var(--n8nwc-bot, #f3f4f6);
  word-wrap:break-word; white-space:pre-wrap;
}
.n8nwc-msg.from-user .n8nwc-bubble{ background: var(--n8nwc-user, #e0f2fe); }

.n8nwc-msg.is-error .n8nwc-bubble{ background:#fee2e2; border:1px solid #fecaca; }

.n8nwc-typing{ align-items:center; gap:6px; padding:6px 8px; }
.n8nwc-dot{ width:7px; height:7px; border-radius:50%; background:#9ca3af; display:inline-block; animation: n8nwc-blink 1s infinite ease-in-out; }
.n8nwc-dot:nth-child(2){ animation-delay:.2s; } .n8nwc-dot:nth-child(3){ animation-delay:.4s; }
@keyframes n8nwc-blink{ 0%,80%,100%{ opacity:.2 } 40%{ opacity:1 } }

.n8nwc-input{
  grid-area: input;
  display:flex;
  gap:8px;
  padding:10px calc(10px + env(safe-area-inset-right));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background:#fff;
  border-top:1px solid #e5e7eb;
  align-items:center;
  box-sizing: border-box;
  min-height: 60px;
}
.n8nwc-text{
  flex:1; padding:10px 12px; border:1px solid #e5e7eb; border-radius:12px; font-size:16px;
  outline:none;
}
.n8nwc-send{
  background:var(--n8nwc-primary, #8b5cf6); color:#fff; border:none; padding:10px 14px; border-radius:12px; font-weight:700; cursor:pointer;
}
/* Inline shortcode variant */
.n8nwc-root.inline{ position:relative; width:100%; display:block; }
.n8nwc-root.inline .n8nwc-window {
  position: fixed;
  width: min(380px, 92vw);
  height: min(640px, 85vh);
  bottom: 20px;
  right: 20px;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  display:none;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  transform: translateY(12px);
  opacity:0;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2147483646;
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}

/* Mobile tweaks */
@media (max-width: 480px){
  .n8nwc-window{ width: calc(100vw - 24px); right:12px; left: auto; bottom: 20px; height: min(640px, 85vh); }
  .n8nwc-root.pos-bl .n8nwc-window{ left:12px; right:auto; }
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
  .n8nwc-root.pos-bl .n8nwc-window {
  position: fixed;
  width: min(380px, 92vw);
  height: min(640px, 85vh);
  bottom: 20px;
  right: 20px;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  display:none;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  transform: translateY(12px);
  opacity:0;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2147483646;
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
}
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}
  .n8nwc-root.pos-bl .n8nwc-window {
  position: fixed;
  width: min(380px, 92vw);
  height: min(640px, 85vh);
  bottom: 20px;
  right: 20px;
  background:#fff;
  border-radius:16px;
  overflow:hidden;
  display:none;
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  transform: translateY(12px);
  opacity:0;
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2147483646;
}
.n8nwc-root.pos-bl .n8nwc-window { left: 20px; right:auto; }
.n8nwc-window.open {
  display: grid !important;
  grid-template-areas:
    "header"
    "body"
    "input";
  grid-template-rows: auto 1fr auto !important;
  opacity: 1;
  transform: translateY(0);
}
}

/* Hide launcher when the window is open to avoid overlap & clicks */
.n8nwc-root.is-open .n8nwc-launcher { display: none; }

/* Compact on open, expand when conversation grows */
.n8nwc-window.compact { height: min(640px, 85vh); }
.n8nwc-window.expanded { height: min(640px, 85vh); }
@media (max-width: 480px){
  .n8nwc-window.compact { height: min(640px, 85vh); }
  .n8nwc-window.expanded { height: min(640px, 85vh); }
}

.n8nwc-msg.from-user { justify-content:flex-end; }
.n8nwc-msg.from-user .n8nwc-row { justify-items:end; }
.n8nwc-msg.from-user .n8nwc-avatar { order:3; }
.n8nwc-msg.from-user .n8nwc-bubble { order:2; }
.n8nwc-msg.from-user .n8nwc-meta { order:1; }
.n8nwc-msg.from-bot .n8nwc-row { justify-items:start; }
