/* 基本样式 */
body {
    font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #0056b3;
}

/* 状态栏 */
.status-bar {
    text-align: center;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-weight: bold;
}
.status-success { background-color: #d4edda; color: #155724; }
.status-error   { background-color: #f8d7da; color: #721c24; }
.status-loading { background-color: #d1ecf1; color: #0c5460; }
.status-info    { background-color: #e2e3e5; color: #383d41; }


/* 标签页样式 */
.tabs {
    overflow: hidden;
    border-bottom: 1px solid #ccc;
    margin-bottom: 20px;
}

.tab-link {
    background-color: #f1f1f1;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
    font-size: 17px;
    border-radius: 5px 5px 0 0;
}

.tab-link:hover {
    background-color: #ddd;
}

.tab-link.active {
    background-color: #007bff;
    color: white;
}

.tab-content {
    display: none;
    padding: 6px 12px;
    border-top: none;
}
.tab-content.active {
    display: block;
}

/* 表单和网格布局 */
fieldset {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
}

legend {
    font-weight: bold;
    color: #0056b3;
    padding: 0 10px;
}

.form-grid, .settings-grid, .results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
}


input[type="number"],
input[type="text"],
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
}

.button-group {
    margin-top: 15px;
    margin-bottom: 15px;
}

button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 10px;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 加载动画 */
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* 表格样式 */
.table-container {
    max-height: 400px; /* 增加最大高度 */
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
    white-space: nowrap; /* 防止表头和单元格内容换行 */
}

th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
    z-index: 1; /* 确保表头在滚动时保持在最上层 */
}

tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 结果区域 */
#optimization-results {
    margin-top: 20px;
}

.result-item {
    min-height: 300px;
}
pre {
    background-color: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: #333; /* 确保文本颜色可读 */
}
.ai-response {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 100px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
}


/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.pagination button, .pagination span {
    margin: 0 5px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: #fff;
    cursor: pointer;
    border-radius: 4px;
}

.pagination button:disabled {
    cursor: not-allowed;
    background-color: #f9f9f9;
    color: #ccc;
}

.pagination .active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* 响应式布局 */
@media (max-width: 768px) {
    .form-grid, .settings-grid, .results-grid {
        grid-template-columns: 1fr;
    }
    .tabs {
        display: flex;
        flex-direction: column;
    }
    .tab-link {
        width: 100%;
        box-sizing: border-box;
        border-radius: 5px;
        margin-bottom: 5px;
    }
}