@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&display=swap');

:root {
    --primary-text: #1E1E1E;
    --secondary-text: #525252;
    --accent-color: #2F29D9;
    --accent-hover: #1913CE;
    --bg-white: #FFFFFF;
    --bg-light: #F4F4F4;
    --bg-body: #FAFBFD;
    --border-color: #D6D9DD;
    --error-color: #EE2828;
    --font-family: 'DM Sans', sans-serif;
}

/* Floating Widget Container */
#aa-chatbot-wrapper {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: var(--font-family);
}

/* Force font on all children */
#aa-chatbot-wrapper * {
    font-family: var(--font-family);
    margin-top: 0px !important;
}

/* Toggle Button */
#aa-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#aa-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Chat Window */
#aa-chat-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 350px;
    height: 500px;
    background-color: var(--bg-body);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom left;
}

#aa-chat-window.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

#aa-chat-window.visible {
    display: flex;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Header */
.chat-header {
    background: var(--bg-white);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.header-title {
    display: flex;
    align-items: center;
    color: var(--primary-text);
    font-weight: 600;
}

.header-title .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    margin-right: 10px;
    color: white;
}

#close-chat {
    background: transparent;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    padding: 5px;
}

#close-chat:hover {
    color: var(--primary-text);
}

/* Chat Area */
#chat-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--bg-body);
}

/* Scrollbar */
#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-track {
    background: var(--bg-body);
}

#chat-container::-webkit-scrollbar-thumb {
    background: var(--secondary-text);
    border-radius: 3px;
}

/* Messages */
.message-animate {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Avatar Container */
.avatar-container {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: var(--accent-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Message Bubbles */
.message-bubble {
    padding: 0.75rem;
    border-radius: 1rem;
    max-width: 80%;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    font-size: 0.875rem;
    line-height: 1.625;
}

.message-user {
    background-color: var(--accent-color);
    color: white;
    align-self: flex-end;
}

.message-model {
    background-color: var(--bg-white);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
}

.message-system {
    background-color: var(--bg-light);
    color: var(--secondary-text);
    font-size: 0.75rem;
    font-style: italic;
    border: 1px solid var(--border-color);
    align-self: center;
}

.message-error {
    background-color: var(--error-color);
    color: white;
}

/* Input Area */
#chat-form {
    padding: 15px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 10px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

#user-input:focus {
    border-color: var(--accent-color);
}

#chat-form button {
    background: var(--accent-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

#chat-form button:hover {
    background: var(--accent-hover);
}

#chat-form button:disabled {
    background: var(--secondary-text);
    cursor: not-allowed;
}

/* Utility Classes */
.flex {
    display: flex;
}

.items-start {
    align-items: flex-start;
}

.space-x-2>*+* {
    margin-left: 0.5rem;
}

.justify-end {
    justify-content: flex-end;
}

.rounded-tr-none {
    border-top-right-radius: 0;
}

.rounded-tl-none {
    border-top-left-radius: 0;
}

/* Link Buttons (Simple Links) */
.chat-link {
    color: var(--accent-color);
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.chat-link:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

/* Formatted Text Styles */
.message-bubble ul {
    list-style-type: disc;
    margin-left: 1.2rem;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

.message-bubble li {
    margin-bottom: 0.25rem;
}

.message-bubble p {
    margin-bottom: 0.5rem;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble h3 {
    font-weight: 700;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.message-bubble strong {
    font-weight: 700;
}