/* MLTutor 算法页面样式 - 明亮丝滑教育风格 */

/* 导航栏 */
.navbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 24px;
    background: var(--bg-card);
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    transition: all var(--duration-normal) var(--ease-out);
}

.back-link:hover {
    background: rgba(59, 130, 246, 0.08);
}

.algo-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 内容布局 */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: -1;
    }
}

/* 主内容 */
.main-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 区块 */
section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.5s var(--ease-out) backwards;
}

section:nth-child(1) { animation-delay: 0.05s; }
section:nth-child(2) { animation-delay: 0.1s; }
section:nth-child(3) { animation-delay: 0.15s; }
section:nth-child(4) { animation-delay: 0.2s; }

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

section h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

/* 简介内容 */
.intro-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.intro-content strong {
    color: var(--text-primary);
}

.intro-content ul {
    margin: 12px 0;
    padding-left: 24px;
}

.intro-content li {
    margin-bottom: 8px;
}

/* 高亮框 */
.highlight-box {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    padding: 18px 20px;
    margin-top: 18px;
}

.highlight-box h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 600;
}

.highlight-box p {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* 可视化控制 - 清新增强 */
.viz-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 14px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.control-group input[type="range"] {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transition: transform var(--duration-fast) var(--ease-out);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.control-group input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--duration-fast);
}

.control-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}

.control-group select {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: border-color var(--duration-fast);
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.value-display {
    min-width: 50px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

/* 可视化容器 - 清新明亮增强 */
.viz-container {
    width: 100%;
    min-height: 400px;
    background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* 数据点微动画 */
.viz-container circle {
    transition: all 0.2s ease;
}

.viz-container circle:hover {
    filter: brightness(1.1);
}

/* SVG 背景 */
.viz-container svg rect:first-child {
    rx: 8;
}

/* 数学内容 */
.math-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.math-content p {
    margin-bottom: 14px;
}

.math-content strong {
    color: var(--primary);
}

.math-content ul {
    margin: 10px 0;
    padding-left: 24px;
}

.math-content li {
    margin-bottom: 8px;
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Notebook 卡片 */
.notebook-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.5s var(--ease-out) 0.1s backwards;
}

.notebook-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.notebook-card > p {
    opacity: 0.9;
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.notebook-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.btn {
    display: block;
    text-align: center;
    padding: 12px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--duration-normal) var(--ease-out);
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: white;
    color: var(--primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
}

.notebook-preview {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 16px;
}

.notebook-preview p {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.notebook-features {
    list-style: none;
    padding: 0;
}

.notebook-features li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    font-size: 0.9rem;
    opacity: 0.95;
}

.notebook-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #a5f3fc;
}

/* 快速导航 */
.quick-nav {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.5s var(--ease-out) 0.15s backwards;
}

.quick-nav h3 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1rem;
}

.quick-nav-list {
    list-style: none;
    padding: 0;
}

.quick-nav-list li {
    margin-bottom: 10px;
}

.quick-nav-list a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--duration-fast);
    display: inline-block;
}

.quick-nav-list a:hover {
    color: var(--secondary);
    transform: translateX(4px);
}

/* 等级信息 */
.level-info {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.5s var(--ease-out) 0.2s backwards;
}

.level-info h3 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
    font-size: 1rem;
}

.level-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* 公式渲染 - 清新美化 */
.katex-display {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 20px 24px;
    border-radius: 12px;
    margin: 16px 0;
    overflow-x: auto;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.katex {
    font-size: 1.1em;
    color: var(--text-primary);
}

.katex-display > .katex {
    display: inline-block;
    text-align: center;
    width: 100%;
}

/* 行内公式 */
.katex-inline, p .katex {
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.95em;
}

/* 动态公式（无背景） */
#equation-katex, #mse-katex {
    font-size: 1.05em;
}

#equation-katex .katex, #mse-katex .katex {
    color: var(--primary);
    font-weight: 500;
}

.math-content {
    line-height: 2;
}

/* 响应式 */
@media (max-width: 768px) {
    .viz-controls {
        flex-direction: column;
        padding: 14px 16px;
        gap: 12px;
    }

    .control-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .control-group label {
        min-width: 80px;
    }

    .control-group input[type="range"] {
        flex: 1;
        min-width: 0;
    }

    .control-group select {
        width: 100%;
    }

    .value-display {
        min-width: 44px;
        font-size: 0.8rem;
    }

    .algo-title {
        font-size: 1.3rem;
    }

    .navbar {
        flex-wrap: wrap;
        padding: 14px 16px;
        gap: 12px;
    }

    section {
        padding: 18px 16px;
    }

    .viz-container {
        min-height: 280px;
        padding: 12px;
    }

    .notebook-card {
        padding: 20px;
    }

    .notebook-actions {
        gap: 8px;
    }

    .sidebar {
        gap: 16px;
    }
}

/* ============================================
   深度理解模块
   ============================================ */

.deep-understanding {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.deep-understanding section {
    margin: 0;
}

@media (max-width: 900px) {
    .deep-understanding {
        grid-template-columns: 1fr;
    }
}

/* 信息卡片 */
.info-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.info-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.info-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-light);
}

.info-card .info-content {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.9rem;
}

.info-card .info-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.info-card .info-content li {
    margin-bottom: 8px;
}

.info-card .info-content strong {
    color: var(--text-primary);
}

/* 适用场景 */
.scenario-card::before {
    background: linear-gradient(180deg, #10b981, #059669);
}

.scenario-card h3 {
    color: #059669;
}

/* 历史渊源 */
.history-card::before {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.history-card h3 {
    color: #2563eb;
}

/* 发展脉络 */
.evolution-card::before {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}

.evolution-card {
    grid-column: span 2;
}

.evolution-card h3 {
    color: #d97706;
}

@media (max-width: 900px) {
    .evolution-card {
        grid-column: span 1;
    }
}

/* 时间线 */
.evolution-timeline {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 16px 0;
}

.evolution-timeline .evo-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.evolution-timeline .evo-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fafbfc 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border: 3px solid #f59e0b;
    margin-bottom: 10px;
    transition: all var(--duration-normal) var(--ease-out);
}

.evolution-timeline .evo-node:hover .evo-circle {
    transform: scale(1.12);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.evolution-timeline .evo-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.evolution-timeline .evo-year {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.evolution-timeline .evo-arrow {
    font-size: 22px;
    color: #cbd5e1;
}

.evolution-timeline .evo-reason {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 80px;
    text-align: center;
    line-height: 1.4;
}

/* 局限性 */
.limitation-card::before {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}

.limitation-card h3 {
    color: #dc2626;
}

/* 工业界地位 */
.industry-card::before {
    background: linear-gradient(180deg, #8b5cf6, #7c3aed);
}

.industry-card h3 {
    color: #7c3aed;
}

/* 使用情况标签 */
.industry-usage {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
}

.usage-very-high {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
}

.usage-high {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.usage-medium {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.usage-low {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
}

.usage-historical {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #3730a3;
}

/* 通用 Tooltip */
.viz-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    z-index: 1000;
    transition: opacity 0.15s;
    max-width: 200px;
    line-height: 1.4;
}

/* 提示框样式覆盖 */
.info-card .info-content p[style*="background: #dcfce7"],
.info-card .info-content p[style*="background: #e0e7ff"],
.info-card .info-content p[style*="background: #fef3c7"],
.info-card .info-content p[style*="background: #fee2e2"] {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08)) !important;
    border: 1px solid rgba(59, 130, 246, 0.12);
    border-radius: 8px;
}

/* 操作按钮组 - 统一美化 */
.viz-controls .btn,
.viz-controls button {
    padding: 8px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all var(--duration-normal) var(--ease-out);
}

.viz-controls .btn:hover,
.viz-controls button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.viz-controls .btn:active,
.viz-controls button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* 可视化加载占位 */
.viz-container:empty::after {
    content: '加载可视化中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-light);
    font-size: 0.9rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* 数学公式块 hover 高亮 */
.katex-display:hover {
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}

/* 侧边栏卡片渐入动画增强 */
.sidebar > * {
    animation: fadeInUp 0.5s var(--ease-out) backwards;
}

.sidebar > *:nth-child(1) { animation-delay: 0.05s; }
.sidebar > *:nth-child(2) { animation-delay: 0.1s; }
.sidebar > *:nth-child(3) { animation-delay: 0.15s; }
.sidebar > *:nth-child(4) { animation-delay: 0.2s; }

.evolution-timeline {
    position: relative;
}

.evolution-timeline .evo-node {
    z-index: 1;
}

/* 试一试引导框 */
.try-it-box {
    margin-top: 15px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    font-size: 14px;
    color: var(--text-secondary);
}

.try-it-box strong {
    color: var(--primary);
}

.try-it-box ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    line-height: 1.8;
}

.try-it-box li {
    margin-bottom: 4px;
}

.try-it-box li strong {
    color: var(--text-primary);
}

/* 打印友好 */
@media print {
    body { background: white; }
    section { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .navbar, .sidebar, .viz-controls { display: none; }
    .content-wrapper { grid-template-columns: 1fr; }
}
