/* ============================================================
   SOAFT 计算器 - 本目录专属样式
   ------------------------------------------------------------
   仅包含 shared/theme.css 未覆盖的 SOAFT 计算器官方布局：
   表单网格、条件字段、结果/过程框、明细表微调、历史列表、
   toast、淡入动画、主题切换按钮。
   颜色一律来自 theme.css 的 --brand-* 令牌，禁止另写配色。
   ============================================================ */

/* ===== 表单网格 & 字段 ===== */
.calc-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}
.form-label .required { color: var(--brand-danger); margin-left: 2px; }
/* 条件字段默认隐藏，show_when 命中后显示 */
.form-group[data-show-when] { display: none; }
.form-group[data-show-when].visible { display: flex; animation: fadeInUp .3s ease; }

/* ===== 按钮组（卡片内操作行）===== */
.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* ===== 头部主题切换 ===== */
.header-actions { margin-top: var(--space-4); display: flex; justify-content: center; }
#themeToggle i { margin-right: .4rem; }

/* ===== 结果框（结构化键值面板）===== */
.result-box {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-primary);
    border-radius: var(--radius-md);
    min-height: 80px;
    color: var(--text);
    overflow: hidden;
}
.result-box:empty::before { content: '计算结果将在此显示'; display: block; padding: 22px 18px; color: var(--text-muted); font-style: italic; }
.result-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 18px;
    border-bottom: 1px dashed var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-row .rk { color: var(--text-muted); font-weight: 600; font-size: 14px; flex: 0 1 auto; min-width: 0; }
.result-row .rv {
    color: var(--text-strong);
    font-weight: 700;
    font-size: 16px;
    font-family: var(--font-mono);
    text-align: right;
    flex: 0 0 auto;
}
.result-row.is-sub { padding-left: 34px; }
.result-row.is-sub .rk { font-weight: 500; }
.result-row.is-sub .rv { font-size: 15px; }
.result-row.is-warn { background: rgba(246,194,62,.12); }
.result-row.is-warn .rk, .result-row.is-warn .rv { color: #8a6d1a; }
.result-row.is-primary { background: rgba(78,115,223,.07); }
.result-row.is-primary .rk { color: var(--text-strong); font-weight: 700; font-size: 15px; }
.result-row.is-primary .rv { color: var(--brand-primary); font-size: 19px; }
.result-note { padding: 11px 18px; }
.result-note .rv-full { color: var(--text); font-size: 14px; line-height: 1.7; word-break: break-word; }
.result-note.is-warn .rv-full { color: #8a6d1a; }

/* ===== 过程框（步骤日志）===== */
.process-box {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    min-height: 80px;
    max-height: 340px;
    overflow-y: auto;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.85;
    scrollbar-width: thin;
}
.process-box:empty::before { content: '计算过程将在此显示'; display: block; padding: 6px 2px; color: var(--text-muted); font-style: italic; }
.process-line { white-space: pre-wrap; word-break: break-word; padding: 3px 2px; }
.process-line.step { display: flex; gap: 10px; align-items: flex-start; }
.process-line.step .num {
    flex: 0 0 auto;
    min-width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    margin-top: 1px;
}
.process-line.step .content { flex: 1 1 auto; min-width: 0; }
.process-line .res { color: var(--brand-success); font-weight: 700; }
.process-gap { height: 8px; }

/* ===== 明细表微调（在 .table 基础上加深区隔）===== */
.detail-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table thead th {
    background: var(--brand-primary);
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.detail-table tbody tr:nth-child(even) { background: var(--surface-soft); }
.detail-table tbody tr:hover { background: rgba(78,115,223,.08); }
.detail-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.detail-table tbody tr:last-child td { border-bottom: none; }

/* ===== 历史记录列表 ===== */
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--surface);
}
.history-item-main { min-width: 0; }
.history-item-summary { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.history-item-meta { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.history-item-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: var(--transition-base);
}
.icon-btn:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: 80px; right: 24px;
    z-index: 10000;
    display: flex; flex-direction: column; gap: 12px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-card);
    display: flex; align-items: center; gap: 10px;
    font-size: 14px;
    min-width: 260px;
    border-left: 4px solid var(--brand-primary);
    animation: slideInRight .3s ease;
}
.toast.success { border-left-color: var(--brand-success); }
.toast.error { border-left-color: var(--brand-danger); }
.toast.warning { border-left-color: var(--brand-warning); }

/* ===== 动画 ===== */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.fade-in { animation: fadeInUp .4s ease; }

/* ===== 移动端微调 ===== */
@media (max-width: 768px) {
    .calc-form { grid-template-columns: 1fr; }
    .toast-container { right: 16px; left: 16px; }
    .toast { min-width: auto; }
}
