/* N8N Chatbot Interface - Frontend Styles */

/* Chatbot Widget Container */
.n8n-chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Position variants */
.n8n-chatbot-widget.n8n-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

.n8n-chatbot-widget.n8n-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

.n8n-chatbot-widget.n8n-chatbot-top-right {
    top: 20px;
    right: 20px;
}

.n8n-chatbot-widget.n8n-chatbot-top-left {
    top: 20px;
    left: 20px;
}

/* Chatbot Toggle Button */
.n8n-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-theme-color, #007cba);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.n8n-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.n8n-chatbot-toggle.active {
    background: #dc3545;
}

.n8n-chatbot-icon {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
    position: absolute;
}

.n8n-chatbot-icon-chat {
    opacity: 1;
    transform: rotate(0deg);
}

.n8n-chatbot-icon-close {
    opacity: 0;
    transform: rotate(180deg);
}

.n8n-chatbot-widget.open .n8n-chatbot-icon-chat {
    opacity: 0;
    transform: rotate(-180deg);
}

.n8n-chatbot-widget.open .n8n-chatbot-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chatbot Window */
.n8n-chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: var(--chatbot-width, 320px);
    max-width: 85vw;
    height: var(--chatbot-max-height, 450px);
    max-height: 60vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.n8n-chatbot-window.show {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chatbot Header */
.n8n-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--chatbot-theme-color, #007cba);
    color: white;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.n8n-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.n8n-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.n8n-chatbot-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.n8n-chatbot-title {
    flex: 1;
    min-width: 0;
}

.n8n-chatbot-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.n8n-chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
    display: block;
}

/* Header Buttons Container */
.n8n-chatbot-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.n8n-chatbot-new-session,
.n8n-chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.n8n-chatbot-new-session:hover,
.n8n-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.n8n-chatbot-new-session svg,
.n8n-chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* Messages Container */
.n8n-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.n8n-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.n8n-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.n8n-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.n8n-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message Bubbles */
.n8n-chatbot-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 0;
}

.n8n-chatbot-message.user {
    justify-content: flex-end;
}

.n8n-chatbot-message.bot {
    justify-content: flex-start;
}

.n8n-chatbot-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.n8n-chatbot-message.user .n8n-chatbot-message-bubble {
    background: var(--chatbot-theme-color, #007cba);
    color: white;
    border-bottom-right-radius: 6px;
}

.n8n-chatbot-message.bot .n8n-chatbot-message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 6px;
}

/* Typing Indicator */
.n8n-chatbot-typing {
    display: none;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 80%;
}

.n8n-chatbot-typing.show {
    display: block;
}

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

.n8n-chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typingDot 1.4s infinite ease-in-out;
}

.n8n-chatbot-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.n8n-chatbot-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Input Area */
.n8n-chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.n8n-chatbot-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.n8n-chatbot-input {
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
    line-height: 1.4;
}

.n8n-chatbot-input:focus {
    border-color: var(--chatbot-theme-color, #007cba);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.n8n-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chatbot-theme-color, #007cba);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 7px;
}

.n8n-chatbot-send:hover:not(:disabled) {
    background: var(--chatbot-theme-color-dark, #005a87);
    transform: scale(1.05);
}

.n8n-chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.n8n-chatbot-send.n8n-chatbot-send-disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Welcome Message */
.n8n-chatbot-welcome {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-bottom: 16px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e1e5e9;
}

/* Error Message */
.n8n-chatbot-error {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #fcc;
    font-size: 13px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Base mobile adjustments - no positioning override */
    /* Removed empty .n8n-chatbot-widget rule to respect position classes */
    
    /* Specific positioning for mobile - respecting user settings */
    .n8n-chatbot-widget.n8n-chatbot-bottom-right {
        bottom: 10px;
        right: 10px;
    }
    
    .n8n-chatbot-widget.n8n-chatbot-bottom-left {
        bottom: 10px;
        left: 10px;
    }
    
    .n8n-chatbot-widget.n8n-chatbot-top-right {
        top: 10px;
        right: 10px;
    }
    
    .n8n-chatbot-widget.n8n-chatbot-top-left {
        top: 10px;
        left: 10px;
    }
    
    /* Window positioning based on widget position */
    .n8n-chatbot-window {
        width: calc(100vw - 20px);
        max-width: none;
        height: 60vh;
        max-height: 400px;
        margin: 0;
        /* Force centered positioning on mobile 
        left: 10px !important;
        right: 10px !important;*/
    }
    
    /* Bottom positioned widgets */
    .n8n-chatbot-widget.n8n-chatbot-bottom-right .n8n-chatbot-window,
    .n8n-chatbot-widget.n8n-chatbot-bottom-left .n8n-chatbot-window {
        bottom: 70px;
    }
    
    /* Top positioned widgets */
    .n8n-chatbot-widget.n8n-chatbot-top-right .n8n-chatbot-window,
    .n8n-chatbot-widget.n8n-chatbot-top-left .n8n-chatbot-window {
        top: 70px;
    }
    

    

    
    .n8n-chatbot-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .n8n-chatbot-header {
        padding: 12px 16px;
    }
    
    .n8n-chatbot-title h3 {
        font-size: 14px;
    }
    
    .n8n-chatbot-messages {
        padding: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .n8n-chatbot-window {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-messages {
        background: #1a202c;
    }
    
    .n8n-chatbot-message.bot .n8n-chatbot-message-bubble {
        background: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-input-area {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-input {
        background: #1a202c;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-welcome {
        background: #2d3748;
        color: #a0aec0;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-typing {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .n8n-chatbot-error {
        background-color: #2d1b1b;
        border-color: #5c2b2b;
        color: #ff6b6b;
    }
}

/* Status message */
.n8n-chatbot-status-message {
    text-align: center;
    color: #666;
    font-size: 0.8em;
    margin: 10px 0;
    padding: 5px;
}

@media (prefers-color-scheme: dark) {
    .n8n-chatbot-status-message {
        color: #999;
    }
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Privacy Consent Modal Styles */
.n8n-chatbot-consent-modal {
    display: none;
}

.n8n-chatbot-consent-modal.show {
    display: block;
}

.n8n-chatbot-consent-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: var(--chatbot-width, 320px);
    max-width: 85vw;
    height: auto;
    min-height: 300px;
    max-height: 60vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.n8n-chatbot-consent-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.n8n-chatbot-consent-message {
    color: #374151;
    line-height: 1.6;
}

.n8n-chatbot-consent-message p {
    margin: 0 0 15px 0;
}

.n8n-chatbot-privacy-link {
    margin: 10px 0 0 0;
}

.n8n-chatbot-privacy-link a {
    color: var(--chatbot-theme-color, #007cba);
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.n8n-chatbot-privacy-link a:hover {
    color: #005a8b;
    text-decoration: underline;
}

.n8n-chatbot-external-link {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Consent Checkbox */
.n8n-chatbot-consent-checkbox {
    margin: 10px 0;
}

.n8n-chatbot-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

.n8n-chatbot-checkbox {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s ease;
}

.n8n-chatbot-checkbox:checked {
    background: var(--chatbot-theme-color, #007cba);
    border-color: var(--chatbot-theme-color, #007cba);
}

.n8n-chatbot-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.n8n-chatbot-checkbox:focus {
    outline: 2px solid var(--chatbot-theme-color, #007cba);
    outline-offset: 2px;
}

.n8n-chatbot-checkbox-text {
    flex: 1;
}

/* Consent Action Buttons */
.n8n-chatbot-consent-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 10px;
}

.n8n-chatbot-button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 44px;
    position: relative;
}

.n8n-chatbot-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.n8n-chatbot-button-primary {
    background: var(--chatbot-theme-color, #007cba);
    color: white;
}

.n8n-chatbot-button-primary:hover:not(:disabled) {
    background: #005a8b;
    transform: translateY(-1px);
}

.n8n-chatbot-button-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.n8n-chatbot-button-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* Loading state for buttons */
.n8n-chatbot-button.n8n-chatbot-loading {
    opacity: 0.8;
    cursor: not-allowed;
    transform: none !important;
}

.n8n-chatbot-button.n8n-chatbot-loading:hover {
    transform: none !important;
}

/* Spinner animation */
.n8n-chatbot-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: n8n-chatbot-spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes n8n-chatbot-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments for consent modal */
    @media (max-width: 480px) {
        .n8n-chatbot-consent-window {
            width: calc(100vw - 40px);
            max-width: none;
            left: 20px !important;
            right: 20px !important;
            bottom: 20px;
        }
        
        /* Force centered positioning for consent modal on mobile */
        .n8n-chatbot-widget.n8n-chatbot-bottom-left .n8n-chatbot-consent-window,
        .n8n-chatbot-widget.n8n-chatbot-top-left .n8n-chatbot-consent-window,
        .n8n-chatbot-widget.n8n-chatbot-bottom-right .n8n-chatbot-consent-window,
        .n8n-chatbot-widget.n8n-chatbot-top-right .n8n-chatbot-consent-window {
            left: 20px !important;
            right: 20px !important;
        }
        

    
    .n8n-chatbot-consent-content {
        padding: 16px;
        gap: 16px;
    }
    
    .n8n-chatbot-consent-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .n8n-chatbot-button {
        width: 100%;
    }
}

/* Animation for consent modal */
.n8n-chatbot-consent-modal.show .n8n-chatbot-consent-window {
    animation: slideUpFadeIn 0.3s ease-out;
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}