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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    height: calc(100vh - 40px);
}

/* 左侧对话区域 */
.chat-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    text-align: center;
}

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

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

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 16px;
    border-radius: 12px;
    max-width: 85%;
}

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

.message.assistant .message-content {
    background: #f5f5f7;
    color: #333;
}

.message-content p {
    margin-bottom: 12px;
    line-height: 1.6;
}

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

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

.message-content li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.input-section {
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 24px;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.3s;
    max-height: 120px;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

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

.clear-btn {
    width: 100%;
    padding: 10px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: white;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: #f5f5f5;
    border-color: #667eea;
    color: #667eea;
}

/* 右侧图形显示区域 */
.graph-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.graph-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.graph-header h2 {
    font-size: 20px;
}

.graph-info {
    font-size: 13px;
    opacity: 0.9;
}

.graph-container {
    flex: 1;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

#functionChart {
    max-height: 100%;
    max-width: 100%;
}

.graph-controls {
    padding: 16px 24px;
    background: #fafafa;
    border-top: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 250px;
}

.control-group label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.control-group input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: 14px;
}

.control-group input:focus {
    outline: none;
    border-color: #f093fb;
}

.control-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

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

.function-info {
    padding: 20px 24px;
    border-top: 1px solid #e5e5e5;
    max-height: 200px;
    overflow-y: auto;
}

.function-info h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
}

#functionDetails {
    font-size: 14px;
    line-height: 1.8;
    color: #666;
}

.placeholder {
    color: #999;
    font-style: italic;
}

/* 加载指示器 */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1000;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.chat-container::-webkit-scrollbar-track,
.function-info::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-container::-webkit-scrollbar-thumb,
.function-info::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.function-info::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        height: calc(100vh - 20px);
        gap: 10px;
    }

    .header h1 {
        font-size: 22px;
    }

    .message-content {
        max-width: 90%;
    }

    .control-group {
        flex-wrap: wrap;
    }
}
