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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* 查询区 */
.query-section {
    margin-bottom: 30px;
}

.query-section h2 {
    margin-bottom: 15px;
    color: #333;
}

.query-box {
    display: flex;
    gap: 10px;
}

#queryInput {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

#queryInput:focus {
    border-color: #667eea;
}

#queryBtn {
    padding: 12px 30px;
    font-size: 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

#queryBtn:hover:not(:disabled) {
    background: #5568d3;
}

#queryBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 结果展示区 */
.results-section {
    margin-bottom: 30px;
}

.results-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.params-box {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.params-box h3 {
    margin-bottom: 10px;
    color: #667eea;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.re-ranked-badge {
    background: #4caf50;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
}

/* Stage0: 意图理解显示 */
.intent-box {
    background: #fff3e0;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #ff9800;
}

.intent-box h3 {
    margin-bottom: 15px;
    color: #ff9800;
}

.intent-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.intent-item {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #ffe0b2;
}

.intent-item strong {
    color: #ff6f00;
    display: block;
}

/* Stage4: 迭代历史样式 */
.iteration-history-box {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #4caf50;
}

.iteration-history-box h3 {
    margin-bottom: 15px;
    color: #2e7d32;
}

.iteration-rounds {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.iteration-round {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #c8e6c9;
}

.iteration-round h4 {
    color: #2e7d32;
    margin-bottom: 8px;
}

.round-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.round-stats span {
    background: #f1f8e9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #558b2f;
}

/* Stage4: 迭代控制和信息样式 */
.iteration-controls {
    margin-top: 20px;
    text-align: center;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

#nextIterationBtn {
    padding: 12px 30px;
    font-size: 16px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

#nextIterationBtn:hover {
    background: #45a049;
}

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

.iteration-info {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2196f3;
}

.iteration-progress {
    display: flex;
    gap: 15px;
    align-items: center;
}

.final-badge {
    background: #4caf50;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
}

.intent-item ul {
    margin-left: 20px;
    margin-top: 8px;
}

.intent-item li {
    margin-bottom: 5px;
    color: #555;
}

/* 偏好模式列表样式 */
.pattern-list {
    list-style: none;
    margin-left: 0;
    padding-left: 0;
}

.pattern-list li {
    background: #fff9e6;
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 3px solid #ff9800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pattern-badge {
    background: #ff9800;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.vector-info {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.9em;
}

.vector-info span {
    color: #666;
}

.patterns-box, .rules-box {
    margin-bottom: 20px;
}

.patterns-box h3, .rules-box h3 {
    margin-bottom: 15px;
    color: #333;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

thead {
    background: #667eea;
    color: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f5f5f5;
}

code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.similarity {
    color: #ff9800;
    font-weight: bold;
}

.btn-like, .btn-dislike {
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin: 0 2px;
    transition: transform 0.2s;
}

.btn-like:hover {
    background: #4caf50;
    transform: scale(1.1);
}

.btn-dislike:hover {
    background: #f44336;
    transform: scale(1.1);
}

.explanation-box {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

.explanation-box h3 {
    margin-bottom: 10px;
    color: #1976d2;
}

.explanation-section-title {
    display: inline-block;
    margin: 12px 0 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #d9ecff;
    color: #0d5ea8;
    font-size: 16px;
    font-weight: 700;
}

.explanation-box p {
    margin: 0 0 12px;
    line-height: 1.7;
    color: #1f2937;
}

/* 训练控制区 */
.training-section {
    margin-bottom: 30px;
}

.training-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.training-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

#trainBtn, #loadHistoryBtn {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

#trainBtn {
    background: #4caf50;
    color: white;
}

#trainBtn:hover:not(:disabled) {
    background: #45a049;
}

#trainBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#loadHistoryBtn {
    background: #2196f3;
    color: white;
}

#loadHistoryBtn:hover {
    background: #1976d2;
}

.chart-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chart-box h3 {
    margin-bottom: 15px;
    color: #333;
}

#lossChart {
    max-height: 400px;
}

/* 状态消息 */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    min-width: 200px;
    max-width: 400px;
}

.status-message.success {
    background: #4caf50;
    color: white;
}

.status-message.error {
    background: #f44336;
    color: white;
}

.status-message.info {
    background: #2196f3;
    color: white;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .query-box {
        flex-direction: column;
    }
    
    .params-grid {
        grid-template-columns: 1fr;
    }
    
    .training-controls {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 0.9em;
    }
}

