/* ==========================================================================
   AI Assistant Modal
   Description: Styles for the chat modal UI (layout, messages, input, loader).
   Notes for buyers:
   - Keep class names intact to preserve JS behavior.
   - Customize colors/spacing freely; animations are timing-safe.
   - Avoid renaming structural classes: .modal-ai, .chat-messages, .chat-input, .chat-message.
   ========================================================================== */
   .modal-ai {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 500px;
    max-height: 80vh;
    background-color: #fff;
    border-radius: 15px;
    z-index: 1000;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-ai.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.modal-ai.hide {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7f7f7;
    border-radius: 15px;
    height: 100%;
}

.chat-header {
    padding: 12px;
    background: #fff;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #999 #f7f7f7;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 4px;
}

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

.chat-message {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
}

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

.chat-message.ai {
    justify-content: flex-start;
    gap: 10px;
}

.chat-message.ai.template {
    display: none;
}

.chat-message .message-content {
    max-width: 80%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.chat-message.user .message-content {
    background: #404852;
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

.chat-message.user .message-content::before {
    content: '';
    position: absolute;
    top: 10px;
    right: -6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 7px;
    border-color: transparent transparent transparent #404852;
}

.chat-message.user .message-content::after {
    content: none;
}

.chat-message.ai .message-content {
    background: #e9e9eb;
    color: #1c1c1e;
    border: none;
    box-shadow: none;
    border-radius: 4px 16px 16px 16px;
}

.chat-message.ai .message-content::before {
    content: '';
    position: absolute;
    top: 10px;
    left: -6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 7px 6px 0;
    border-color: transparent #e9e9eb transparent transparent;
}

.chat-message.ai .message-content::after {
    content: none;
}

.chat-message.ai .message-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-color, #e6e8eb);
    box-shadow: 2px 2px 6px rgba(150, 152, 158, 0.22);
    color: var(--ico-color, #4a5260);
    font-size: 15px;
}

.chat-message.ai:not(.template) .message-icon-wrap {
    display: flex;
}

.chat-message.ai .loading-dots {
    display: none;
    gap: 5px;
    align-items: center;
    padding: 0 8px;
    height: 36px;
}

.chat-message.ai.loading .loading-dots {
    display: flex;
}

.chat-message.ai .loading-dots span {
    width: 5px;
    height: 5px;
    background: #666;
    border-radius: 50%;
    animation: bounce 0.6s infinite alternate;
}

.chat-message.ai .loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-message.ai .loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.chat-input {
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.chat-input textarea {
    flex: 1;
    padding: 12px 50px 12px 15px;
    border: none;
    border-radius: 12px;
    background: #f0f0f0;
    font-size: 14px;
    min-height: 40px;
    height: auto;
    max-height: 100px;
    outline: none;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.1), inset -2px -2px 5px rgba(255, 255, 255, 0.7);
    transition: box-shadow 0.3s ease, background 0.3s ease;
    resize: none;
    box-sizing: border-box;
    font-family: 'Titillium Web', sans-serif;
    line-height: 1.4;
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-input textarea::-webkit-scrollbar {
    width: 0;
}

.chat-input textarea:focus {
    background: #fff;
    box-shadow: 0 0 0 2px #404852, inset 2px 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-input button {
    position: absolute;
    right: 15px;
    width: 36px;
    height: 36px;
    border: none;
    background: #404852;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chat-input button:hover {
    background: #33383e;
    transform: scale(1.05);
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1.5),
       (max-width: 768px) and (min-resolution: 144dpi) {
    .modal-ai {
        width: 90%;
        max-height: 85vh;
    }
    .chat-header {
        padding: 10px;
    }
    .chat-messages {
        padding: 10px;
        padding-bottom: 60px;
    }
    .chat-input {
        padding: 8px;
    }
    .chat-input textarea {
        min-height: 36px;
        max-height: 80px;
        padding: 10px 45px 10px 12px;
    }
    .chat-input button {
        width: 32px;
        height: 32px;
        right: 12px;
    }
    .chat-message.ai .message-icon-wrap,
    .chat-message.ai .loading-dots {
        width: 32px;
        height: 32px;
    }
}

/* -------- Enhanced content styles (markdown-like) -------- */
.chat-message .message-content p {
    margin: 0 0 8px 0;
}
.chat-message .message-content a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px dotted rgba(37,99,235,.45);
}
.chat-message .message-content a:hover {
    text-decoration: underline;
}
.chat-message .message-content .inline-code {
    background: #f4f6f8;
    border: 1px solid #e7e9ee;
    border-radius: 6px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}
.chat-message .message-content .code-block {
    background: #0f172a;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #0b1223;
    margin: 10px 0;
}
.chat-message .message-content .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(180deg, #111827, #0b1223);
    color: #e5e7eb;
    border-bottom: 1px solid #0b1223;
}
.chat-message .message-content .code-lang {
    font-size: 12px;
    opacity: .8;
}
.chat-message .message-content .code-copy {
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
}
.chat-message .message-content .code-copy:hover {
    background: #111827;
}
.chat-message .message-content pre {
    margin: 0;
    overflow: auto;
    padding: 12px 14px;
    background: transparent;
}
.chat-message .message-content pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #e5e7eb;
}