
/* N8N Chatbot Widget - Frontend */
.n8ncw-mount { all: initial; }
.n8ncw-mount * { box-sizing: border-box; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }

.n8ncw-floating{
  position: fixed;
  z-index: 999999;
  transition: opacity .2s ease;
}

.n8ncw-button{
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid var(--n8n-border);
  background: var(--n8n-primary);
  color: var(--n8n-header-text);
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  cursor: pointer;
}

.n8ncw-button:hover{ filter: brightness(1.05); }

.n8ncw-icon-img{
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.n8ncw-icon-emoji{ font-size: 22px; line-height: 1; }

.n8ncw-icon-svg svg{ width: 24px; height: 24px; display:block; fill: currentColor; }

.n8ncw-icon-dash{
  width: 26px; height: 26px; display:block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v12H5.17L4 17.17V4zm2 2v7h12V6H6zm0 9.17L6.83 14H18v-1H6v2.17z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v12H5.17L4 17.17V4zm2 2v7h12V6H6zm0 9.17L6.83 14H18v-1H6v2.17z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.n8ncw-panel{
  position: absolute;
  bottom: 72px;
  width: 340px;
  max-width: calc(100vw - 48px);
  height: 460px;
  max-height: calc(100vh - 140px);
  border-radius: 18px;
  border: 1px solid var(--n8n-border);
  background: var(--n8n-panel-bg);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  overflow: hidden;
  display:flex;
  flex-direction:column;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.n8ncw-floating.is-open .n8ncw-panel{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.n8ncw-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 12px 12px 12px 14px;
  background: color-mix(in srgb, var(--n8n-primary) 25%, transparent);
  border-bottom: 1px solid var(--n8n-border);
}

.n8ncw-title{
  font-size: 14px;
  font-weight: 700;
  color: var(--n8n-header-text);
  letter-spacing: .2px;
}

.n8ncw-close{
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--n8n-border);
  background: rgba(0,0,0,.12);
  color: var(--n8n-header-text);
  cursor: pointer;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
}
.n8ncw-close svg{ width: 16px; height: 16px; display:block; fill: currentColor; }

.n8ncw-close:hover{ filter: brightness(1.1); }

.n8ncw-messages{
  flex: 1;
  min-height: 0;
  padding: 14px;
  overflow:auto;
  background: radial-gradient(1200px 300px at 50% 0%, rgba(255,255,255,.08), transparent), var(--n8n-chat-bg);
}

.n8ncw-msg{ display:flex; margin: 10px 0; }
.n8ncw-bot{ justify-content: flex-start; }
.n8ncw-user{ justify-content: flex-end; }

.n8ncw-bubble{
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--n8n-border);
  color: var(--n8n-message-text);
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.n8ncw-bot .n8ncw-bubble{ background: var(--n8n-agent-bubble); border-top-left-radius: 8px; }
.n8ncw-user .n8ncw-bubble{ background: var(--n8n-user-bubble); border-top-right-radius: 8px; }

.n8ncw-form{
  display:flex;
  width: 100%;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--n8n-border);
  background: rgba(0,0,0,.10);
}

.n8ncw-input{
  flex: 1;
  min-width: 0;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--n8n-border);
  background: rgba(0,0,0,.18);
  color: var(--n8n-message-text);
  padding: 0 12px;
  outline: none;
}

.n8ncw-input:focus{ border-color: color-mix(in srgb, var(--n8n-primary) 55%, var(--n8n-border)); }

.n8ncw-send{
  height: 40px;
  flex: 0 0 auto;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--n8n-border);
  background: var(--n8n-primary);
  color: var(--n8n-header-text);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.n8ncw-send:hover{ filter: brightness(1.05); }

.n8ncw-typing{ display:inline-flex; gap: 4px; align-items:center; }
.n8ncw-typing i{
  width: 6px; height: 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--n8n-message-text) 75%, transparent);
  display:block;
  animation: n8ncwPulse 1s infinite ease-in-out;
}
.n8ncw-typing i:nth-child(2){ animation-delay: .15s; }
.n8ncw-typing i:nth-child(3){ animation-delay: .3s; }
@keyframes n8ncwPulse { 0%,100%{ transform: translateY(0); opacity:.55; } 50%{ transform: translateY(-2px); opacity:1; } }

/* Positioning of panel relative to button */
.n8ncw-floating{ right: var(--n8n-right, auto); left: var(--n8n-left, auto); }


.n8ncw-bubble a{ color: color-mix(in srgb, var(--n8n-primary) 70%, var(--n8n-message-text)); text-decoration: underline; }
.n8ncw-bubble a:hover{ filter: brightness(1.05); }


/* Panel alignment (opens inward) */
.n8ncw-floating.pos-right .n8ncw-panel{ right: 0; left: auto; }
.n8ncw-floating.pos-left  .n8ncw-panel{ left: 0; right: auto; }


/* Admin preview mode (renders inside preview box) */
.n8ncw-floating.is-preview{ position: relative; left:auto; right:auto; bottom:auto; }
.n8ncw-floating.is-preview .n8ncw-button{ display:none; }
.n8ncw-floating.is-preview .n8ncw-panel{
  position: relative;
  bottom: auto;
  width: 100%;
  max-width: 100%;
  height: 420px;
  max-height: 420px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
