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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-window {
    width: 100%;
    max-width: 500px;
    height: 700px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.chat-header {
    background: #1e3a8a;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.header-content h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.warning {
    font-size: 0.75rem;
    color: #fbbf24;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Settings Panel */
.settings-panel {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
}

.setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1e3a8a;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

.message-wrapper {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-out;
}

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

.user-wrapper {
    justify-content: flex-end;
}

.bot-wrapper {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar {
    background: #1e3a8a;
    color: white;
    font-size: 0.9rem;
}

.message {
    max-width: 70%;
    position: relative;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.user-message .message-content {
    background: #1e3a8a;
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

.bot-message.error .message-content {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.message-time {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
}

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

.bot-message .message-time {
    text-align: left;
}

/* Chat Input */
.chat-input {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 16px 20px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 8px 16px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #1e3a8a;
}

#user-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    max-height: 100px;
    min-height: 20px;
    padding: 8px 0;
}

#user-input::placeholder {
    color: #9ca3af;
}

#send-btn {
    background: #1e3a8a;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
    background: #1e40af;
    transform: scale(1.05);
}

#send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Markdown Content Styling */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 8px 0 4px 0;
    color: inherit;
}

.message-content p {
    margin: 4px 0;
}

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

.message-content li {
    margin: 2px 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding-left: 12px;
    margin: 8px 0;
    font-style: italic;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.tab-content::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.tab-content::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.tab-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.tab-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chat-window {
        height: calc(100vh - 20px);
        max-width: none;
    }
    
    .message {
        max-width: 85%;
    }
    
    .header-content h1 {
        font-size: 1rem;
    }
    
    .warning {
        font-size: 0.7rem;
    }
}
