/* ======================================================================
 *  通用计算器样式 /calc-common.css
 *  适用于「生活实用计算」「健康运动」等一批本地计算类工具，
 *  与 /tool/bmi-calc 视觉规范保持一致：
 *  依赖 home.css 全局变量 + tool-detail.css 公共类，支持黑夜模式。
 * ====================================================================== */

[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.calc-layout {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}
.calc-layout--wide { grid-template-columns: minmax(0, 1fr); }
.calc-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}
.calc-card + .calc-card { margin-top: 20px; }
.calc-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}
.calc-subtitle {
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-sub);
    margin: 18px 0 10px;
}

/* ---------- 表单 ---------- */
.calc-field { margin-bottom: 14px; min-width: 0; }
.calc-field > label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-sub);
    margin-bottom: 7px;
}
.calc-grid2, .calc-grid3 {
    display: grid;
    gap: 12px;
}
.calc-grid2 { grid-template-columns: 1fr 1fr; }
.calc-grid3 { grid-template-columns: repeat(3, 1fr); }
.calc-input-wrap { position: relative; display: flex; align-items: center; }
.calc-input {
    width: 100%;
    height: 43px;
    padding: 0 52px 0 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
    -moz-appearance: textfield;
}
.calc-input::-webkit-outer-spin-button,
.calc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.calc-input--plain { padding-right: 14px; }
.calc-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 36px;
    font-size: 13.5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a8' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}
.calc-suffix {
    position: absolute;
    right: 14px;
    font-size: 12px;
    color: var(--c-text-muted);
    pointer-events: none;
    white-space: nowrap;
}
.calc-help {
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--c-text-muted);
    margin-top: 6px;
}
.calc-help b { color: var(--c-text-sub); }

/* 分段按钮 */
.calc-seg {
    display: grid;
    gap: 8px;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
}
.calc-seg-btn {
    height: 43px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    color: var(--c-text-sub);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
    padding: 0 8px;
    white-space: nowrap;
}
.calc-seg-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.calc-seg-btn.active {
    background: linear-gradient(135deg, rgba(0, 150, 220, 0.16), rgba(0, 150, 220, 0.08));
    border-color: rgba(0, 150, 220, 0.55);
    color: #0a7fc0;
}

/* 复选 */
.calc-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--c-text-sub);
    padding: 9px 0;
    cursor: pointer;
}
.calc-check input {
    width: 17px;
    height: 17px;
    accent-color: var(--c-primary);
    cursor: pointer;
    flex: none;
}

/* 按钮 */
.btn-block { width: 100%; margin-top: 8px; }

/* 主操作按钮：工具页（如网速测速的「开始测速」）不一定加载 home.css，这里补一份同风格定义 */
.btn-primary {
    background: var(--c-primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(0, 102, 255, 0.32);
}
.btn-primary:hover {
    background: var(--c-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(0, 102, 255, 0.42);
}
.btn-primary:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- 结果区 ---------- */
.calc-result-card { min-height: 340px; }
.calc-result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 320px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 13.5px;
    line-height: 1.8;
}
.calc-result-empty .emoji { font-size: 46px; opacity: 0.75; }
.calc-result-body { animation: calcFade 0.28s ease; }
@keyframes calcFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* 主数值 */
.calc-hero {
    padding: 20px 24px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0, 150, 220, 0.12), rgba(0, 168, 168, 0.08));
    border: 1px solid rgba(0, 150, 220, 0.28);
    margin-bottom: 14px;
    text-align: center;
}
.calc-hero-label { font-size: 12.5px; color: var(--c-text-sub); margin-bottom: 4px; }
.calc-hero-num {
    line-height: 1.15;
    color: #0a7fc0;
    font-size: 38px;
    font-weight: 800;
    letter-spacing: -0.03em;
    word-break: break-all;
}
.calc-hero-num small { font-size: 16px; font-weight: 700; margin-left: 4px; }
.calc-hero-sub {
    margin-top: 6px;
    font-size: 13px;
    color: var(--c-text-sub);
}
.calc-hero-cat {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 14px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 800;
}

/* 多列数值卡 */
.calc-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.calc-metric {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    text-align: center;
}
.calc-metric .k { display: block; font-size: 11.5px; color: var(--c-text-muted); margin-bottom: 4px; }
.calc-metric .v { font-size: 17px; font-weight: 800; color: var(--c-text); word-break: break-all; }
.calc-metric .v small { font-size: 11.5px; font-weight: 600; color: var(--c-text-muted); }
.calc-metric.is-hl { background: rgba(0, 150, 220, 0.09); border-color: rgba(0, 150, 220, 0.3); }
.calc-metric.is-hl .v { color: #0a7fc0; }

/* 明细清单 */
.calc-bill {
    list-style: none;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}
.calc-bill li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--c-border);
}
.calc-bill li:last-child { border-bottom: none; }
.calc-bill .k { color: var(--c-text-sub); }
.calc-bill .v { font-weight: 700; color: var(--c-text); text-align: right; }
.calc-bill li.total { background: var(--c-surface-soft); }
.calc-bill li.total .v { color: #0a7fc0; font-size: 14.5px; }
.calc-bill li.total .v small { font-size: 11.5px; font-weight: 600; color: var(--c-text-muted); }

/* ============ 实时进度条 ============ */
.calc-progress {
    margin: 16px 0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--c-text-sub);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    display: flex; align-items: center; gap: 8px;
}
.calc-progress::before {
    content: '⏳';
    flex-shrink: 0;
    font-size: 15px;
    animation: spinicon 1.5s linear infinite;
    display: inline-block;
}
@keyframes spinicon {
    0%   { transform: rotate(-8deg); }
    50%  { transform: rotate(8deg); }
    100% { transform: rotate(-8deg); }
}
[data-theme="dark"] .calc-progress {
    background: rgba(59,130,246,0.12);
    border-color: rgba(59,130,246,0.3);
    color: #93c5fd;
}

/* 条形占比 */
.calc-bars { margin: 4px 0 14px; }
.calc-bar-row { margin-bottom: 10px; }
.calc-bar-head {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--c-text-sub);
    margin-bottom: 5px;
}
.calc-bar-head b { color: var(--c-text); }
.calc-bar-track {
    height: 9px;
    border-radius: 99px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    overflow: hidden;
}
.calc-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }

/* 提示条 */
.calc-note {
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--c-text-sub);
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(0, 150, 220, 0.07);
    border: 1px dashed rgba(0, 150, 220, 0.32);
}
.calc-note + .calc-note { margin-top: 10px; }
.calc-note b { color: var(--c-text); }
.calc-note--warn {
    background: rgba(224, 68, 124, 0.07);
    border-color: rgba(224, 68, 124, 0.32);
}
.calc-note--ok {
    background: rgba(52, 199, 89, 0.08);
    border-color: rgba(52, 199, 89, 0.35);
}
.calc-ok { color: #1f9d43; }
.calc-warn { color: #e0447c; }
/* 与 --warn 等价的简写（部分工具用 is-warn） */
.calc-note.is-warn {
    background: rgba(224, 68, 124, 0.07);
    border-color: rgba(224, 68, 124, 0.32);
}
.calc-note.is-ok {
    background: rgba(52, 199, 89, 0.08);
    border-color: rgba(52, 199, 89, 0.35);
}

/* ---------- 表格 ---------- */
.calc-table-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
}
.calc-table-head { margin-bottom: 14px; }
.calc-table-head .calc-title { margin-bottom: 4px; }
.calc-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}
.calc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 520px;
}
.calc-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-text-sub);
    background: var(--c-surface-soft);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.calc-table tbody td {
    padding: 11px 16px;
    color: var(--c-text-sub);
    border-bottom: 1px solid var(--c-border);
    line-height: 1.6;
}
.calc-table tbody tr:last-child td { border-bottom: none; }
.calc-table tbody tr.is-active { background: rgba(0, 150, 220, 0.09); }
.calc-table tbody tr.is-active td { color: var(--c-text); }
.calc-td-num { white-space: nowrap; }
.calc-td-h { white-space: nowrap; }
.calc-td-hl { white-space: nowrap; font-weight: 800; color: #0a7fc0; }

/* ---------- 免责 ---------- */
.calc-disclaim {
    font-size: 12px;
    line-height: 1.85;
    color: var(--c-text-muted);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 26px;
}
.calc-disclaim b { color: var(--c-text-sub); }
.calc-info { margin-bottom: 26px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
    .calc-layout { grid-template-columns: 1fr; }
    .calc-result-card { min-height: auto; }
    .calc-result-empty { min-height: 170px; }
}
@media (max-width: 620px) {
    .calc-card, .calc-table-card { padding: 18px; }
    .calc-hero-num { font-size: 30px; }
    .calc-bill li { flex-direction: column; align-items: flex-start; gap: 4px; }
    .calc-bill .v { text-align: left; }
    .calc-grid3 { grid-template-columns: 1fr 1fr; }
}

/* ============ 黑夜模式 ============ */
[data-theme="dark"] .calc-input,
[data-theme="dark"] .calc-seg-btn { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .calc-input option { background: #131c31; color: #e5e9f0; }
[data-theme="dark"] .calc-hero {
    background: linear-gradient(135deg, rgba(0, 150, 220, 0.18), rgba(0, 168, 168, 0.12));
    border-color: rgba(0, 150, 220, 0.34);
}
[data-theme="dark"] .calc-hero-num { color: #58bdf0; }
[data-theme="dark"] .calc-seg-btn.active { color: #58bdf0; }
[data-theme="dark"] .calc-bill li.total .v,
[data-theme="dark"] .calc-td-hl,
[data-theme="dark"] .calc-metric.is-hl .v { color: #58bdf0; }
[data-theme="dark"] .calc-ok { color: #4ede78; }
[data-theme="dark"] .calc-note {
    background: rgba(0, 150, 220, 0.13);
    border-color: rgba(0, 150, 220, 0.34);
}
[data-theme="dark"] .calc-note.is-warn {
    background: rgba(224, 68, 124, 0.13);
    border-color: rgba(224, 68, 124, 0.34);
}
[data-theme="dark"] .calc-note.is-ok {
    background: rgba(52, 199, 89, 0.13);
    border-color: rgba(52, 199, 89, 0.34);
}
[data-theme="dark"] .calc-note--ok {
    background: rgba(52, 199, 89, 0.13);
    border-color: rgba(52, 199, 89, 0.34);
}
[data-theme="dark"] .calc-note--warn {
    background: rgba(224, 68, 124, 0.13);
    border-color: rgba(224, 68, 124, 0.34);
}
[data-theme="dark"] .calc-bill li.total,
[data-theme="dark"] .calc-table thead th,
[data-theme="dark"] .calc-metric,
[data-theme="dark"] .calc-bar-track,
[data-theme="dark"] .calc-disclaim { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .calc-table tbody tr.is-active,
[data-theme="dark"] .calc-metric.is-hl { background: rgba(0, 150, 220, 0.14); }

/* ---------- 颜色工具（color-convert） ---------- */
.color-preview {
    height: 120px;
    border-radius: 16px;
    border: 1px solid var(--c-border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 14px;
    background: #4F7CFF;
    transition: background 0.2s ease;
}
.color-preview-hex {
    margin-bottom: 12px;
    padding: 4px 14px;
    border-radius: 99px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
}
.color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}
.color-palette button {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    border: 1px solid var(--c-border);
    padding: 0;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.color-palette button:hover { transform: scale(1.08); box-shadow: var(--shadow-sm); }
.color-hero-swatch {
    height: 88px;
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid var(--c-border);
    margin: 6px auto 12px;
    transition: background 0.2s ease;
}
.color-swatch-dot {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    vertical-align: middle;
}
@media (max-width: 620px) {
    .color-palette { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- 颜色工具：配色参考 ---------- */
.color-shades {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.color-shade {
    padding: 0;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--c-surface-soft);
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.16s ease, transform 0.12s ease;
}
.color-shade:hover { border-color: var(--c-primary); transform: translateY(-2px); }
.color-shade i {
    display: block;
    height: 52px;
    border-bottom: 1px solid var(--c-border);
}
.color-shade b {
    display: block;
    padding: 7px 4px 2px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--c-text-sub);
}
.color-shade em {
    display: block;
    padding-bottom: 8px;
    font-size: 10.5px;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--c-text-muted);
}
.color-contrast {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 14px;
}
.color-contrast span {
    padding: 5px 12px;
    border-radius: 99px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--c-text-sub);
}
.color-contrast span b { color: var(--c-text); }

/* 黑夜模式下给浅色/白色色块补一圈内描边，避免与卡片融为一体 */
[data-theme="dark"] .color-shade { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .color-palette button,
[data-theme="dark"] .color-swatch-dot,
[data-theme="dark"] .color-hero-swatch,
[data-theme="dark"] .color-shade i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }

/* ---------- 颜色工具：渐变生成 ---------- */
.color-grad-preview {
    height: 92px;
    border-radius: 14px;
    border: 1px solid var(--c-border);
    margin-bottom: 10px;
}
.color-code {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--c-text-sub);
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 10px;
}
.color-code b { color: var(--c-text); }
[data-theme="dark"] .color-code { background: rgba(255, 255, 255, 0.03); }

/* ---------- AI 顾问卡片（水价等按城市查询类） ---------- */
.wt-ai-row {
    display: flex;
    gap: 10px;
}
.wt-ai-row .calc-input { flex: 1; min-width: 0; }
.wt-ai-btn { flex: none; height: 43px; padding: 0 18px; font-size: 13.5px; white-space: nowrap; }
.wt-ai-status {
    font-size: 12.5px;
    line-height: 1.6;
    margin-top: 8px;
    min-height: 0;
}
.wt-ai-status.is-ok { color: #1f9d43; font-weight: 700; }
.wt-ai-status.is-err { color: #e0447c; font-weight: 700; }
.wt-ai-result {
    margin-top: 10px;
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 150, 220, 0.08), rgba(0, 168, 168, 0.05));
    border: 1px solid rgba(0, 150, 220, 0.25);
}
.wt-ai-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    margin-bottom: 10px;
}
.wt-ai-conf { font-size: 11.5px; font-weight: 700; }
.wt-ai-conf--high { color: #1f9d43; }
.wt-ai-conf--medium { color: #d98a00; }
.wt-ai-conf--low { color: #e0447c; }
.wt-ai-result .calc-bill { margin-bottom: 10px; }
.wt-ai-result .calc-note { margin-bottom: 6px; }
.wt-ai-result .calc-help { margin-top: 0; }
@media (max-width: 620px) {
    .wt-ai-row { flex-direction: column; }
}
[data-theme="dark"] .wt-ai-result {
    background: rgba(0, 150, 220, 0.12);
    border-color: rgba(0, 150, 220, 0.3);
}
[data-theme="dark"] .wt-ai-status.is-ok { color: #4ede78; }
[data-theme="dark"] .wt-ai-status.is-err { color: #ff7ab0; }
[data-theme="dark"] .wt-ai-conf--high { color: #4ede78; }
[data-theme="dark"] .wt-ai-conf--medium { color: #ffb84d; }
[data-theme="dark"] .wt-ai-conf--low { color: #ff7ab0; }

/* ---------- 按钮行（ft-btns，与 file-common.css 同名类补齐共享实现） ---------- */
.ft-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ft-btns .btn { flex: 1 1 30%; min-width: 108px; }
@media (max-width: 620px) {
    .ft-btns .btn { flex: 1 1 100%; }
}
