:root {
    --primary-color: #6C63FF;
    --primary-dark: #5750d1;
    --bg-color: #f4f7f6;
    --chat-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #777777;
    --user-bubble: #6C63FF;
    --bot-bubble: #f1f3f4;
    --border-color: #e0e0e0;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 20px;
}

.chat-header {
    padding: 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 20px;
}

.bg-gradient {
    background: linear-gradient(135deg, #6C63FF, #FF6584);
}

.user-avatar-bg {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
}

.header-info h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.header-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-icon {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon:hover {
    background: #e9ecef;
    color: var(--primary-color);
}

.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #fafbfc;
}

/* Scrollbar styling */
.chat-box::-webkit-scrollbar {
    width: 6px;
}
.chat-box::-webkit-scrollbar-track {
    background: transparent;
}
.chat-box::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.message-wrapper {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.message {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.bot {
    background-color: var(--bot-bubble);
    color: var(--text-main);
    border-top-left-radius: 4px;
}

.message.user {
    background-color: var(--user-bubble);
    color: white;
    border-top-right-radius: 4px;
}

/* Markdown basic formatting in chat */
.message p { margin-bottom: 8px; }
.message p:last-child { margin-bottom: 0; }
.message code { background: rgba(0,0,0,0.1); padding: 2px 4px; border-radius: 4px; font-family: monospace; }
.message pre { background: #282c34; color: #abb2bf; padding: 10px; border-radius: 6px; overflow-x: auto; margin-top: 8px; font-family: monospace; }
.message ul, .message ol { padding-left: 20px; margin-bottom: 8px; }

/* Loading indicator */
.loading-indicator {
    display: flex;
    gap: 5px;
    padding: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #90949c;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.quick-questions {
    padding: 10px 20px;
    background: #fafbfc;
    border-top: 1px solid var(--border-color);
}

.quick-questions p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.qq-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qq-btn {
    background: white;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.qq-btn:hover {
    background: var(--primary-color);
    color: white;
}

.chat-input-area {
    padding: 20px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f1f3f4;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    background: #ffffff;
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 0.95rem;
    max-height: 120px;
    padding: 5px 0;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.modal-content h2 {
    color: #e74c3c;
    margin-bottom: 15px;
}

.modal-content code {
    background: #f1f3f4;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.small-text {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-top: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .message-wrapper {
        max-width: 95%;
    }
}
