/* ============================================
   Quick Calculator — 便捷计算器
   ============================================ */

/* ── FAB 按钮 ── */
.qc-fab {
    position: fixed;
    bottom: 224px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(102,126,234,0.45);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: qcPulse 4s ease-in-out infinite;
}
.qc-fab::after {
    content: '计算器';
    position: absolute;
    right: 64px;
    top: 50%;
    transform: translateY(-50%) scale(0.85);
    background: var(--text-primary, #1a202c);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
}
.qc-fab:hover {
    animation: none;
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(102,126,234,0.55);
}
.qc-fab:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }
.qc-fab:active { transform: scale(0.94); }
.qc-fab.is-open {
    animation: none;
    transform: rotate(15deg) scale(1.05);
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 6px 20px rgba(185,28,28,0.35);
}
@keyframes qcPulse {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px) scale(1.05); }
}

/* ── 面板容器 ── */
.qc-panel {
    position: fixed;
    bottom: 290px;
    right: 20px;
    width: 400px;
    max-height: 560px;
    background: var(--bg-card, #fff);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}
.qc-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ── 面板头部 ── */
.qc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 6px 12px;
    background: linear-gradient(135deg, rgba(102,126,234,0.08), rgba(118,75,162,0.08));
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}
.qc-panel-tabs { display: flex; gap: 4px; }
.qc-tab {
    padding: 6px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.qc-tab:hover { color: #667eea; background: rgba(102,126,234,0.08); }
.qc-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.qc-tab i { font-size: 14px; }
.qc-panel-close {
    width: 32px; height: 32px;
    border: none; background: none;
    border-radius: 8px; cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary, #64748b);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.qc-panel-close:hover { background: rgba(0,0,0,0.06); color: var(--text-primary); }

/* ── 面板内容区 ── */
.qc-panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.qc-tab-content { display: none; }
.qc-tab-content.active { display: block; }

/* ── 基础计算器：显示屏 ── */
.qc-calc-display {
    background: #1e293b;
    padding: 16px 20px 12px;
    text-align: right;
    min-height: 76px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.qc-expr {
    font-size: 0.85rem;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    min-height: 1.2em;
    word-break: break-all;
    line-height: 1.3;
}
.qc-result {
    font-size: 2rem;
    font-weight: 700;
    color: #f8fafc;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── 基础计算器：键盘 ── */
.qc-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-secondary, #f8fafc);
}
.qc-key {
    height: 48px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1e293b);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qc-key:hover { background: #eef2ff; }
.qc-key:active { transform: scale(0.94); box-shadow: none; }
.qc-key-func {
    background: #fee2e2;
    color: #dc2626;
}
.qc-key-func:hover { background: #fecaca; }
.qc-key-op {
    background: #eef2ff;
    color: #667eea;
    font-size: 1.2rem;
}
.qc-key-op:hover { background: #e0e7ff; }
.qc-key-eq {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 1.3rem;
}
.qc-key-eq:hover { filter: brightness(1.1); }
.qc-key-eq:active { filter: brightness(0.95); }

/* ── 计算历史 ── */
.qc-history-section { border-top: 1px solid var(--border-color, #e5e7eb); }
.qc-history-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
}
.qc-history-toggle:hover { color: #667eea; }
.qc-history-arrow { margin-left: auto; transition: transform 0.2s; }
.qc-history-section.open .qc-history-arrow { transform: rotate(180deg); }
.qc-history-body {
    display: none;
    padding: 0 12px 10px;
    max-height: 160px;
    overflow-y: auto;
}
.qc-history-section.open .qc-history-body { display: block; }
.qc-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    font-size: 0.78rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}
.qc-history-item:hover { background: rgba(102,126,234,0.08); }
.qc-history-expr {
    color: var(--text-secondary, #64748b);
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}
.qc-history-result {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    font-family: 'JetBrains Mono', monospace;
}
.qc-history-empty {
    text-align: center;
    padding: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary, #94a3b8);
}
.qc-history-clear {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 5px;
    border: none;
    background: none;
    color: #ef4444;
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    border-radius: 4px;
}
.qc-history-clear:hover { background: #fee2e2; }

/* ── 电商速算：公式卡片列表 ── */
.qc-formulas-list { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.qc-formula-card {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.qc-formula-card.expanded { border-color: #667eea; }
.qc-formula-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    transition: background 0.15s;
}
.qc-formula-card-header:hover { background: rgba(102,126,234,0.05); }
.qc-formula-card-header i:first-child { color: #667eea; font-size: 16px; }
.qc-card-arrow {
    margin-left: auto;
    color: var(--text-secondary, #94a3b8);
    transition: transform 0.2s;
    font-size: 16px;
}
.qc-formula-card.expanded .qc-card-arrow { transform: rotate(180deg); }
.qc-fc-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    letter-spacing: 0.03em;
}
.qc-formula-card-body {
    display: none;
    padding: 0 14px 14px;
}
.qc-formula-card.expanded .qc-formula-card-body { display: block; }

/* ── 电商速算：输入字段 ── */
.qc-fc-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.qc-fc-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    margin-bottom: 3px;
}
.qc-fc-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-card, #fff);
    transition: border-color 0.15s;
}
.qc-fc-input-wrap:focus-within { border-color: #667eea; box-shadow: 0 0 0 2px rgba(102,126,234,0.15); }
.qc-fc-input-wrap input {
    flex: 1;
    border: none;
    padding: 7px 8px;
    font-size: 0.85rem;
    background: transparent;
    color: var(--text-primary, #1e293b);
    outline: none;
    min-width: 0;
}
.qc-fc-unit {
    padding: 0 8px;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    background: var(--bg-secondary, #f8fafc);
    height: 100%;
    display: flex;
    align-items: center;
    border-left: 1px solid var(--border-color, #e5e7eb);
}
.qc-fc-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 10px;
    cursor: pointer;
}
.qc-fc-checkbox input[type="checkbox"] { accent-color: #667eea; }

/* ── 电商速算：计算按钮 ── */
.qc-fc-btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: filter 0.15s;
}
.qc-fc-btn:hover { filter: brightness(1.1); }
.qc-fc-btn:active { filter: brightness(0.95); }

/* ── 电商速算：结果区域 ── */
.qc-fc-result {
    display: none;
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(102,126,234,0.05), rgba(118,75,162,0.05));
    border: 1px solid rgba(102,126,234,0.15);
    border-radius: 8px;
}
.qc-fc-result.show { display: block; }
.qc-fr-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.82rem;
    color: var(--text-secondary, #64748b);
}
.qc-fr-row strong {
    color: var(--text-primary, #1e293b);
    font-family: 'JetBrains Mono', monospace;
}
.qc-fr-row + .qc-fr-row { border-top: 1px dashed rgba(0,0,0,0.06); }

/* ── 满减盈亏表格 ── */
.qc-fc-result .qc-fc-baseline {
    font-size: 0.76rem;
    color: var(--text-secondary, #64748b);
    padding: 6px 8px;
    background: rgba(102,126,234,0.08);
    border-radius: 6px;
    margin-bottom: 8px;
}
.qc-fc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.74rem;
    font-family: 'JetBrains Mono', monospace;
}
.qc-fc-table th {
    padding: 5px 4px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    font-size: 0.7rem;
    white-space: nowrap;
}
.qc-fc-table td {
    padding: 5px 4px;
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    white-space: nowrap;
}
.qc-fc-table tr.loss { background: #fef2f2; }
.qc-fc-table tr.loss td { color: #dc2626; font-weight: 600; }
.qc-fc-table tr.warn { background: #fffbeb; }
.qc-fc-table tr.warn td:last-child { color: #d97706; }
.qc-fc-table tr.caution td:last-child { color: #2563eb; }

/* ── 底部导流 ── */
.qc-deep-link {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 16px 14px;
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    border-top: 1px solid var(--border-color, #e5e7eb);
}
.qc-deep-link i { color: #667eea; }
.qc-deep-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}
.qc-deep-link a:hover { text-decoration: underline; }
.qc-link-sep { color: var(--border-color, #d1d5db); }

/* ── 暗色模式 ── */
html[data-theme="dark"] .qc-calc-display { background: #0f172a; }
html[data-theme="dark"] .qc-key { background: #1e293b; color: #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
html[data-theme="dark"] .qc-key:hover { background: #334155; }
html[data-theme="dark"] .qc-key-func { background: #451a1a; color: #fca5a5; }
html[data-theme="dark"] .qc-key-op { background: #1e1b4b; color: #a5b4fc; }
html[data-theme="dark"] .qc-keypad { background: var(--bg-secondary, #0f172a); }
html[data-theme="dark"] .qc-panel { box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06); }

/* ── 移动端适配 ── */
@media (max-width: 640px) {
    .qc-fab {
        bottom: 242px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .qc-panel {
        bottom: 12px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 24px);
        border-radius: 14px;
    }
}
