/**
 * MCNAC N8N Chat Styles
 * Premium, modern design.
 */

/* Widget Container */
.mcnac-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Toggle Button */
.mcnac-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mcnac-primary, #5ea17b);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    outline: none;
}

.mcnac-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.mcnac-chat-toggle svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

/* Chat Window */
.mcnac-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s ease;
    pointer-events: none;
}

.mcnac-chat-window.active {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.mcnac-chat-header {
    background: var(--mcnac-header-bg, #5ea17b);
    color: var(--mcnac-header-text, #ffffff);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.mcnac-header-info {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.mcnac-header-logo-container {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.mcnac-header-logo-container img {
    width: 100%;
    max-width: 40px;
    -webkit-border-radius: 1000px;
    -moz-border-radius: 1000px;
    border-radius: 1000px;
}

.mcnac-header-logo-container svg {
    width: 24px;
    height: 24px;
    color: var(--mcnac-primary, #5ea17b);
}

.mcnac-header-text-container {
    display: flex;
    flex-direction: column;
}

.mcnac-title {
    margin: 0;
    font-size: 18px;
    line-height: 20px;
    font-weight: 600;
    color: var(--mcnac-header-text, #ffffff) !important;
}

.mcnac-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    opacity: 0.9;
    color: var(--mcnac-header-text, #ffffff) !important;
    line-height: 1.2;
}

.mcnac-chat-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
    align-self: flex-start;
    margin-top: -5px;
}

.mcnac-chat-close:hover {
    opacity: 1;
}

/* Messages Area */
.mcnac-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mcnac-message {
    max-width: 95%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: fadeIn 0.3s ease;
}

.mcnac-message.user {
    background: var(--mcnac-user-bg, #5ea17b);
    color: var(--mcnac-user-text, #ffffff);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.mcnac-message.bot {
    background: #ffffff;
    color: #333333;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mcnac-message.bot.typing {
    display: flex;
    gap: 4px;
    padding: 15px 14px;
    min-width: 40px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Input Area */
.mcnac-chat-input-area {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #eeeeee;
    display: flex;
    gap: 10px;
    align-items: center;
}

#mcnac-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#mcnac-chat-input:focus {
    border-color: var(--mcnac-primary, #5ea17b);
}

#mcnac-chat-send {
    background: transparent;
    border: none;
    color: var(--mcnac-primary, #5ea17b);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mcnac-chat-send:hover {
    background: rgba(0, 0, 0, 0.05);
}

#mcnac-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .mcnac-chat-window {
        bottom: 90px;
        right: 20px;
        height: 60vh;
    }
}

/* YouTube Embed Responsive Wrapper */
.mcnac-yt-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    margin: 10px 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    background: #000000;
}

.mcnac-yt-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 12px;
}

/* Markdown Formatted Elements */
.mcnac-message a.mcnac-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
    transition: opacity 0.2s;
}

.mcnac-message.user a.mcnac-link {
    color: #ffffff;
}

.mcnac-message.bot a.mcnac-link {
    color: var(--mcnac-primary, #5ea17b);
}

.mcnac-message a.mcnac-link:hover {
    opacity: 0.85;
}

/* Code Container, Header & Syntax Highlighting */
.mcnac-code-container {
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mcnac-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #181825;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mcnac-code-lang {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #a6adc8;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

.mcnac-code-lang.lang-php {
    color: #89b4fa;
    background: rgba(137, 180, 250, 0.15);
}

.mcnac-code-lang.lang-js,
.mcnac-code-lang.lang-javascript {
    color: #f9e2af;
    background: rgba(249, 226, 175, 0.15);
}

.mcnac-code-lang.lang-html,
.mcnac-code-lang.lang-xml {
    color: #fab387;
    background: rgba(250, 179, 135, 0.15);
}

.mcnac-code-lang.lang-css {
    color: #89dceb;
    background: rgba(137, 220, 235, 0.15);
}

.mcnac-code-copy {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cdd6f4;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.mcnac-code-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.mcnac-code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px;
    margin: 0;
    font-family: "Fira Code", Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    border: none;
    white-space: pre;
}

.mcnac-code-block code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    font-family: inherit !important;
    white-space: pre;
}

/* Syntax Tokens */
.mcnac-tok-keyword {
    color: #cba6f7;
    font-weight: 600;
}

.mcnac-tok-string {
    color: #a6e3a1;
}

.mcnac-tok-comment {
    color: #6c7086;
    font-style: italic;
}

.mcnac-tok-number {
    color: #fab387;
}

.mcnac-tok-var {
    color: #f38ba8;
}

.mcnac-tok-attr {
    color: #89b4fa;
}

.mcnac-inline-code {
    background: rgba(0, 0, 0, 0.08);
    color: #d63384;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Fira Code", Consolas, Monaco, monospace;
    font-size: 12.5px;
}

.mcnac-message.user .mcnac-inline-code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Headings in Markdown */
.mcnac-md-h {
    margin: 8px 0 4px 0;
    font-weight: 700;
    line-height: 1.3;
}

h3.mcnac-md-h {
    font-size: 16px;
}

h4.mcnac-md-h {
    font-size: 15px;
}

h5.mcnac-md-h {
    font-size: 14px;
}

/* Lists in Markdown */
.mcnac-list {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.mcnac-list-item,
.mcnac-olist-item {
    margin-bottom: 3px;
    line-height: 1.4;
}