/* Modern color palette */
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #e0e7ff;
    --secondary-color: #764ba2;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --user-message: #667eea;
    --bot-message: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}

.chat-container {
    width: 100%;
    max-width: 900px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 85vh;
    max-height: 800px;
}

/* Header Styles */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
}

.header-info h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Box */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--background);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.chat-box::-webkit-scrollbar-track {
    background: transparent;
}

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

.chat-box::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    animation: fadeIn 0.5s ease-in;
}

.welcome-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.welcome-message h3 {
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 24px;
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.quick-reply-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-reply-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.quick-reply-btn i {
    font-size: 16px;
}

/* Message Styles */
.message-wrapper {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.message-wrapper.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-wrapper.bot .message-avatar {
    background: var(--bot-message);
    color: var(--primary-color);
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-wrapper.user .message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message-wrapper.bot .message {
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-content {
    font-size: 15px;
}

.message-time {
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.7;
}

.message-wrapper.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.chat-input {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.chat-input input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-input button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Reset Button */
.chat-reset {
    padding: 12px 24px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-reset button {
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-reset button:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .chat-container {
        border-radius: 0;
        height: 100vh;
        max-height: none;
    }

    .message {
        max-width: 85%;
    }

    .quick-replies {
        flex-direction: column;
    }

    .quick-reply-btn {
        width: 100%;
    }
}

/* Code blocks styling */
.message pre {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message code {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-wrapper.user pre {
    background: rgba(255, 255, 255, 0.2);
}

/* Links in messages */
.message a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.9;
}

.message a:hover {
    opacity: 1;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content ul {
    list-style-type: disc;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content li {
    margin: 8px 0;
    line-height: 1.6;
    padding-left: 8px;
}

.message-content li::marker {
    color: var(--primary-color);
    font-weight: 600;
}

/* Nested lists */
.message-content ul ul,
.message-content ol ul,
.message-content ul ol,
.message-content ol ol {
    margin: 6px 0;
    padding-left: 20px;
}

/* Headers trong message */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content h1 { font-size: 20px; }
.message-content h2 { font-size: 18px; }
.message-content h3 { font-size: 16px; }
.message-content h4 { font-size: 15px; }

/* Paragraphs */
.message-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.message-content p:first-child {
    margin-top: 0;
}

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

/* Bold text */
.message-content strong,
.message-content b {
    font-weight: 600;
    color: var(--text-primary);
}

/* Italic text */
.message-content em,
.message-content i {
    font-style: italic;
}

/* Inline code */
.message-content code {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 14px;
    color: var(--primary-color);
}

/* Code blocks */
.message-content pre {
    background: #f1f5f9;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border-left: 3px solid var(--primary-color);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-primary);
    font-size: 13px;
}

/* Line breaks */
.message-content br {
    display: block;
    margin: 4px 0;
    content: "";
}

/* Spacing between elements */
.message-content > *:not(:last-child) {
    margin-bottom: 12px;
}

/* User message styling */
.message-wrapper.user .message-content strong {
    color: white;
}

.message-wrapper.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message-wrapper.user .message-content li::marker {
    color: rgba(255, 255, 255, 0.8);
}

/* Improve readability */
.message-content {
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-content ul,
.message-content ol {
    margin: 12px 0 !important;
    padding-left: 24px !important;
    display: block !important;
}

.message-content li {
    margin: 8px 0 !important;
    line-height: 1.6 !important;
    padding-left: 8px !important;
    display: list-item !important;
}

/* Fix whitespace preservation */
.message-content {
    white-space: normal !important;
}

/* Đảm bảo paragraphs có spacing */
.message-content p {
    margin: 10px 0 !important;
    line-height: 1.6 !important;
    display: block !important;
}

/* Đảm bảo br tags hoạt động đúng */
.message-content br {
    display: block !important;
    margin: 4px 0 !important;
    content: "" !important;
    line-height: 0 !important;
}

/* Fix spacing cho các block elements */
.message-content > * {
    margin-bottom: 12px !important;
}

.message-content > *:last-child {
    margin-bottom: 0 !important;
}

/* Đảm bảo list markers luôn hiển thị */
.message-content ul {
    list-style-type: disc !important;
    list-style-position: outside !important;
}

.message-content ol {
    list-style-type: decimal !important;
    list-style-position: outside !important;
}

