/* N8N Chat Widget Custom Styles */
:root {
    --chat--color-primary: #000000;
    --chat--color-primary-shade-50: #000000;
    --chat--color-primary-shade-100: #000000;
    --chat--color-secondary: #000000;
    --chat--color-secondary-shade-50: #000000;
    --chat--color-white: #FFFFFF;
    --chat--color-light: #F7F7F7;
    --chat--color-light-shade-50: #EFEFEF;
    --chat--color-light-shade-100: rgba(0, 0, 0, 0.05);
    --chat--color-medium: #D2D4D9;
    --chat--color-dark: #000000;
    --chat--color-disabled: #777980;
    --chat--color-typing: #404040;

    --chat--spacing: 1rem;
    --chat--border-radius: 1rem;
    --chat--transition-duration: 0.2s;
    --chat--window--width: 400px;
    --chat--window--height: 600px;
    --chat--textarea--height: 56px;

    --chat--message--bot--background: var(--chat--color-white);
    --chat--message--bot--color: var(--chat--color-dark);
    --chat--message--user--background: var(--chat--color-secondary);
    --chat--message--user--color: var(--chat--color-white);
    --chat--message--pre--background: rgba(0, 0, 0, 0.05);

    --chat--toggle--background: var(--chat--color-primary);
    --chat--toggle--hover--background: var(--chat--color-primary-shade-50);
    --chat--toggle--active--background: var(--chat--color-primary-shade-100);
    --chat--toggle--color: var(--chat--color-white);
    --chat--toggle--size: 64px;

    --chat--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
    --chat--heading--font-size: 1.125rem;
    --chat--message--font-size: 0.9375rem;
    --chat--message-line-height: 1.5;
    --chat--input--font-size: 0.9375rem;
}

.n8n-chat {
    font-family: var(--chat--font-family);
}

.chat-window-wrapper {
    position: fixed;
    display: flex;
    flex-direction: column;
    bottom: 90px;
    right: 20px;
    z-index: 10000;
    max-width: calc(100% - var(--chat--spacing) * 2);
    max-height: calc(100% - var(--chat--spacing) * 2);
}

.chat-window {
    display: flex;
    width: var(--chat--window--width);
    height: var(--chat--window--height);
    max-width: 100%;
    max-height: 100%;
    background: var(--chat--color-white);
    border-radius: var(--chat--border-radius);
    box-shadow: rgb(0 0 0 / 15%) 0px 6px 26px, rgb(0 0 0 / 8%) 0px 1px 3px;
    overflow: hidden;
    transform-origin: bottom right;
}

.chat-layout {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--chat--color-white);
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--chat--color-white);
}

.chat-header-content {
    flex: 1;
    min-width: 0;
}

.chat-header-title {
    font-size: var(--chat--heading--font-size);
    font-weight: 600;
    color: var(--chat--color-dark);
    margin: 0;
    line-height: 1.4;
}

.chat-header-subtitle {
    font-size: var(--chat--message--font-size);
    color: #666;
    margin: 0.25rem 0 0;
    line-height: 1.4;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    background: var(--chat--color-white);
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.chat-message.chat-message-from-bot {
    align-self: flex-start;
}

.chat-message.chat-message-from-bot .chat-message-markdown {
    padding: 12px 16px;
    background-color: rgb(245, 245, 245);
    color: var(--chat--color-dark);
    border-radius: 15px;
    border-bottom-left-radius: 4px;
}

.chat-message.chat-message-from-user {
    align-self: flex-end;
}

.chat-message.chat-message-from-user .chat-message-markdown {
    padding: 12px 16px;
    background-color: #000000;
    color: var(--chat--color-white);
    border-radius: 15px;
    border-bottom-right-radius: 4px;
}

.chat-message-markdown {
    font-size: var(--chat--message--font-size);
    line-height: var(--chat--message-line-height);
}

.chat-message-markdown p {
    margin: 0;
}

.chat-footer {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--chat--color-white);
    padding-bottom:.6rem;
}

/* Powered by DialogX */
.chat-powered-by {
    text-align: center;
    padding-top: 8px;
    font-size: 12px;
    color: var(--chat--color-disabled);
    background: var(--chat--color-white);
    /* border-top: 1px solid var(--chat--color-light-shade-100); */
}

.chat-powered-by a {
    color: var(--chat--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.chat-powered-by a:hover {
    text-decoration: underline;
}

.chat-input {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--chat--color-white);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 28px;
    transition: border-color 0.2s ease;
}

.chat-input:focus-within {
    border-color: rgba(0, 0, 0, 0.2);
}

.chat-input textarea {
    flex: 1;
    height: var(--chat--textarea--height);
    padding: 1rem 3rem 1rem 1.25rem;
    border: none;
    background: transparent;
    font-family: var(--chat--font-family);
    font-size: var(--chat--input--font-size);
    line-height: 1.4;
    resize: none;
    outline: none !important;
    box-shadow: none !important;
}

.chat-input textarea:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.chat-input textarea:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.chat-input-send-button {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--chat--color-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.chat-input-send-button:hover {
    opacity: 0.8;
}

.chat-input-send-button[disabled] {
    opacity: 0.4;
    cursor: default;
}

/* Quick Reply Buttons */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-quick-reply {
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    background: var(--chat--color-white);
    border: 1px solid rgba(0, 0, 0, 0.08);
    font-size: var(--chat--message--font-size);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-quick-reply:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Email Input Section */
.chat-email-input {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fb;
    border-radius: var(--chat--border-radius);
}

.chat-email-input-label {
    font-size: var(--chat--message--font-size);
    color: var(--chat--color-dark);
    margin-bottom: 0.5rem;
}

.chat-email-input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    font-size: var(--chat--input--font-size);
    transition: border-color 0.2s ease;
}

.chat-email-input-field:focus {
    border-color: rgba(0, 0, 0, 0.2);
    outline: none;
}

.chat-email-submit {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--chat--color-primary);
    color: var(--chat--color-white);
    border: none;
    border-radius: 0.5rem;
    font-size: var(--chat--input--font-size);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chat-email-submit:hover {
    opacity: 0.9;
}

/* Typing Indicator */
.chat-message-typing {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f0f0f0;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    max-width: fit-content;
}

.chat-message-typing-dots {
    display: flex;
    gap: 0.25rem;
}

.chat-message-typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

.chat-message-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-message-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* New typing indicator styles for the actual structure being used */
.chat-message-typing-body {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-message-typing-circle {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.chat-message-typing-animation-bouncing .chat-message-typing-circle {
    animation: typingAnimation 1.4s infinite;
}

.chat-message-typing-animation-bouncing .chat-message-typing-circle:nth-child(2) { 
    animation-delay: 0.2s; 
}

.chat-message-typing-animation-bouncing .chat-message-typing-circle:nth-child(3) { 
    animation-delay: 0.4s; 
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Window Controls */
.chat-window-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.chat-window-button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.chat-window-button:hover {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .chat-header {
        padding-top: calc(1.5rem + env(safe-area-inset-top));
    }

    .chat-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* Message Markdown Styles */
.chat-message-markdown {
    color: var(--chat--color-dark);
    line-height: var(--chat--message-line-height);
}

.chat-message-markdown p {
    margin: 0 0 0.75rem 0;
}

.chat-message-markdown p:last-child {
    margin-bottom: 0;
}

.chat-message-markdown a {
    color: var(--chat--color-primary);
    text-decoration: underline;
}

.chat-message-markdown code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.chat-message-markdown pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.chat-message-markdown pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.chat-message-markdown ul, 
.chat-message-markdown ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.chat-message-markdown li {
    margin: 0.25rem 0;
}

/* Ensure markdown text is black in user messages */
.chat-message.chat-message-from-user .chat-message-markdown {
    color: var(--chat--color-white);
}

/* Add icon to chat header */
.chat-header::before {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    padding: 4px;
    margin-right: 8px;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='10' rx='2' ry='2'%3E%3C/rect%3E%3Ccircle cx='8' cy='16' r='1'%3E%3C/circle%3E%3Ccircle cx='16' cy='16' r='1'%3E%3C/circle%3E%3Cpath d='M12 7v4'%3E%3C/path%3E%3Cpath d='M7 7h10'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Style for chat-heading */
.chat-heading {
    display: flex;
    flex-direction: column;
    padding: 0;
    font-weight: bold;
    width: 100%;
}

.chat-heading h1 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: var(--chat--color-dark);
    display: block;
    width: 100%;
}

.chat-heading p {
    margin: 0;
    font-weight: 400;
    color: #999;
    font-size: 12px;
    display: block;
    width: 100%;
}

/* Chat Toggle Button */
.chat-window-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--dialogx-primary-light, #000307);
    color: white;
    border: none;
    box-shadow: var(--dialogx-shadow, 0 2px 8px rgba(0,0,0,0.15));
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chat-window-toggle svg {
    width: 32px;
    height: 32px;
}

/* Remove the previous chat-toggle styling */
.chat-toggle {
    display: none;
} 