/* n8n Chatbot — Layout & Positioning */

/* Widget Positioning */
.n8n-chatbot-widget:not(.n8n-inline-mode) {
    position: fixed;
    z-index: 99999;
    overflow: visible;
    width: 0;
    height: 0;
}

.n8n-position-bottom-right { bottom: 20px; right: 20px; }
.n8n-position-bottom-left { bottom: 20px; left: 20px; }

/* Toggle Button */
.n8n-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--n8n-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--n8n-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    position: absolute;
    bottom: 0;
    right: 0;
}

.n8n-position-bottom-left .n8n-chatbot-toggle { right: auto; left: 0; }

.n8n-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--n8n-shadow-lg);
    background: var(--n8n-primary-hover);
}

.n8n-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: var(--n8n-white);
    transition: opacity 0.2s ease;
}

.n8n-chatbot-toggle .n8n-icon-close { display: none; }
.n8n-chatbot-toggle.open .n8n-icon-chat { display: none; }
.n8n-chatbot-toggle.open .n8n-icon-close { display: block; }

/* Unread Badge */
.n8n-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--n8n-primary);
    color: var(--n8n-white);
    font-family: var(--n8n-font-accent);
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--n8n-white);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    animation: n8n-badge-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
}

.n8n-chatbot-toggle.open .n8n-unread-badge { display: none !important; }

@keyframes n8n-badge-pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Chat Window */
.n8n-chatbot-window {
    --n8n-chat-font-size: 14px;
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: var(--n8n-white);
    border-radius: var(--n8n-radius);
    box-shadow: var(--n8n-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.3s ease;
}

.n8n-chatbot-window.n8n-form-active { height: 740px; }
.n8n-position-bottom-left .n8n-chatbot-window { right: auto; left: 0; }

.n8n-chatbot-window.open {
    display: flex;
    animation: n8n-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Inline Mode */
.n8n-inline-mode .n8n-chatbot-window {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: none;
    border-radius: var(--n8n-radius-sm);
    display: flex;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--n8n-border);
}

@keyframes n8n-slide-up {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Fullscreen Mode */
.n8n-chatbot-window.n8n-fullscreen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    right: auto;
    bottom: auto;
    width: 800px !important;
    height: 800px !important;
    max-width: calc(100vw - 40px) !important;
    max-height: calc(100vh - 40px) !important;
    border-radius: var(--n8n-radius);
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.3);
    z-index: 100000;
    animation: n8n-fullscreen-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.n8n-chatbot-window.n8n-fullscreen .n8n-chatbot-messages { padding: 24px 32px; }
.n8n-chatbot-window.n8n-fullscreen .n8n-chatbot-input-area { padding: 16px 32px; }
.n8n-chatbot-window.n8n-fullscreen .n8n-chatbot-message { max-width: 85%; }
.n8n-chatbot-window.n8n-fullscreen .n8n-chatbot-header { padding: 16px 32px; }

@keyframes n8n-fullscreen-in {
    from { opacity: 0.9; transform: translate(-50%, -50%) scale(0.97); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Inline Shortcode Container */
.n8n-chatbot-inline {
    width: 100%;
    min-height: 400px;
    border: 1px solid var(--n8n-border);
    border-radius: var(--n8n-radius-sm);
    overflow: hidden;
}

/* Header */
.n8n-chatbot-header {
    background: var(--n8n-dark);
    color: var(--n8n-white);
    padding: 14px 16px;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--n8n-font-body);
}

.n8n-chatbot-title { flex: 1; letter-spacing: -0.01em; }

.n8n-chatbot-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.n8n-chatbot-header-actions button {
    background: none;
    border: none;
    color: var(--n8n-white);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.n8n-chatbot-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.n8n-chatbot-font-down,
.n8n-chatbot-font-up {
    font-family: var(--n8n-font-accent) !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    min-width: 28px;
}

.n8n-chatbot-sound-toggle .n8n-icon-sound-off { opacity: 0.5; }
.n8n-chatbot-header-actions svg { width: 20px; height: 20px; fill: var(--n8n-white); }

/* Chat Area */
.n8n-chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Input Area */
.n8n-chatbot-input-area {
    display: flex;
    align-items: flex-end;
    padding: 12px;
    border-top: 1px solid var(--n8n-border);
    gap: 8px;
    flex-shrink: 0;
    background: var(--n8n-white);
}

.n8n-chatbot-input {
    flex: 1;
    border: 1px solid var(--n8n-border);
    border-radius: 18px;
    padding: 10px 16px;
    font-family: var(--n8n-font-body);
    font-size: var(--n8n-chat-font-size);
    line-height: 1.4;
    color: var(--n8n-text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--n8n-light-bg);
    resize: none;
    overflow-y: auto;
    min-height: 40px;
    max-height: 120px;
}

.n8n-chatbot-input::placeholder { color: var(--n8n-grey); }

.n8n-chatbot-input:focus {
    border-color: var(--n8n-primary);
    box-shadow: 0 0 0 2px rgba(207, 8, 26, 0.1);
    background: var(--n8n-white);
}

.n8n-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--n8n-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.n8n-chatbot-send:hover { background: var(--n8n-primary-hover); transform: scale(1.05); }
.n8n-chatbot-send:active { transform: scale(0.95); }
.n8n-chatbot-send:disabled { background: var(--n8n-border); cursor: not-allowed; transform: none; }
.n8n-chatbot-send svg { width: 18px; height: 18px; fill: var(--n8n-white); }

/* Scrollbar */
.n8n-chatbot-messages::-webkit-scrollbar { width: 5px; }
.n8n-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.n8n-chatbot-messages::-webkit-scrollbar-thumb { background: var(--n8n-border); border-radius: 3px; }
.n8n-chatbot-messages::-webkit-scrollbar-thumb:hover { background: var(--n8n-grey); }
