/* N8n Chatbot Styles - Adapted to SBTech Theme */
/* Fonts & Variables imported from final.css conceptually */

#n8n-chat-widget {
    position: fixed;
    bottom: 22px;
    right: 100px;
    /* Positioned to the left of the WhatsApp button */
    z-index: 10000;
    font-family: 'Poppins', Inter, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@keyframes n8n-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 209, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(0, 255, 209, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 209, 0);
    }
}

/* Toggle Button */
.n8n-chat-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    /* Matching the WhatsApp float gradient from final.css (#00ffd1 to #00d2ff) */
    background: linear-gradient(135deg, #00ffd1, #00d2ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Glow effect similar to .sb-whatsapp-float in final.css */
    box-shadow: 0 10px 25px rgba(0, 255, 180, 0.3);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: n8n-pulse 2s infinite;
    position: relative;
    z-index: 2;
}

.n8n-chat-toggle:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow:
        0 22px 70px rgba(0, 210, 255, 0.4),
        0 12px 30px rgba(0, 255, 180, 0.3);
}

.n8n-chat-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.n8n-chat-toggle svg {
    color: #061019;
    /* Dark icon color to contrast with bright gradient, matches final.css icons */
    width: 32px;
    height: 32px;
}

.n8n-chat-tooltip {
    background: white;
    color: #000;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    margin-bottom: 12px;
    order: -1;
    /* Ensure it appears visually above if using flex column, or use absolute positioning */
    position: absolute;
    bottom: 80px;
    right: 0;
}

.n8n-chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 35px;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

.n8n-chat-toggle.hidden+.n8n-chat-tooltip {
    opacity: 0;
    transform: translateY(10px);
}

/* Chat Window */
.n8n-chat-window {
    position: fixed;
    bottom: 100px;
    right: 22px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    /* Dark card background from final.css (.card-bg / .sb-service-card) */
    background: #0b0f14;
    color: #fff;
    border-radius: 18px;
    /* Glass-like border and shadow */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.n8n-chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.n8n-chat-header {
    padding: 20px;
    /* Using the primary button gradient: Blue -> Cyan */
    background: linear-gradient(90deg, #2d4bff, #00ffc8);
    border-radius: 18px 18px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.n8n-chat-header-content h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.n8n-chat-header-content p {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    font-weight: 500;
}

/* Hide the header close button since the main toggle now acts as a close button */
.n8n-chat-close {
    display: none;
}

.n8n-chat-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

.n8n-chat-close svg {
    color: white;
}

/* Messages Container */
.n8n-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.n8n-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.n8n-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.n8n-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Messages */
.n8n-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.n8n-message-content {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Images in messages */
.n8n-message-content img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.n8n-message-content img:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Bot Message - using the 'card' background style */
.n8n-bot-message .n8n-message-content {
    background: rgba(255, 255, 255, 0.06);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

/* User Message - using the primary gradient */
.n8n-user-message {
    justify-content: flex-end;
}

.n8n-user-message .n8n-message-content {
    background: linear-gradient(135deg, #2d4bff, #00ffc8);
    color: white;
    /* White text looks best on this vibrant gradient */
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(45, 75, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.n8n-message-content a {
    color: #00ffc8;
    /* Cyan link color */
    text-decoration: underline;
}

.n8n-user-message .n8n-message-content a {
    color: #ffffff;
    text-decoration: underline;
}

/* Typing Indicator */
.n8n-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.n8n-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ffc8;
    animation: typingDot 1.4s infinite;
}

.n8n-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.n8n-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.n8n-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Input Container */
/* Input Container */
.n8n-chat-input-container {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #0b0f14;
    border-radius: 0 0 18px 18px;
    box-sizing: border-box;
}

.n8n-chat-input {
    flex: 0 0 70% !important;
    width: 70% !important;
    padding: 12px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.04);
    color: white;
}

.n8n-chat-input:focus {
    border-color: #00ffc8;
    box-shadow: 0 0 0 1px rgba(0, 255, 200, 0.1);
    background: rgba(255, 255, 255, 0.08);
}

.n8n-chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Send Button */
.n8n-chat-send {
    flex: 0 0 28% !important;
    /* ~30% with gap */
    width: 28% !important;
    height: 44px;
    border-radius: 22px;
    background: linear-gradient(135deg, #2d4bff, #00ffc8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(45, 75, 255, 0.25);
    padding: 0;
}

.n8n-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(45, 75, 255, 0.4);
}

.n8n-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.n8n-chat-send svg {
    color: white;
    margin-left: -2px;
}

/* Mobile Responsive */
/* Mobile Responsive */
@media (max-width: 480px) {
    .n8n-chat-window {
        width: 90vw;
        /* Responsive width relative to viewport */
        right: 5vw;
        /* Center it horizontally (5% left + 90% width + 5% right) */
        height: 70vh;
        /* constrain height to 70% of screen height to avoid being too tall */
        bottom: 90px;
        /* Keep it above the toggle button */
        max-height: 600px;
        border-radius: 16px;
    }

    #n8n-chat-widget {
        bottom: 20px;
        right: 90px;
        /* Move it to the left of the WhatsApp button on mobile too */
    }

    .n8n-chat-toggle {
        width: 60px;
        height: 60px;
    }

    .n8n-chat-toggle svg {
        width: 28px;
        height: 28px;
    }

    .n8n-chat-tooltip {
        bottom: 70px;
        /* Adjust tooltip position for smaller button */
        right: 0;
        font-size: 12px;
        padding: 6px 12px;
    }
}