/* Minimal, modern chat UI */
#n8n-chatbot-root { 
  position: fixed; 
  z-index: 999999; 
  display: block; 
}
.n8n-pos-br { right: 18px; bottom: 24px; }
.n8n-pos-bl { left: 18px; bottom: 24px; }

/* LAUNCHER - Chat button */
.n8n-launcher {
  position: fixed !important;
  z-index: 1000000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0,0,0,.2);
  transition: transform .15s ease, box-shadow .15s ease;
  background: var(--n8n-primary, #7c3aed);
  color: #fff;
  font-weight: 600;
}
.n8n-launcher:hover { 
  transform: translateY(-1px); 
  box-shadow: 0 14px 30px rgba(0,0,0,.25); 
}
.n8n-launcher img { 
  width: 24px; 
  height: 24px; 
  border-radius: 6px; 
  object-fit: cover; 
  background: rgba(255,255,255,.2); 
}
.n8n-launcher-cta { white-space: nowrap; }

/* Launcher positioning - with spacing from screen edge */
.n8n-pos-br .n8n-launcher { right: 18px; left: auto; bottom: 24px; }
.n8n-pos-bl .n8n-launcher { left: 18px; right: auto; bottom: 24px; }

/* Hide launcher when chat is open */
#n8n-chatbot-root.n8n-open .n8n-launcher { 
  display: none !important; 
}

/* PANEL - Chat window */
.n8n-panel { 
  position: fixed !important;
  width: 320px; 
  max-width: calc(100vw - 24px); 
  height: 480px; 
  background: #fff; 
  border-radius: 16px; 
  overflow: hidden; 
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  /* CRITICAL: Hidden by default */
  display: none !important;
}

/* Show panel when it has the 'show' class */
.n8n-panel.show { 
  display: flex !important;
  flex-direction: column !important;
  animation: n8n-pop .18s ease; 
}

@keyframes n8n-pop { 
  from { transform: scale(.98); opacity: 0; } 
  to { transform: scale(1); opacity: 1; } 
}

/* Panel positioning */
.n8n-pos-br .n8n-panel { right: 18px; left: auto; bottom: 100px; }
.n8n-pos-bl .n8n-panel { left: 18px; right: auto; bottom: 100px; }

@media (max-width: 480px) {
  .n8n-panel { width: 94vw; height: 64vh; }
}

/* HEADER */
.n8n-header {
  position: relative;
  padding: 12px 14px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.n8n-header img { 
  width: 28px; 
  height: 28px; 
  border-radius: 9999px; 
  object-fit: cover; 
}
.n8n-title { font-weight: 700; line-height: 1.1; }
.n8n-sub { font-size: 12px; opacity: .9; }

/* Close button */
.n8n-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
}
.n8n-close:hover { 
  background: rgba(255,255,255,.25); 
}

/* MESSAGES AREA */
.n8n-messages { 
  flex: 1; 
  padding: 10px; 
  background: #f8fafc; 
  overflow-y: auto; 
}

.n8n-row { 
  display: flex;
  width: 100%;
  gap: 6px;
  margin: 4px 0;
  align-items: flex-end;
}
.n8n-row.bot { 
  justify-content: flex-start;
  flex-direction: row;
}
.n8n-row.user { 
  justify-content: flex-end;
  flex-direction: row-reverse;
}

/* Avatar */
.n8n-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  overflow: hidden;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
}
.n8n-avatar img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block; 
}
.n8n-avatar svg { 
  width: 18px; 
  height: 18px; 
  opacity: .7; 
}

/* Message wrapper and bubble */
.n8n-row .n8n-msgwrap { 
  max-width: calc(100% - 36px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.n8n-row.user .n8n-msgwrap { 
  align-items: flex-end;
}

.n8n-bubble {
  display: inline-block;
  min-width: 48px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  margin: 0;
}
.n8n-row.bot .n8n-bubble { 
  border-bottom-left-radius: 4px;
  margin-left: 0;
}
.n8n-row.user .n8n-bubble { 
  border-bottom-right-radius: 4px;
  margin-right: 0;
}

/* Timestamp */
.n8n-meta {
  font-size: 10px;
  opacity: .6;
  margin-top: 2px;
}
.n8n-row.user .n8n-meta { 
  text-align: right; 
}

/* Typing indicator */
.n8n-typing { 
  font-size: 12px; 
  opacity: .65; 
  margin-left: 8px; 
}

/* INPUT BAR */
.n8n-inputbar {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.n8n-inputbar input[type="text"] {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
.n8n-sendbtn {
  border: none;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
}
