/* 全局样式 */
:root {
    --primary-color: #0071e3;
    --secondary-color: #86b9ff;
    --background-color: #f5f5f7;
    --card-background: #ffffff;
    --text-color: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #d2d2d7;
    --success-color: #34c759;
    --user-message-bg: #e9f0fd;
    --ai-message-bg: #f5f5f7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.app-header {
    background-color: var(--card-background);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(90deg, #0071e3, #00c6fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    position: relative;
    padding-left: 0.5rem;
}

.app-header h1::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: linear-gradient(to bottom, #0071e3, #00c6fb);
    border-radius: 2px;
}

.app-header nav {
    display: flex;
    gap: 1rem;
}

.app-header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header nav a.active {
    color: var(--primary-color);
    background-color: rgba(0, 113, 227, 0.1);
}

.app-header nav a:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.back-button a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.back-button a:hover {
    background-color: rgba(0, 113, 227, 0.1);
}

/* 聊天容器样式 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 248, 250, 0.9));
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.06);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 113, 227, 0.08);
}

.chat-messages::before {
    content: '对话记录';
    display: block;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    position: relative;
    letter-spacing: -0.3px;
}

.chat-messages::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 113, 227, 0.1), transparent);
}

.welcome-message {
    text-align: center;
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.95));
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 113, 227, 0.1);
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 113, 227, 0.1);
}

.welcome-message::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 198, 251, 0.05) 0%, transparent 70%);
    z-index: -1;
}

.welcome-message::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(0, 113, 227, 0.3), transparent);
}

.welcome-message h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.tech-title {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #0071e3, #00c6fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2rem;
    text-shadow: 0 2px 10px rgba(0, 113, 227, 0.2);
    margin-bottom: 1.5rem;
}

.tech-text {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #333;
    max-width: 90%;
    margin: 0 auto;
    position: relative;
    padding: 0.5rem 0;
}

.tech-text::before, .tech-text::after {
    content: '';
    position: absolute;
    height: 2px;
    width: 30px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    left: 50%;
    transform: translateX(-50%);
}

.tech-text::before {
    top: 0;
}

.tech-text::after {
    bottom: 0;
}

.message {
    padding: 1rem;
    border-radius: 12px;
    max-width: 95%; /* 增加最大宽度，使消息可以显示更多内容 */
    animation: fadeIn 0.3s ease;
    overflow: visible; /* 确保内容可以完整显示 */
}

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

.user-message {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1), rgba(0, 198, 251, 0.05));
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.1);
    border-right: 2px solid rgba(0, 113, 227, 0.3);
    position: relative;
}

.user-message::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 113, 227, 0.3));
}

.ai-message {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.05), rgba(0, 198, 251, 0.05));
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
    border-left: 2px solid rgba(0, 113, 227, 0.3);
    position: relative;
}

.raw-message {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 248, 250, 0.9));
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 113, 227, 0.15);
    position: relative;
    margin: 1rem 0;
    padding: 1.5rem;
}

.raw-message .message-content {
    white-space: pre-wrap;
    font-family: monospace;
    line-height: 1.6;
    overflow-x: auto;
}

.raw-message .message-sender {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 113, 227, 0.1);
    padding-bottom: 0.5rem;
}

.system-message {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(245, 245, 247, 0.9));
    align-self: center;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.75rem 1.5rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
    max-width: 90%;
}

.ai-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 113, 227, 0.3), transparent);
}

.message-content {
    word-break: break-word;
    max-height: none !important; /* 确保内容不会被截断 */
    overflow: visible !important; /* 确保内容可以完整显示 */
}

.ai-message .message-content {
    white-space: pre-wrap;
}

.typing-indicator {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--ai-message-bg);
    border-radius: 12px;
    align-self: flex-start;
    box-shadow: var(--shadow);
    animation: fadeIn 0.3s ease;
}

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

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

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

@keyframes typingAnimation {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 聊天输入区域样式 */
.chat-input-container {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.clear-button {
    align-self: flex-end;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.clear-button:hover {
    color: var(--text-color);
}

.input-wrapper {
    display: flex;
    background-color: var(--card-background);
    border-radius: 24px;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 113, 227, 0.1);
    position: relative;
    overflow: hidden;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 198, 251, 0.3), transparent);
}

.input-wrapper:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.1);
    border-color: rgba(0, 113, 227, 0.3);
}

#userInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-size: 1rem;
    max-height: 120px;
    overflow-y: auto;
}

#sendMessage {
    background: linear-gradient(135deg, #0071e3, #00c6fb);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
    position: relative;
    overflow: hidden;
}

#sendMessage::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sendMessage:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.4);
}

#sendMessage:hover::before {
    opacity: 1;
}

#sendMessage:disabled {
    background: linear-gradient(135deg, #a0a0a0, #c0c0c0);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* 历史记录页面样式 */
.history-container {
    flex: 1;
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-content {
    flex: 1;
}

.history-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.history-preview {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    margin-left: 1rem;
}

.empty-history-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.text-secondary {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #0071e3, #00c6fb);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 24px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
    margin-top: 0.5rem;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.4);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 113, 227, 0.3);
}

/* 聊天详情页样式 */
.chat-detail-info {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(250, 250, 252, 0.98));
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 15px 30px rgba(0, 113, 227, 0.1);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 113, 227, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-detail-info:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px rgba(0, 113, 227, 0.15);
}

.chat-detail-info::before {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(0, 198, 251, 0.05) 0%, transparent 70%);
    z-index: 0;
}

.chat-detail-info::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0071e3, #00c6fb, transparent);
    border-radius: 0 0 20px 20px;
}

.chat-detail-info h2 {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-color);
    position: relative;
    z-index: 1;
    letter-spacing: -0.5px;
}

.chat-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    position: relative;
    z-index: 1;
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background-color: rgba(0, 113, 227, 0.05);
    border-radius: 6px;
}

.chat-overview {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(245, 245, 247, 0.95));
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.08);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 113, 227, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-overview:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 113, 227, 0.12);
}

.chat-overview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #0071e3, #00c6fb);
    border-radius: 2px 0 0 2px;
}

.chat-overview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, #0071e3, transparent);
}

.chat-overview h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    position: relative;
    display: inline-block;
}

.chat-overview h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #0071e3, #00c6fb);
    border-radius: 1px;
}

.overview-content {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    white-space: pre-wrap;
    padding: 0.5rem 0;
    position: relative;
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 0.5rem;
    width: 100%; /* 确保容器宽度足够 */
    max-width: 100%; /* 确保容器最大宽度不受限制 */
}

.message-sender {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

/* Markdown 样式 */
/* 决策结论和决策置信度样式 */
.decision-conclusion {
    background-color: rgba(0, 113, 227, 0.1);
    border-left: 3px solid var(--primary-color);
    padding: 0.8rem 1rem;
    margin: 0.8rem 0;
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.decision-confidence {
    background-color: rgba(52, 199, 89, 0.1);
    border-left: 3px solid var(--success-color);
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-color);
    display: inline-block;
}

.message-content pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.message-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

.message-content ul, .message-content ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}

.message-content th, .message-content td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.message-content th {
    background-color: rgba(0, 0, 0, 0.05);
}

.loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 113, 227, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1.25rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .welcome-message {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem;
    }
    
    .app-header h1 {
        font-size: 1.1rem;
    }
    
    .app-header nav a {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
    }
    
    .chat-container, .history-container {
        padding: 0.75rem;
    }
    
    .message {
        padding: 0.75rem;
    }
}