/* N8N Chatbot - Frontend Styles */

:root {
    --chatbot-primary: #007bff;
    --chatbot-button: #007bff;
    --chatbot-text: #333;
    --chatbot-bg: #ffffff;
    --chatbot-user-bg: #007bff;
    --chatbot-bot-bg: #f1f3f5;
    --chatbot-border: #e9ecef;
    --chatbot-shadow: rgba(0, 0, 0, 0.1);
}

/* Chatbot Container */
.n8n-chatbot-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.n8n-chatbot-container[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.n8n-chatbot-container[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.n8n-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-button);
    border: none;
    box-shadow: 0 4px 12px var(--chatbot-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    position: relative;
}

.n8n-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px var(--chatbot-shadow);
}

.n8n-chatbot-toggle img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Badge */
.n8n-chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Chatbot Window */
.n8n-chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.n8n-chatbot-container[data-position="bottom-right"] .n8n-chatbot-window {
    right: 0;
}

.n8n-chatbot-container[data-position="bottom-left"] .n8n-chatbot-window {
    left: 0;
}

.n8n-chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header */
.n8n-chatbot-header {
    background: var(--chatbot-primary);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.n8n-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.n8n-chatbot-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.n8n-chatbot-close:hover {
    opacity: 1;
}

/* Messages Container */
.n8n-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.n8n-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.n8n-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.n8n-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.n8n-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Bubbles */
.n8n-chatbot-message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.n8n-chatbot-message.user-message {
    justify-content: flex-end;
}

.n8n-chatbot-message.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.user-message .message-content {
    background: var(--chatbot-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: var(--chatbot-bot-bg);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Container */
.n8n-chatbot-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--chatbot-border);
    background: var(--chatbot-bg);
}

.n8n-chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.n8n-chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

.n8n-chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chatbot-button);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.n8n-chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--chatbot-shadow);
}

.n8n-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Branding Footer */
.n8n-chatbot-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: #6c757d;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    border-radius: 0 0 16px 16px;
}

.n8n-chatbot-footer span {
    display: inline-block;
}

.n8n-chatbot-footer a {
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s;
}

.n8n-chatbot-footer a:hover {
    color: var(--chatbot-primary);
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .n8n-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
    }

    .n8n-chatbot-container[data-position="bottom-right"],
    .n8n-chatbot-container[data-position="bottom-left"] {
        bottom: 10px;
        right: 10px;
        left: auto;
    }

    .n8n-chatbot-container[data-position="bottom-left"] .n8n-chatbot-window {
        left: auto;
        right: 0;
    }

    .n8n-chatbot-footer {
        font-size: 10px;
        padding: 6px 12px;
    }
}