/* 变量定义 - 暖色系 */
:root {
    --primary-color: #D84315; /* 红棕色 */
    --secondary-color: #FF8F00; /* 琥珀色 */
    --accent-color: #FF6F00; /* 橙黄色 */
    --bg-color: #FFFAF0; /* 暖白/浅米色 */
    --text-color: #4E342E; /* 深咖啡色 */
    --highlight-bg: #FFF3E0;
    --border-color: #FFE0B2;
    --header-bg: #FFF3E0;
    --white: #FFFFFF;
}

body {
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.5;
    font-size: 16px;
    color: var(--text-color);
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    color: var(--primary-color);
    font-size: 2.2em;
    margin-bottom: 8px;
    margin-top: 0;
}

.header .subtitle {
    color: #8d6e63;
    font-size: 1.1em;
    margin: 0;
}

/* 返回按钮 */
.back-btn {
    display: inline-block;
    margin-bottom: 20px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #ffb300, #ff8f00);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.back-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 140, 0, 0.3);
}

/* 导航栏 */
.navigation {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.nav-btn {
    padding: 10px 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

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

/* 布局 */
.main-layout {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 25px;
    align-items: stretch;
}

body.ai-sidebar-open .main-layout {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 16px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

    .input-panel-sticky-wrapper {
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
        margin-bottom: 25px;
    }

    .results-container {
        height: 600px;
        max-height: none;
        min-height: 0;
    }
}

/* 输入面板 */
.input-panel {
    background: var(--white);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-top: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.panel-section {
    margin-bottom: 18px;
}

.panel-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.1em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.hint-text {
    font-size: 0.8em;
    color: rgba(78, 52, 46, 0.6);
    margin-top: -10px;
    margin-bottom: 10px;
    font-style: italic;
}

.hint-text sub {
    font-size: 0.7em;
}

.input-inline {
    display: flex;
    gap: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.input-group label {
    font-size: 0.95em;
    font-weight: bold;
}

.input-group input, .input-group select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    background: white;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(255, 143, 0, 0.1);
}

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

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* 系数表格 */
#coeff-table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.input-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.input-table th, .input-table td {
    padding: 4px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.input-table th {
    background-color: var(--highlight-bg);
}

.input-table input {
    width: 50px;
    padding: 4px;
    border: none;
    text-align: center;
    outline: none;
    background: transparent;
}

.input-table input:focus {
    background-color: #fff9c4;
}

/* 操作按钮 */
.panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.panel-actions #solve-btn {
    grid-column: span 2;
    margin-top: 5px;
}

.action-btn {
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

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

.action-btn.primary:hover {
    background-color: #BF360C;
    box-shadow: 0 4px 8px rgba(216, 67, 21, 0.3);
}

.action-btn.secondary {
    background-color: var(--highlight-bg);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.action-btn.secondary:hover {
    background-color: var(--border-color);
}

/* 结果区域 */
.result-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 20px;
    min-height: 0;
}

.experiment-data-panel {
    background: var(--white);
    border-radius: 15px;
    padding: 18px 20px;
    border-top: 5px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.experiment-data-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.02em;
}

.experiment-data-header p {
    margin: 6px 0 0;
    color: #8d6e63;
    font-size: 0.85em;
}

.experiment-data-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
}

.experiment-data-actions .action-btn {
    width: 100%;
}

.results-container {
    box-sizing: border-box;
    background: var(--white);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    min-height: 400px;
    flex: 1;
    overflow-y: auto;
}

#simplex-iteration-cards {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#simplex-iteration-cards.is-empty {
    height: 100%;
    overflow: hidden;
    padding: 0;
}

#simplex-iteration-cards.has-results {
    padding-right: 4px;
}

.viz-container {
    background: linear-gradient(145deg, #fff8ee, #fffdf7);
    padding: 18px;
    border-radius: 12px;
    border: 1px solid #f5dcc1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.placeholder-text {
    width: 100%;
    min-height: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    color: #9E9E9E;
    font-style: italic;
    border: 2px dashed #f3d5b3;
    border-radius: 12px;
    background: linear-gradient(145deg, #fffdf9, #fff7eb);
}

/* 迭代卡片 */
.iteration-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    background-color: white;
    transition: transform 0.2s;
}

.iteration-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.iteration-card h4 {
    margin-top: 0;
    color: var(--primary-color);
    border-left: 4px solid var(--secondary-color);
    padding-left: 10px;
    margin-bottom: 15px;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.explanation {
    font-size: 0.95em;
    color: #5D4037;
    background: var(--highlight-bg);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}

.alert {
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-weight: bold;
}

.alert-warning {
    background-color: #FFFDE7;
    color: #F57F17;
    border: 1px solid #FFF9C4;
}

.alert-danger {
    background-color: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.alert-success {
    background-color: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

/* SVG 样式 */
.simplex-svg text {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

/* 可视化 */
.viz-container {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-top: 25px;
}

.viz-container h3 {
    margin-top: 0;
    color: var(--primary-color);
}

#lp-viz {
    width: 100%;
    height: 400px;
}

.hidden {
    display: none;
}

.simplex-log-modal {
    position: fixed;
    inset: 0;
    background: rgba(65, 40, 20, 0.34);
    backdrop-filter: blur(2px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.simplex-log-modal.hidden {
    display: none;
}

.simplex-log-card {
    width: min(1050px, 96vw);
    max-height: 84vh;
    background: #fffdf7;
    border-radius: 14px;
    border: 1px solid #f3ddc2;
    box-shadow: 0 20px 40px rgba(107, 66, 38, 0.22);
    display: flex;
    flex-direction: column;
}

.simplex-log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #f1dfc8;
}

.simplex-log-head h3 {
    margin: 0;
    color: #b74a22;
}

.simplex-log-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: #ffe7cf;
    color: #8d4b2b;
    font-size: 24px;
    cursor: pointer;
}

.simplex-log-summary {
    padding: 12px 18px 4px;
    color: #7a5d4f;
    font-size: 13px;
    line-height: 1.6;
}

.simplex-log-table-wrap {
    padding: 8px 18px 18px;
    overflow: auto;
}

.simplex-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.simplex-log-table th,
.simplex-log-table td {
    border-bottom: 1px solid #f0e0cb;
    padding: 8px 6px;
    text-align: left;
}

.simplex-log-table th {
    position: sticky;
    top: 0;
    background: #fff4e6;
    z-index: 1;
}

.simplex-expand-btn {
    border: 1px solid #e4c7a3;
    background: #fff7ea;
    color: #8a4d2f;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.simplex-expand-btn:hover {
    background: #ffeacc;
}

.simplex-tableau-wrap {
    overflow: auto;
    border: 1px solid #f0ddc5;
    border-radius: 8px;
    background: #fffaf1;
}

.simplex-tableau-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12px;
    white-space: nowrap;
}

.simplex-tableau-table th,
.simplex-tableau-table td {
    border-bottom: 1px solid #f0e0cb;
    padding: 6px 8px;
    text-align: right;
}

.simplex-tableau-table th:nth-child(1),
.simplex-tableau-table td:nth-child(1),
.simplex-tableau-table th:nth-child(2),
.simplex-tableau-table td:nth-child(2) {
    text-align: center;
}

.simplex-tableau-table thead th {
    background: #fff3e2;
    position: sticky;
    top: 0;
}

.simplex-tableau-table .sigma-row td {
    background: #fff7ec;
    font-weight: 600;
}

.simplex-tableau-empty {
    padding: 12px;
    color: #9d7c66;
}

@media (max-width: 880px) {
    .experiment-data-actions {
        grid-template-columns: 1fr;
    }
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: #a1887f;
    font-size: 14px;
}

/* ===== 二维可视化样式 ===== */

#lp-viz {
    width: 100%;
    height: 600px;
    position: relative;
}

/* 网格线 */
.grid-line {
    stroke: #D2B48C;
    stroke-width: 0.5;
}

/* 约束线样式 */
.constraint-line {
    cursor: pointer;
    transition: stroke-width 0.2s;
}

.constraint-line:hover {
    stroke-width: 2.5 !important;
}

/* 可行域填充 */
.feasible-region-single {
    fill: rgba(255, 140, 0, 0.3);
}

.feasible-region-final {
    fill: rgba(139, 0, 0, 0.3);
}

/* 可行域退化为点 */
.feasible-region-point {
    fill: rgba(139, 0, 0, 0.8);
    stroke: #8B0000;
    stroke-width: 2;
}

/* 可行域退化为线段 */
.feasible-region-line {
    stroke: rgba(139, 0, 0, 0.8);
    stroke-width: 3;
    stroke-linecap: round;
}

/* 目标函数线 */
.objective-line {
    stroke: #228B22;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    cursor: pointer;
}

.objective-line:hover {
    stroke-width: 3;
}

/* 浮动信息面板 */
.info-panel-float {
    position: fixed;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    overflow: hidden;
}

.info-panel-float.visible {
    opacity: 1;
    transform: translateY(0);
}

.float-panel-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-weight: bold;
    font-size: 14px;
}

.panel-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
}

.panel-body {
    padding: 20px;
}

.equation {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-color);
}

.details {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
}

.details-item {
    margin-bottom: 8px;
    padding-left: 8px;
    border-left: 2px solid #ddd;
}

.optimal-value {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 14px;
}

.intercept-info {
    color: #666;
    font-size: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.viz-caption {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

.all-slack-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #666;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 8px;
    border: 2px dashed #ccc;
}

/* 约束数量限制警告 */
.constraint-limit-warning {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: fadeOut 3s forwards;
    animation-delay: 2s;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* 迭代路径样式 */
.iteration-path {
    fill: none;
    stroke: var(--accent-color);
    stroke-width: 2;
}

.iteration-dot {
    cursor: pointer;
    transition: r 0.2s;
}

.iteration-dot:hover {
    r: 7px;
}

/* 坐标轴 */
.axis-line {
    stroke: #333;
    stroke-width: 1.5;
}

.axis-text {
    font-size: 14px;
    fill: #666;
}
