/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --bot-bubble: #f3f4f6;
    --user-bubble: #3b82f6;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Tahoma", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

body[dir="rtl"] {
    direction: rtl;
    font-family: "Tahoma", "Segoe UI", Arial, sans-serif;
}

/* 应用容器 */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* 头部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.avatar-inner {
    font-size: 16px;
}

.header-info h1.title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.reset-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

.reset-btn svg {
    width: 18px;
    height: 18px;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg);
    position: relative;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100%;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-title {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
}

.welcome-text {
    max-width: 400px;
    line-height: 1.6;
}

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

/* 消息气泡 */
.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

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

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

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

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #10b981, #06b6d4);
}

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 15px;
}

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

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

.message-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.message.user .message-bubble a {
    color: #fff;
}

/* 打字指示器 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

/* 输入区域 */
.input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 20px 16px;
    flex-shrink: 0;
}

.stage-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0 8px;
    height: 22px;
    transition: all 0.3s;
}

.stage-indicator.active {
    color: var(--primary);
}

.input-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 14px;
    transition: border-color 0.2s;
}

.input-form:focus-within {
    border-color: var(--primary);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    max-height: 120px;
    color: var(--text);
    padding: 6px 0;
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* 响应式 */
@media (max-width: 640px) {
    .app {
        box-shadow: none;
    }

    .header {
        padding: 12px 14px;
    }

    .chat-container {
        padding: 14px;
    }

    .input-area {
        padding: 10px 14px 12px;
    }

    .message {
        max-width: 88%;
    }

    .header-info h1.title {
        font-size: 15px;
    }
}

/* 滚动条样式 */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

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

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