/* ═══════════════════════════════════════════════════════════
   n8n Chatbot – Frontend Chat Widget Styles
   ═══════════════════════════════════════════════════════════ */

/* Variables are set dynamically via JS on :root / the widget element */

#n8n-chatbot-root {
    --n8n-color: #4F46E5;
    --n8n-bubble: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    z-index: 999999;
}

/* ─── Floating Bubble ──────────────────────────────────────── */

.n8n-bubble {
    position: fixed;
    width: var(--n8n-bubble);
    height: var(--n8n-bubble);
    border-radius: 50%;
    background: var(--n8n-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.22);
    transition: transform .25s ease, box-shadow .25s ease;
    z-index: 999999;
}
.n8n-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
.n8n-bubble svg { width: 28px; height: 28px; fill: currentColor; }
.n8n-bubble .n8n-close-icon { display: none; }
.n8n-bubble.open .n8n-chat-icon { display: none; }
.n8n-bubble.open .n8n-close-icon { display: block; }

/* Position helpers */
.n8n-pos-bottom-right { bottom: 24px; right: 24px; }
.n8n-pos-bottom-left  { bottom: 24px; left: 24px; }
.n8n-pos-top-right    { top: 24px; right: 24px; }
.n8n-pos-top-left     { top: 24px; left: 24px; }

/* ─── Chat Window ──────────────────────────────────────────── */

.n8n-window {
    position: fixed;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(.96);
    transition: opacity .25s ease, transform .25s ease;
}
.n8n-window.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Position the window relative to bubble */
.n8n-win-bottom-right { bottom: 96px; right: 24px; }
.n8n-win-bottom-left  { bottom: 96px; left: 24px; }
.n8n-win-top-right    { top: 96px; right: 24px; }
.n8n-win-top-left     { top: 96px; left: 24px; }

/* ─── Header ───────────────────────────────────────────────── */

.n8n-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--n8n-color);
    color: #fff;
    flex-shrink: 0;
}
.n8n-header-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}
.n8n-header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}
.n8n-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.n8n-header-close:hover { background: rgba(255,255,255,.2); }
.n8n-header-close svg { width: 18px; height: 18px; }

/* ─── Messages Area ────────────────────────────────────────── */

.n8n-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fb;
}

.n8n-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: n8n-fade-in .2s ease;
}

@keyframes n8n-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.n8n-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1e1e1e;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.n8n-msg-user {
    align-self: flex-end;
    background: var(--n8n-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.n8n-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.n8n-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a0a0a0;
    animation: n8n-bounce .9s infinite;
}
.n8n-typing span:nth-child(2) { animation-delay: .15s; }
.n8n-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes n8n-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ─── Input Area ───────────────────────────────────────────── */

.n8n-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.n8n-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color .15s;
}
.n8n-input:focus { border-color: var(--n8n-color); }

.n8n-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--n8n-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}
.n8n-send:disabled { opacity: .45; cursor: default; }
.n8n-send svg { width: 18px; height: 18px; }

/* ─── Powered-by footer ────────────────────────────────────── */
.n8n-footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 4px 0 8px;
    background: #fff;
}

/* ─── Mobile responsive ────────────────────────────────────── */
@media (max-width: 480px) {
    .n8n-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        border-radius: 12px;
        left: 8px !important;
        right: 8px !important;
    }
}
