/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

/* 标题栏 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* 主要内容区 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 对话区 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

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

.message-content {
    padding: 15px 20px;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.6;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    margin-left: auto;
}

.message.assistant .message-content {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.system .message-content {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    max-width: 100%;
}

/* Markdown样式 */
.message-content p {
    margin-bottom: 10px;
}

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

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.message-content li {
    margin-bottom: 5px;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

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

/* LaTeX数学公式样式 */
.katex {
    font-size: 1.1em;
}

.katex-block {
    display: block;
    text-align: center;
    margin: 15px 0;
    overflow-x: auto;
}

.latex-error {
    color: #d32f2f;
    background: #ffebee;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* 输入区 */
.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.3s;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 组件展示区 */
.component-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.component-display {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.component-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
}

.component-placeholder p {
    font-size: 18px;
    margin-bottom: 10px;
}

.component-placeholder .hint {
    font-size: 14px;
}

/* 组件iframe */
.component-frame {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
    background: white;
}

/* 加载动画 */
.loading {
    display: inline-block;
}

.loading::after {
    content: '';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .chat-container {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        min-height: 50%;
    }

    .component-container {
        min-height: 50%;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar,
.component-display::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.component-display::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.component-display::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.component-display::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 确认消息样式 */
.confirm-message {
    background: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
}

.confirm-message strong {
    color: #856404;
    font-size: 16px;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.confirm-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.confirm-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

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

.confirm-yes:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.confirm-no {
    background: #e0e0e0;
    color: #333;
}

.confirm-no:hover:not(:disabled) {
    background: #d0d0d0;
}

/* 图片显示样式 */
.image-display {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.image-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
}

.image-header h3 {
    margin: 0;
    font-size: 18px;
}

.image-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    overflow: auto;
}

.image-content img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.image-description {
    padding: 15px 20px;
    margin: 0;
    background: white;
    color: #666;
    font-size: 14px;
    text-align: center;
    border-top: 1px solid #eee;
}
