/* 交叉熵损失可视化样式 */

/* 全局容器 */
.ce-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #ffffff;
    color: #1F2937;
    line-height: 1.6;
}

/* 标题区域 */
.ce-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ce-header h1 {
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.ce-header .subtitle {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.95;
}

/* 标签页 */
.tab-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-button {
    flex: 1;
    min-width: 150px;
    padding: 12px 20px;
    background: #F3F4F6;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #4B5563;
}

.tab-button:hover {
    background: #E5E7EB;
    border-color: #D1D5DB;
}

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

/* 标签页内容 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 公式区域 */
.formula-section {
    background: #F9FAFB;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.formula-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

.formula-display {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    font-size: 1.3rem;
    overflow-x: auto;
}

.formula-display.small {
    padding: 15px;
    font-size: 1.1rem;
}

.formula-explanation {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.explanation-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.color-dot.y-true { background: #3B82F6; }
.color-dot.y-pred { background: #10B981; }
.color-dot.class-true { background: #8B5CF6; }
.color-dot.class-pred { background: #F59E0B; }

/* 控制区域 */
.controls-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.controls-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #374151;
}

.value-display {
    background: #F3F4F6;
    padding: 4px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #1F2937;
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 10px;
}

.label-button,
.class-button {
    flex: 1;
    padding: 12px 20px;
    background: #F3F4F6;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #4B5563;
}

.label-button:hover,
.class-button:hover {
    background: #E5E7EB;
    border-color: #D1D5DB;
}

.label-button.active,
.class-button.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* 滑块 */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #E5E7EB;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #6B7280;
}

/* 结果面板 */
.result-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.result-card {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #E5E7EB;
}

.result-card h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #6B7280;
    font-weight: 500;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1F2937;
    font-family: 'Courier New', monospace;
}

/* 解释面板 */
.explanation-panel {
    background: #EFF6FF;
    border-left: 4px solid #3B82F6;
    padding: 15px 20px;
    border-radius: 8px;
}

.explanation-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.explanation-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.explanation-content.correct-prediction {
    background: #D1FAE5;
    border-left-color: #10B981;
}

.explanation-content.correct-prediction .explanation-icon {
    background: #10B981;
    color: white;
}

.explanation-content.wrong-prediction {
    background: #FEE2E2;
    border-left-color: #EF4444;
}

.explanation-content.wrong-prediction .explanation-icon {
    background: #EF4444;
    color: white;
}

/* 图表区域 */
.chart-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.chart-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 20px;
}

.chart-container.large {
    height: 500px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-line {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

.legend-point {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Softmax演示 */
.softmax-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.logits-panel,
.softmax-output {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

.logits-panel h4,
.softmax-output h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #1F2937;
}

.logit-inputs {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logit-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logit-input label {
    font-size: 0.9rem;
    color: #4B5563;
    font-weight: 500;
}

.logit-input .slider {
    flex: 1;
}

.logit-value {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #1F2937;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #E5E7EB;
}

/* 概率条 */
.probability-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.prob-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prob-label {
    min-width: 80px;
    font-weight: 500;
    color: #374151;
}

.prob-bar-wrapper {
    flex: 1;
    height: 40px;
    background: #F3F4F6;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.prob-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    transition: width 0.3s ease;
}

.prob-bar.class-0 { background: linear-gradient(90deg, #667eea, #764ba2); }
.prob-bar.class-1 { background: linear-gradient(90deg, #F59E0B, #EF4444); }
.prob-bar.class-2 { background: linear-gradient(90deg, #10B981, #059669); }

/* 真实类别选择 */
.true-class-selection {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    margin-bottom: 20px;
}

.true-class-selection h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #1F2937;
}

.class-buttons {
    display: flex;
    gap: 10px;
}

/* Softmax公式 */
.softmax-formula {
    background: #EFF6FF;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #DBEAFE;
    margin-top: 20px;
}

.softmax-formula h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #1E40AF;
}

/* 关键洞察 */
.insights-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.insights-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.insight-card {
    background: #F9FAFB;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.insight-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: #1F2937;
}

.insight-card p {
    margin: 0;
    font-size: 0.95rem;
    color: #6B7280;
    line-height: 1.6;
}

/* 对比结果 */
.comparison-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.comparison-card {
    padding: 25px;
    border-radius: 8px;
    text-align: center;
}

.comparison-card h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: white;
}

.comparison-card.ce-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.comparison-card.mse-card {
    background: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);
}

.comparison-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    font-family: 'Courier New', monospace;
    margin-bottom: 10px;
}

.comparison-gradient {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

/* 对比表格 */
.comparison-table-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.comparison-table-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

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

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

.comparison-table th,
.comparison-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

.comparison-table th {
    background: #F9FAFB;
    font-weight: 600;
    color: #1F2937;
}

.comparison-table td.advantage {
    background: #D1FAE5;
    color: #065F46;
}

.comparison-table td.disadvantage {
    background: #FEE2E2;
    color: #991B1B;
}

.comparison-table td.neutral {
    background: #F3F4F6;
    color: #4B5563;
}

/* 理论背景 */
.theory-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #E5E7EB;
}

.theory-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #1F2937;
}

.theory-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.theory-item h4 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: #1F2937;
}

.theory-item p {
    margin: 0;
    color: #6B7280;
    line-height: 1.7;
}

/* 实用技巧 */
.education-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 12px;
    color: white;
}

.education-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
}

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

.tip-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tip-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

.tip-card p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.95;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ce-header h1 {
        font-size: 1.8rem;
    }

    .ce-header .subtitle {
        font-size: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 300px;
    }

    .result-panel {
        grid-template-columns: 1fr;
    }

    .insight-grid {
        grid-template-columns: 1fr;
    }

    .comparison-results {
        grid-template-columns: 1fr;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }

    .tab-button {
        min-width: 100px;
        font-size: 0.9rem;
    }
}

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

.tab-content {
    animation: fadeIn 0.3s ease;
}

.result-card,
.insight-card,
.tip-card {
    animation: fadeIn 0.3s ease;
}
