/* ========== 基金计算器全局样式 ========== */
/* 说明：此文件在 tailwind.min.css 之后加载，用于补充交互态、
   明暗主题覆盖与微交互动画。深色模式通过 html.dark 生效。 */

:root {
    --page-bg: #f9fafb;          /* body 背景（灰-50） */
    --card-bg: #ffffff;
    --line-accent: #f59e0b;      /* 品牌点缀色 */
    --brand-strong: #1e3a8a;
    --brand-main: #2563eb;
    color-scheme: light;
}

html.dark {
    color-scheme: dark;
    --page-bg: #0b1220;
    --card-bg: #111a2c;
    --line-accent: #fbbf24;
    --brand-strong: #172554;
    --brand-main: #1d4ed8;
}

/* ---------- 中文字体栈（跨端统一观感） ---------- */
html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Helvetica Neue", Arial, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

html.dark body {
    background-color: #0b1220;
}

/* ---------- 头部渐变与点缀 ---------- */
.site-header {
    background-image: linear-gradient(135deg, var(--brand-strong) 0%, var(--brand-main) 60%, #3b82f6 130%);
    position: relative;
    box-shadow: 0 4px 18px rgba(30, 58, 138, .18);
}
.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--line-accent) 30%, #f59e0b 70%, transparent);
    opacity: .85;
    pointer-events: none;
}
.hdr-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* 主题切换按钮 */
.theme-toggle {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .32);
    color: #fff;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .28); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.theme-toggle svg { width: 20px; height: 20px; display: none; }
.theme-toggle .icon-moon { display: block; }
html.dark .theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }

/* ---------- 表单控件焦点反馈 ---------- */
#inputPanel input:focus,
#inputPanel select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
    background-color: #fff;
}
html.dark #inputPanel input:focus,
html.dark #inputPanel select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .18);
    background-color: #0d1526;
}

/* 键盘可达性：按钮/可点元素焦点环 */
button:focus-visible,
summary:focus-visible,
a:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
html.dark button:focus-visible,
html.dark summary:focus-visible,
html.dark a:focus-visible { outline-color: #93c5fd; }

/* 数字输入框：保留去箭头 */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* ---------- 计算器标签栏：单行横向滚动 ---------- */
.tabs-shell { position: relative; }
.tabs-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 22px 12px;
    scrollbar-width: none;         /* Firefox */
    -ms-overflow-style: none;      /* IE/Edge */
    -webkit-overflow-scrolling: touch;
}
.tabs-scroll::-webkit-scrollbar { display: none; height: 0; }

/* 左右渐隐遮罩 */
.tabs-shell::before,
.tabs-shell::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 12px;
    width: 24px;
    z-index: 1;
    pointer-events: none;
}
.tabs-shell::before {
    left: 0;
    background: linear-gradient(to right, var(--page-bg), transparent);
}
.tabs-shell::after {
    right: 0;
    background: linear-gradient(to left, var(--page-bg), transparent);
}

.calc-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    transition: background-color .2s ease, color .2s ease,
                transform .15s ease, border-color .2s ease;
    position: relative;
    z-index: 0;
}
.calc-tab:hover { transform: translateY(-1px); }
.calc-tab:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }

/* 激活态标签 */
.tab-active {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ---------- 卡片 ---------- */
.card-shadow {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
html.dark .card-shadow { box-shadow: 0 4px 18px rgba(0, 0, 0, .45); }

/* ---------- 测算结果装饰 ---------- */
#resultPanel .p-3 {
    line-height: 1.5;
}
#resultPanel strong {
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
    padding: 1px 0;
}
/* 数字统一等宽数字，避免重算跳动 */
.res-val {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -0.2px;
}
.res-unit { font-weight: 500; opacity: .85; }
/* 主结果数字：放大 + 语义配色 */
.res-val.main {
    font-size: 1.45em;
    line-height: 1.15;
    font-weight: 800;
}
.res-val.main.gain { color: #059669; }
.res-val.main.neg  { color: #dc2626; }
html.dark .res-val.main.gain { color: #34d399; }
html.dark .res-val.main.neg  { color: #f87171; }

/* 结果更新时的一次性高亮呼吸 */
#resultPanel.result-updated { animation: resultPulse .65s ease-out; }
@keyframes resultPulse {
    0%   { background-color: rgba(59, 130, 246, .16); }
    100% { background-color: transparent; }
}

/* ---------- 输入错误现场提示 ---------- */
.field-invalid input,
.field-invalid select {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .14);
}
html.dark .field-invalid input,
html.dark .field-invalid select { border-color: #f87171; }
.field-error {
    display: none;
    margin-top: 4px;
    font-size: 12px;
    color: #dc2626;
}
html.dark .field-error { color: #f87171; }

/* ---------- 深色模式：覆盖用到的工具类颜色 ---------- */
html.dark .bg-white { background-color: #111a2c; }
html.dark .bg-gray-100 { background-color: #1c2740; }
html.dark .bg-gray-50  { background-color: var(--page-bg); }
html.dark .bg-gray-800 { background-color: #0a0f1a; }
html.dark .text-gray-800 { color: #e6ebf3; }
html.dark .text-gray-700 { color: #d2d9e4; }
html.dark .text-gray-600 { color: #a5b0c0; }
html.dark .text-gray-400 { color: #7c8ba0; }
html.dark .text-gray-300 { color: #b9c4d1; }
html.dark .text-blue-600  { color: #93c5fd; }
html.dark .text-blue-100  { color: #dbeafe; }
html.dark .text-blue-700  { color: #a7c8ff; }
html.dark .text-red-500   { color: #f87171; }
html.dark .border-gray-200,
html.dark .border-gray-300 { border-color: #2b3a55; }

/* 结果色块在深色下的柔和玻璃感 */
html.dark .bg-blue-50   { background-color: rgba(37, 99, 235, .18); }
html.dark .bg-green-50  { background-color: rgba(16, 185, 129, .18); }
html.dark .bg-red-50    { background-color: rgba(239, 68, 68, .18); }
html.dark .bg-orange-50 { background-color: rgba(245, 158, 11, .18); }

/* 表单控件深色化 */
html.dark #inputPanel input,
html.dark #inputPanel select {
    background-color: #0d1526;
    color: #e2e8f0;
    border-color: #2b3a55;
}
html.dark #inputPanel input::placeholder { color: #64748b; }
html.dark #inputPanel select option { background-color: #0d1526; color: #e2e8f0; }
html.dark #inputPanel input:disabled,
html.dark #inputPanel input:disabled { background-color: #1c2740; color: #64748b; }

html.dark .hover\:bg-gray-200:hover { background-color: #28344f; }

/* ---------- 动效尊重系统减弱动态设置 ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    #resultPanel.result-updated { animation: none !important; }
}
