/* ============================================================
   Fengvi Tools - Financial Calculators 共享样式
   适用页面：travel-budget.html / emi-calculator.html / money-transfer.html
   依赖：styles/main.css
   ============================================================ */

/* ---- 计算器表单区 ---- */
.calc-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.calc-form .field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calc-form label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.calc-form .input-wrap {
    position: relative;
}

.calc-form .input-wrap input,
.calc-form .input-wrap select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #d9d9d9;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    color: #222;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.calc-form .input-wrap input:focus,
.calc-form .input-wrap select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.calc-form .input-wrap .prefix {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #666;
    pointer-events: none;
}

.calc-form .input-wrap .prefix + input {
    padding-left: 32px;
}

.calc-form .input-wrap .suffix {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: #888;
    pointer-events: none;
}

.calc-form .input-wrap .suffix + input,
.calc-form .input-wrap:has(> .suffix) > input {
    padding-right: 46px;
}

/* 单选组（EMI 还款方式 / 期限单位） */
.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1.5px solid #d9d9d9;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.radio-group label:hover {
    border-color: #1a73e8;
}

.radio-group input[type="radio"] {
    accent-color: #1a73e8;
    width: 15px;
    height: 15px;
    margin: 0;
}

.radio-group label.selected {
    border-color: #1a73e8;
    background: rgba(26, 115, 232, 0.08);
    color: #1a73e8;
    font-weight: 700;
}

.calc-form .field-group.full-width {
    grid-column: 1 / -1;
}

/* 按钮 */
.calc-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.calc-btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    background: #1a73e8;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.calc-btn:hover {
    background: #1557b0;
}

.calc-btn:active {
    transform: scale(0.98);
}

.calc-btn.reset-btn {
    background: #6c757d;
}

.calc-btn.reset-btn:hover {
    background: #545b62;
}

/* ---- 结果区 ---- */
.calc-result {
    display: none;
    background: linear-gradient(135deg, #f0f7ff, #e8f1fb);
    border: 1.5px solid #d3e4f7;
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 24px;
}

.calc-result.show {
    display: block;
    animation: calcFadeIn 0.35s ease;
}

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

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.result-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.result-card .result-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.result-card .result-value {
    font-size: 26px;
    font-weight: 800;
    color: #1a73e8;
    line-height: 1.2;
}

.result-card .result-sub {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.result-card.highlight {
    background: linear-gradient(135deg, #1a73e8, #1557b0);
}

.result-card.highlight .result-label {
    color: rgba(255, 255, 255, 0.8);
}

.result-card.highlight .result-value {
    color: #fff;
}

.result-card.highlight .result-sub {
    color: rgba(255, 255, 255, 0.7);
}

.result-note {
    font-size: 13px;
    color: #666;
    margin-top: 10px;
    line-height: 1.6;
}

.data-source {
    margin-top: 12px;
    font-size: 12.5px;
    color: #888;
}

/* ---- 快速开始预设 + 动态结果提示 ---- */
.calc-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
}

.calc-preset-label {
    font-weight: 600;
    font-size: .85rem;
    color: #4b5563;
    margin-right: 4px;
}

.calc-preset-btn {
    font-size: .8rem;
    padding: .32rem .7rem;
    border-radius: 999px;
}

.calc-result-tip {
    margin: 12px 0 0 0;
    padding: 10px 14px;
    background: #f0f7ff;
    border-left: 4px solid #1a73e8;
    border-radius: 0 6px 6px 0;
    font-size: .9rem;
    color: #1a3d6e;
    line-height: 1.5;
}

.calc-result-tip:empty {
    display: none;
}

/* ---- 对比表格（汇款/还款计划） ---- */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e5e5e5;
    background: #fff;
    margin-bottom: 18px;
}

.calc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 560px;
}

.calc-table th {
    background: #f5f8fc;
    color: #333;
    font-weight: 700;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 2px solid #e5e5e5;
    white-space: nowrap;
}

.calc-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.calc-table tbody tr:last-child td {
    border-bottom: none;
}

.calc-table tbody tr:hover {
    background: #f8fbff;
}

.calc-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.calc-table .best-row td {
    background: #eaf6ea;
    font-weight: 700;
}

.best-badge {
    display: inline-block;
    background: #22c55e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ---- 进度条（还款本金/利息构成） ---- */
.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13.5px;
}

.bar-row .bar-label {
    flex: 0 0 130px;
    color: #555;
    font-weight: 600;
}

.bar-row .bar-track {
    flex: 1;
    height: 12px;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.bar-row .bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
}

.bar-row .bar-value {
    flex: 0 0 110px;
    text-align: right;
    color: #333;
    font-variant-numeric: tabular-nums;
}

/* ---- 状态提示 ---- */
.status-banner {
    display: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.status-banner.show {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.status-banner.warning {
    background: #fff8e6;
    border: 1px solid #f5d78e;
    color: #8a6d1a;
}

.status-banner.error {
    background: #fdecec;
    border: 1px solid #f0b4b4;
    color: #a33;
}

.status-banner.success {
    background: #eaf6ea;
    border: 1px solid #b7ddb7;
    color: #2d6a2d;
}

/* ---- 桌面端结果数值放大 ---- */
@media (min-width: 769px) {
    .result-card .result-value {
        font-size: 36px;
    }
}

/* ---- 贷款构成环形图 ---- */
.breakdown-donut {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.breakdown-donut .donut-title {
    flex: 0 0 100%;
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: #333;
}

.donut-chart {
    position: relative;
    width: 132px;
    height: 132px;
    flex: 0 0 132px;
}

.donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-svg .donut-ring {
    fill: none;
    stroke: #eef1f5;
    stroke-width: 7;
}

.donut-svg .donut-segment {
    fill: none;
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease, stroke-dashoffset 0.5s ease;
}

.donut-svg .donut-segment.interest {
    stroke: #ff8a3d;
}

.donut-svg .donut-segment.principal {
    stroke: #1a73e8;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.donut-center .donut-center-label {
    font-size: 11px;
    color: #888;
}

.donut-center .donut-center-value {
    font-size: 16px;
    font-weight: 800;
    color: #1a73e8;
}

.donut-legend {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.donut-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: #555;
}

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

.donut-legend .legend-dot.principal {
    background: #1a73e8;
}

.donut-legend .legend-dot.interest {
    background: #ff8a3d;
}

.donut-legend .legend-value {
    margin-left: auto;
    font-weight: 700;
    color: #333;
    font-variant-numeric: tabular-nums;
}

/* ---- 还款方式对比说明 ---- */
.emi-compare {
    margin: 26px 0 30px;
    padding: 22px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.emi-compare .compare-intro {
    font-size: 14px;
    color: #666;
    line-height: 1.7;
    margin: 6px 0 16px;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.compare-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px;
}

.compare-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #1a73e8;
}

.compare-card p {
    font-size: 13.5px;
    color: #555;
    line-height: 1.7;
    margin: 0 0 8px;
}

.compare-card .compare-best {
    margin: 0;
    padding-top: 10px;
    border-top: 1px dashed #d7dee8;
    color: #2d6a2d;
    font-weight: 600;
}

/* ---- 移动端适配 ---- */
@media (max-width: 768px) {
    .calc-form {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .result-card .result-value {
        font-size: 22px;
    }

    .bar-row .bar-label {
        flex-basis: 100px;
    }

    .bar-row .bar-value {
        flex-basis: 88px;
    }

    .calc-btn {
        width: 100%;
        justify-content: center;
    }

    .calc-preset-btn {
        width: auto;
        flex: 0 0 auto;
    }

    .calc-preset-label {
        flex-basis: 100%;
        margin-bottom: -2px;
    }

    .radio-group {
        width: 100%;
    }

    .radio-group label {
        flex: 1;
        justify-content: center;
    }

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

    .breakdown-donut {
        justify-content: center;
    }

    .donut-legend {
        min-width: 0;
        width: 100%;
    }
}

/* ---- EMI：快速情景预设（Quick Scenarios） ---- */
.quick-scenarios {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -4px 0 16px;
}

.quick-scenarios-label {
    font-weight: 700;
    font-size: 13px;
    color: #333;
    margin-right: 6px;
}

.scenario-btn {
    padding: 7px 14px;
    border: 1.5px solid #1a73e8;
    border-radius: 999px;
    background: #fff;
    color: #1a73e8;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.scenario-btn:hover,
.scenario-btn:focus-visible {
    background: #1a73e8;
    color: #fff;
    outline: none;
}

/* ---- EMI：智能解读（结果区） ---- */
.emi-insight {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 8px;
    background: #f0f7ff;
    border-left: 4px solid #1a73e8;
    align-items: flex-start;
}

.emi-insight[hidden] {
    display: none;
}

.emi-insight .insight-icon {
    font-size: 20px;
    line-height: 1.4;
    flex-shrink: 0;
}

.emi-insight .insight-content {
    font-size: 14px;
    line-height: 1.6;
    color: #1a2332;
}

/* ---- 百分比：结果智能解读 ---- */
.percent-insight {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 8px;
    background: #f0f7ff;
    border-left: 4px solid #1a73e8;
    align-items: flex-start;
}

.percent-insight[hidden] {
    display: none;
}

.percent-insight .insight-icon {
    font-size: 20px;
    line-height: 1.4;
    flex-shrink: 0;
}

.percent-insight .insight-content {
    font-size: 14px;
    line-height: 1.6;
    color: #1a2332;
}

/* ---- EMI：利息占比阈值徽章 ---- */
.bar-threshold {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.bar-threshold[hidden] {
    display: none;
}

.bar-threshold[data-level="high"] {
    background: #fde8e8;
    color: #c0392b;
}

.bar-threshold[data-level="medium"] {
    background: #fff3d6;
    color: #b06f00;
}

.bar-threshold[data-level="low"] {
    background: #e6f4e6;
    color: #2d6a2d;
}
