/* Custom styling for n8n chat widget to match Optimized DZ theme */

:root {
	/* Primary Colors - Optimized DZ Green */
	--chat--color--primary: #00d9a3;
	--chat--color--primary-shade-50: #00ffc4;
	--chat--color--primary--shade-100: #00c490;
	--chat--color--secondary: #00d9a3;
	--chat--color-secondary-shade-50: #00ffc4;
	
	/* Base Colors - Dark Theme */
	--chat--color-white: #ffffff;
	--chat--color-light: #1e242e;
	--chat--color-light-shade-50: #2a3140;
	--chat--color-light-shade-100: #353d4f;
	--chat--color-medium: #b8bec9;
	--chat--color-dark: #0a0e14;
	--chat--color-disabled: #6b7280;
	--chat--color-typing: #00d9a3;

	/* Base Layout */
	--chat--spacing: 1rem;
	--chat--border-radius: 12px;
	--chat--transition-duration: 0.2s;
	--chat--font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

	/* Window Dimensions */
	--chat--window--width: 400px;
	--chat--window--height: 600px;
	--chat--window--bottom: 30px;
	--chat--window--right: 30px;
	--chat--window--z-index: 9999;
	--chat--window--border: 1px solid rgba(255, 255, 255, 0.1);
	--chat--window--border-radius: 16px;
	--chat--window--margin-bottom: var(--chat--spacing);

	/* Header Styles - Dark with subtle border */
	--chat--header-height: auto;
	--chat--header--padding: 1.5rem;
	--chat--header--background: #151921;
	--chat--header--color: #ffffff;
	--chat--header--border-top: none;
	--chat--header--border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	--chat--header--border-left: none;
	--chat--header--border-right: none;
	--chat--heading--font-size: 1.5em;
	--chat--subtitle--font-size: 0.9em;
	--chat--subtitle--line-height: 1.6;

	/* Message Styles - High Contrast */
	--chat--message--font-size: 0.95rem;
	--chat--message--padding: 0.875rem 1rem;
	--chat--message--border-radius: 12px;
	--chat--message-line-height: 1.6;
	--chat--message--margin-bottom: 0.75rem;
	
	/* Bot Messages - Dark gray background, white text */
	--chat--message--bot--background: #151921;
	--chat--message--bot--color: #ffffff;
	--chat--message--bot--border: 1px solid rgba(255, 255, 255, 0.05);
	
	/* User Messages - Green gradient, dark text */
	--chat--message--user--background: linear-gradient(135deg, #00d9a3 0%, #00ffc4 100%);
	--chat--message--user--color: #0a0e14;
	--chat--message--user--border: none;
	
	--chat--message--pre--background: rgba(0, 0, 0, 0.3);
	--chat--messages-list--padding: 1.25rem;

	/* Toggle Button - Green with pulse */
	--chat--toggle--size: 60px;
	--chat--toggle--width: var(--chat--toggle--size);
	--chat--toggle--height: var(--chat--toggle--size);
	--chat--toggle--border-radius: 50%;
	--chat--toggle--background: linear-gradient(135deg, #00d9a3 0%, #00ffc4 100%);
	--chat--toggle--hover--background: linear-gradient(135deg, #00ffc4 0%, #00d9a3 100%);
	--chat--toggle--active--background: #00c490;
	--chat--toggle--color: #0a0e14;

	/* Input Area - Dark with borders */
	--chat--textarea--height: 50px;
	--chat--textarea--max-height: 150px;
	--chat--input--font-size: 0.95rem;
	--chat--input--border: 1px solid rgba(255, 255, 255, 0.1);
	--chat--input--border-radius: 8px;
	--chat--input--padding: 0.875rem 1rem;
	--chat--input--background: #1e242e;
	--chat--input--text-color: #ffffff;
	--chat--input--line-height: 1.5;
	--chat--input--placeholder--font-size: var(--chat--input--font-size);
	--chat--input--border-active: 1px solid #00d9a3;
	--chat--input--left--panel--width: 2.5rem;

	/* Button Styles */
	--chat--button--padding: 0.75rem 1.5rem;
	--chat--button--border-radius: 8px;
	--chat--button--font-size: 0.95rem;
	--chat--button--line-height: 1.5;
	
	/* Primary Buttons */
	--chat--button--color--primary: #0a0e14;
	--chat--button--background--primary: #00d9a3;
	--chat--button--border--primary: none;
	--chat--button--color--primary--hover: #0a0e14;
	--chat--button--background--primary--hover: #00ffc4;
	--chat--button--border--primary--hover: none;
	--chat--button--color--primary--disabled: #6b7280;
	--chat--button--background--primary--disabled: #2a3140;
	--chat--button--border--primary--disabled: none;
	
	/* Secondary Buttons */
	--chat--button--color--secondary: #ffffff;
	--chat--button--background--secondary: #2a3140;
	--chat--button--border--secondary: 1px solid rgba(255, 255, 255, 0.1);
	--chat--button--color--secondary--hover: #ffffff;
	--chat--button--background--secondary--hover: #353d4f;
	--chat--button--border--secondary--hover: 1px solid rgba(255, 255, 255, 0.2);
	--chat--button--color--secondary--disabled: #6b7280;
	--chat--button--background--secondary--disabled: #1e242e;
	--chat--button--border--secondary--disabled: 1px solid rgba(255, 255, 255, 0.05);
	
	--chat--close--button--color-hover: #00d9a3;

	/* Send and File Buttons */
	--chat--input--send--button--background: transparent;
	--chat--input--send--button--color: #00d9a3;
	--chat--input--send--button--background-hover: rgba(0, 217, 163, 0.1);
	--chat--input--send--button--color-hover: #00ffc4;
	--chat--input--file--button--background: transparent;
	--chat--input--file--button--color: #b8bec9;
	--chat--input--file--button--background-hover: rgba(255, 255, 255, 0.05);
	--chat--input--file--button--color-hover: #ffffff;
	--chat--files-spacing: 0.5rem;

	/* Body and Footer */
	--chat--body--background: #1e242e;
	--chat--footer--background: #151921;
	--chat--footer--color: #b8bec9;
}

/* Additional custom overrides for better integration */
.chat-button {
    box-shadow: 0 4px 20px rgba(0, 217, 163, 0.5) !important;
    animation: pulse-chat 2s infinite;
}

@keyframes pulse-chat {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(0, 217, 163, 0.5);
    }
    50% {
        box-shadow: 0 4px 30px rgba(0, 217, 163, 0.8);
    }
}

.chat-button:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 6px 30px rgba(0, 217, 163, 0.7) !important;
}

/* Ensure proper text visibility in messages */
.chat-message-text {
    font-weight: 500;
}

/* Scrollbar styling */
.chat-messages-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-list::-webkit-scrollbar-track {
    background: #151921;
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: #00d9a3;
    border-radius: 3px;
}

.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: #00ffc4;
}

/* Input focus state */
.chat-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 217, 163, 0.2);
}

/* Welcome screen if enabled */
.chat-welcome-screen {
    background: #151921 !important;
}

/* Loading dots */
.chat-typing-indicator span {
    background: #00d9a3 !important;
}

/* Links in messages */
.chat-message a {
    color: #00ffc4 !important;
    text-decoration: underline;
}

.chat-message a:hover {
    color: #00d9a3 !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    :root {
        --chat--window--width: calc(100vw - 20px);
        --chat--window--height: calc(100vh - 100px);
        --chat--window--bottom: 10px;
        --chat--window--right: 10px;
    }
}

/* RTL Support */
[dir="rtl"] .chat-message {
    text-align: right;
}

/* RTL Chat Button Positioning */
[dir="rtl"] {
    --chat--window--right: auto;
    --chat--window--left: 30px;
}

[dir="rtl"] .chat-window,
[dir="rtl"] .chat-button,
[dir="rtl"] #n8n-chat > div {
    right: auto !important;
    left: 30px !important;
}

@media (max-width: 768px) {
    [dir="rtl"] {
        --chat--window--left: 10px;
    }
    
    [dir="rtl"] .chat-window,
    [dir="rtl"] .chat-button,
    [dir="rtl"] #n8n-chat > div {
        left: 10px !important;
    }
}


/* Chat Input Layout Fixes */
/* Prevent expand button from going to right, keep send button on right */
[dir="rtl"] .chat-input-container {
    display: flex;
    flex-direction: row-reverse;
}

[dir="rtl"] .chat-input--send-button {
    order: 1;
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .chat-input--file-button,
[dir="rtl"] .chat-input--expand-button {
    order: 3;
}

[dir="rtl"] .chat-input {
    order: 2;
}

/* Ensure send button always on right in RTL */
[dir="rtl"] .chat-footer > div {
    direction: rtl;
    display: flex;
}

/* Fix input controls positioning */
.chat-input-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

[dir="rtl"] .chat-input-controls {
    flex-direction: row-reverse;
}

/* Make Chat Button More Prominent and Noticeable */
.chat-button {
    box-shadow: 0 8px 30px rgba(0, 217, 163, 0.6) !important;
    animation: pulse-prominent 2s infinite, bounce-subtle 3s ease-in-out infinite;
    position: relative;
}

/* Add a notification badge */
.chat-button::before {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #ff6b35;
    border-radius: 50%;
    border: 3px solid var(--chat--color-dark);
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    z-index: 1;
}

@keyframes pulse-prominent {
    0%, 100% {
        box-shadow: 0 8px 30px rgba(0, 217, 163, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 12px 40px rgba(0, 217, 163, 0.9);
        transform: scale(1.05);
    }
}

@keyframes bounce-subtle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes ping {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    75%, 100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Add text hint near chat button on first visit */
.chat-hint {
    position: fixed;
    bottom: 75px;
    right: 120px;
    background: linear-gradient(135deg, #00d9a3 0%, #00ffc4 100%);
    color: #0a0e14;
    padding: 12px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 217, 163, 0.5);
    animation: slideInRight 0.5s ease-out, fadeOutHint 0.5s ease-in 8s forwards;
    z-index: 9998;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
}

.chat-hint::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent;
    border-left-color: #00d9a3;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOutHint {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* RTL positioning for hint */
[dir="rtl"] .chat-hint {
    right: auto;
    left: 120px;
}

[dir="rtl"] .chat-hint::after {
    right: auto;
    left: -10px;
    border-left-color: transparent;
    border-right-color: #00d9a3;
}

/* Mobile positioning */
@media (max-width: 768px) {
    .chat-hint {
        bottom: 80px;
        right: 80px;
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    
    [dir="rtl"] .chat-hint {
        left: 80px;
        right: auto;
    }
}
