/**
 * N8N Chatbot - Clean & Bright Modern Interface
 * Version 2.4 - Added List Formatting Styles.
 */

/* ==========================================================================
   CSS Variables for Theming
   ========================================================================== */
:root {
    --n8n-chatbot-primary-color: #fe6712;
    --n8n-chatbot-secondary-color: #ffffff;
    --n8n-chatbot-primary-light: #ff8f4d;
    --n8n-chatbot-primary-dark: #e8590f;
    --n8n-chatbot-white: #ffffff;
    --n8n-chatbot-gray-50: #f9fafb;
    --n8n-chatbot-gray-100: #f3f4f6;
    --n8n-chatbot-gray-200: #e5e7eb;
    --n8n-chatbot-gray-400: #9ca3af;
    --n8n-chatbot-gray-500: #6b7280;
    --n8n-chatbot-gray-700: #374151;
    --n8n-chatbot-gray-800: #1f2937;
    --n8n-chatbot-green: #10b981;
    --n8n-chatbot-red: #ef4444;
    --n8n-chatbot-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --n8n-chatbot-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --n8n-chatbot-radius: 10px; 
    --n8n-chatbot-radius-lg: 16px;
    --n8n-chatbot-transition: all 0.2s ease-in-out;
}

/* ==========================================================================
   Base & Widget Container
   ========================================================================== */
.n8n-chatbot-widget { position: fixed; bottom: 20px; right: 20px; z-index: 99999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; line-height: 1.5; }
.n8n-chatbot-widget * { box-sizing: border-box; margin: 0; padding: 0; }

/* ==========================================================================
   Chat Button (Launcher)
   ========================================================================== */
.n8n-chatbot-button { width: 60px; height: 60px; background: var(--n8n-chatbot-primary-color); border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--n8n-chatbot-shadow-lg); transition: var(--n8n-chatbot-transition); position: relative; color: var(--n8n-chatbot-secondary-color); overflow: hidden; }
.n8n-chatbot-button:hover { transform: scale(1.1); box-shadow: var(--n8n-chatbot-shadow-xl); }
.n8n-chatbot-button svg { position: absolute; transition: transform 0.3s ease, opacity 0.3s ease; }
.n8n-chatbot-button.active .n8n-chatbot-icon-chat { transform: rotate(45deg) scale(0.5); opacity: 0; }
.n8n-chatbot-button.active .n8n-chatbot-icon-close { display: block !important; transform: rotate(0) scale(1); opacity: 1; }
.n8n-chatbot-button .n8n-chatbot-icon-close { transform: rotate(-45deg) scale(0.5); opacity: 0; }
.n8n-chatbot-unread-count { position: absolute; top: 8px; right: 5px; background: var(--n8n-chatbot-red); color: var(--n8n-chatbot-white); border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; border: 2px solid var(--n8n-chatbot-white); }

/* ==========================================================================
   Chat Window & Header
   ========================================================================== */
.n8n-chatbot-window { position: absolute; bottom: 80px; right: 0; width: 370px; height: 70vh; max-height: 600px; background: var(--n8n-chatbot-white); border-radius: var(--n8n-chatbot-radius-lg); box-shadow: var(--n8n-chatbot-shadow-xl); display: flex; flex-direction: column; overflow: hidden; transform-origin: bottom right; animation: slideUp 0.3s ease-out; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.n8n-chatbot-header { background: linear-gradient(135deg, var(--n8n-chatbot-primary-color) 0%, var(--n8n-chatbot-primary-light) 100%); color: var(--n8n-chatbot-secondary-color); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.n8n-chatbot-header-content { display: flex; align-items: center; gap: 12px; }
.n8n-chatbot-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, 0.3); }
.n8n-chatbot-title { font-size: 16px; font-weight: 600; margin: 0; color: #ffffff; }
.n8n-chatbot-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.n8n-chatbot-status::before { content: ''; width: 8px; height: 8px; background: var(--n8n-chatbot-green); border-radius: 50%; }
.n8n-chatbot-header-actions { display: flex; align-items: center; gap: 8px; }
.n8n-chatbot-action-btn { background: rgba(255, 255, 255, 0.15); border: none; border-radius: 8px; color: var(--n8n-chatbot-secondary-color); cursor: pointer; padding: 8px; transition: var(--n8n-chatbot-transition); display: flex; align-items: center; justify-content: center; }
.n8n-chatbot-action-btn:hover { background: rgba(255, 255, 255, 0.25); transform: scale(1.1); }
.n8n-chatbot-reload-icon { width: 16px; height: 16px; filter: brightness(0) invert(1); opacity: 0.9; }

/* ==========================================================================
   Messages Area & Input Area
   ========================================================================== */
.n8n-chatbot-messages { flex: 1; padding: 20px; background: var(--n8n-chatbot-gray-50); overflow-y: auto; display: flex; flex-direction: column; }
.n8n-chatbot-messages::-webkit-scrollbar { width: 6px; }
.n8n-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.n8n-chatbot-messages::-webkit-scrollbar-thumb { background: var(--n8n-chatbot-gray-200); border-radius: 3px; }
.n8n-chatbot-message { display: flex; margin-bottom: 12px; max-width: 85%; }
.n8n-chatbot-message.user { align-self: flex-end; }
.n8n-chatbot-message.bot { align-self: flex-start; }
.n8n-chatbot-message-content { padding: 10px 16px; border-radius: var(--n8n-chatbot-radius); line-height: 1.5; word-wrap: break-word; }
.n8n-chatbot-message.user { background-color: transparent; }
.n8n-chatbot-message.user .n8n-chatbot-message-content { background: var(--n8n-chatbot-primary-color); color: var(--n8n-chatbot-secondary-color); border-bottom-right-radius: 4px; }
.n8n-chatbot-message.bot .n8n-chatbot-message-content { background: var(--n8n-chatbot-gray-100); color: var(--n8n-chatbot-gray-800); border-bottom-left-radius: 4px; }
.n8n-chatbot-message.bot.n8n-chatbot-welcome-message .n8n-chatbot-message-content { background: var(--n8n-chatbot-white); border: 1px solid var(--n8n-chatbot-gray-200); }

/* --- **NEW** Formatting for lists inside messages --- */
.n8n-chatbot-message-content ul,
.n8n-chatbot-message-content ol {
    padding-left: 20px; /* Restores indentation */
    margin-top: 10px;
    margin-bottom: 10px;
}
.n8n-chatbot-message-content li {
    padding-left: 5px;
    margin-bottom: 5px; /* Adds space between list items */
}
/* --- End of new formatting --- */

.n8n-chatbot-typing .n8n-chatbot-message-content { padding: 12px 16px; }
.n8n-chatbot-typing-indicator { display: flex; gap: 4px; }
.n8n-chatbot-typing-indicator span { width: 8px; height: 8px; background-color: var(--n8n-chatbot-gray-400); border-radius: 50%; animation: typing-bounce 1.4s infinite ease-in-out both; }
.n8n-chatbot-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.n8n-chatbot-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
.n8n-chatbot-input-area { background: var(--n8n-chatbot-white); border-top: 1px solid var(--n8n-chatbot-gray-200); padding: 12px; flex-shrink: 0; position: relative; }
.n8n-chatbot-input-container { display: flex; align-items: flex-end; gap: 8px; }
.n8n-chatbot-input-wrapper { flex: 1; position: relative; }
textarea#n8n-chatbot-input { width: 100%; background: var(--n8n-chatbot-gray-50); border: 1px solid var(--n8n-chatbot-gray-200); border-radius: var(--n8n-chatbot-radius); padding: 10px 16px; font-size: 14px; font-family: inherit; resize: none; outline: none; transition: var(--n8n-chatbot-transition); min-height: 40px; max-height: 100px; color: var(--n8n-chatbot-gray-700); line-height: 1.4; }
textarea#n8n-chatbot-input:focus { background: var(--n8n-chatbot-white); border-color: var(--n8n-chatbot-primary-color); box-shadow: 0 0 0 3px rgba(254, 103, 18, 0.1); }
.n8n-chatbot-attach-btn, .n8n-chatbot-send-btn { width: 40px; height: 40px; border-radius: 50%; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--n8n-chatbot-transition); flex-shrink: 0; }
.n8n-chatbot-attach-btn { background: transparent; color: var(--n8n-chatbot-gray-500); }
.n8n-chatbot-attach-btn:hover { background: var(--n8n-chatbot-gray-100); color: var(--n8n-chatbot-gray-700); }
.n8n-chatbot-send-btn { background: var(--n8n-chatbot-primary-color); color: var(--n8n-chatbot-secondary-color); opacity: 0.5; }
.n8n-chatbot-send-btn:not(:disabled) { opacity: 1; }
.n8n-chatbot-send-btn:not(:disabled):hover { background: var(--n8n-chatbot-primary-dark); transform: scale(1.05); }
.n8n-chatbot-branding { text-align: center; margin-top: 8px; }
.n8n-chatbot-branding a { font-size: 11px; color: var(--n8n-chatbot-gray-400); text-decoration: none; transition: var(--n8n-chatbot-transition); }
.n8n-chatbot-branding a:hover { color: var(--n8n-chatbot-primary-color); }

/* ==========================================================================
   Attachment Preview & Message Styles
   ========================================================================== */
.n8n-chatbot-file-preview {
    background-color: var(--n8n-chatbot-gray-100);
    border-radius: var(--n8n-chatbot-radius);
    padding: 8px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.n8n-chatbot-file-preview-icon { color: var(--n8n-chatbot-gray-500); font-size: 16px; line-height: 1; }
.n8n-chatbot-file-preview-name {
    flex: 1;
    font-size: 13px;
    color: var(--n8n-chatbot-gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.n8n-chatbot-file-preview-remove {
    background: var(--n8n-chatbot-gray-200);
    color: var(--n8n-chatbot-gray-500);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
    transition: var(--n8n-chatbot-transition);
}
.n8n-chatbot-file-preview-remove:hover {
    background: var(--n8n-chatbot-red);
    color: var(--n8n-chatbot-white);
    transform: scale(1.1);
}

/* Style for the file message bubble */
.n8n-chatbot-file-message-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}
.n8n-chatbot-file-message-caption {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}
/* Style for the image message bubble */
.n8n-chatbot-image-message {
    display: flex;
    flex-direction: column;
}
.n8n-chatbot-user-image-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.n8n-chatbot-user-image-preview:hover {
    transform: scale(1.02);
}
/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 480px) {
    .n8n-chatbot-widget { position: fixed; bottom: 0; right: 0; left: 0; top: 0; pointer-events: none; }
    .n8n-chatbot-widget .n8n-chatbot-button { position: absolute !important; bottom: 16px !important; right: 16px !important; left: auto !important; top: auto !important; pointer-events: auto !important; }
    .n8n-chatbot-window { position: absolute !important; width: 100% !important; height: 100% !important; max-height: 100% !important; border-radius: 10px !important; top: 10px !important; left: 10px !important; bottom: 10px !important; right: 10px !important; transform: none !important; transform-origin: bottom center !important; pointer-events: auto !important; animation: slideUpMobile 0.3s ease-out; }
    @keyframes slideUpMobile { from { opacity: 0.8; transform: translateY(100%) !important; } to { opacity: 1; transform: translateY(0) !important; } }
}