/* AI chat widget */
:root {
    --ai-slick-start: #0f172a;
    --ai-slick-mid: #2563eb;
    --ai-slick-end: #14b8a6;
}

.ai-chat-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    width: 380px;
    height: 500px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.ai-chat-widget.hidden {
    display: none;
}

.ai-chat-container.ai-chat-container--debug .ai-chat-widget {
    bottom: 56px;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 12px 12px 0 0;
    background: linear-gradient(135deg, var(--ai-slick-start) 0%, var(--ai-slick-mid) 58%, var(--ai-slick-end) 100%);
    color: #ffffff;
}

.ai-chat-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff !important;
}

.ai-chat-header h3 i,
.ai-chat-header h3 span {
    color: #ffffff !important;
}

.ai-chat-header-buttons {
    display: flex;
    gap: 8px;
}

.ai-chat-header button {
    border: none;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
}

.ai-chat-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-header button i {
    color: #ffffff !important;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: #f5f6f8;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c7cfdb;
    border-radius: 6px;
}

.chat-message {
    display: flex;
    animation: chatFadeIn 0.2s ease-out;
}

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

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

.chat-message-ai,
.chat-message-error {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 85%;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    padding: 10px 12px;
    word-break: break-word;
}

.chat-message-user .chat-message-content {
    color: #ffffff;
    background: linear-gradient(135deg, #3e5f98 0%, #4d8a87 100%);
}

.chat-message-ai .chat-message-content {
    color: #1f2937;
    background: #f1f4f7;
    border: 1px solid #d4dce7;
}

.chat-message-ai .chat-message-content p {
    margin: 0 0 8px;
}

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

.chat-message-ai .chat-message-content h1,
.chat-message-ai .chat-message-content h2,
.chat-message-ai .chat-message-content h3,
.chat-message-ai .chat-message-content h4,
.chat-message-ai .chat-message-content h5,
.chat-message-ai .chat-message-content h6 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.chat-message-ai .chat-message-content ul,
.chat-message-ai .chat-message-content ol {
    margin: 6px 0 8px 18px;
    padding: 0;
}

.chat-message-ai .chat-message-content li {
    margin: 3px 0;
}

.chat-message-ai .chat-message-content code {
    background: #eef2ff;
    color: #1e3a8a;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}

.chat-message-ai .chat-message-content a {
    color: #1d4ed8;
    text-decoration: underline;
}

.chat-message-error .chat-message-content {
    color: #a61f2c;
    background: #fff1f2;
    border: 1px solid #f6c7cc;
}

.ai-chat-footer {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #dde2ea;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
}

.ai-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid #d0d7e3;
    border-radius: 18px;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
}

.ai-chat-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ai-chat-send {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ai-slick-start) 0%, var(--ai-slick-mid) 58%, var(--ai-slick-end) 100%);
    cursor: pointer;
}

.ai-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-chat-send i {
    color: #ffffff !important;
}

.ai-chat-toggle {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.34);
    background: linear-gradient(135deg, var(--ai-slick-start) 0%, var(--ai-slick-mid) 58%, var(--ai-slick-end) 100%);
}

.ai-chat-container.ai-chat-container--debug .ai-chat-toggle {
    bottom: 56px;
}

.ai-chat-toggle i {
    color: #ffffff !important;
}

@media (max-width: 640px) {
    .ai-chat-widget {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        height: 430px;
    }

    .ai-chat-toggle {
        right: 10px;
        bottom: 10px;
    }

    .ai-chat-container.ai-chat-container--debug .ai-chat-widget,
    .ai-chat-container.ai-chat-container--debug .ai-chat-toggle {
        bottom: 46px;
    }
}
