/* 🍳 锅老师·L2量化系统 - 样式表 (响应式 + 明暗双主题) */

/* ===== 暗色主题（默认） ===== */
:root {
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-input: #0d1117;
    --bg-indicator: #0d1117;
    --border: #21262d;
    --border-hover: #30363d;
    --text: #c9d1d9;
    --text-heading: #e6edf3;
    --text-muted: #8b949e;
    --text-dim: #484f58;
    --accent: #ff6b35;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --shadow: rgba(0,0,0,0.85);
    --toast-bg: #1b3a1b;
    --error-bg: #3d1f1f;
    --bar-bg: #0d1117;
}

/* ===== 亮色主题 ===== */
[data-theme="light"] {
    --bg: #f6f8fa;
    --bg-card: #ffffff;
    --bg-input: #f6f8fa;
    --bg-indicator: #f0f2f5;
    --border: #d0d7de;
    --border-hover: #afb8c1;
    --text: #24292f;
    --text-heading: #1f2328;
    --text-muted: #656d76;
    --text-dim: #8b949e;
    --accent: #cf4d1a;
    --green: #1a7f37;
    --red: #cf222e;
    --yellow: #9a6700;
    --shadow: rgba(0,0,0,0.3);
    --toast-bg: #dafbe1;
    --error-bg: #ffebe9;
    --bar-bg: #e8eaed;
}

/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}

.container { max-width: 520px; margin: 0 auto; padding: 12px 14px; }

/* ===== 头部 ===== */
header { margin-bottom: 8px; }
.header-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.header-top h1 { font-size: 18px; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 4px; }
.countdown { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.btn-icon {
    background: transparent; color: var(--text-muted); border: none;
    border-radius: 6px; padding: 4px 6px; font-size: 15px; cursor: pointer;
    transition: color 0.2s; line-height: 1;
}
.btn-icon:hover { color: var(--accent); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-logout {
    color: var(--text-muted); text-decoration: none; font-size: 15px; padding: 4px;
    opacity: 0.5; transition: opacity 0.2s;
}
.btn-logout:hover { opacity: 1; }

/* ===== 盈亏走势图 ===== */
.sparkline-wrap {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 6px 8px 2px; margin-bottom: 8px;
}
.sparkline-wrap canvas { width: 100%; height: 48px; display: block; }

/* ===== 底部导航 ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around; overflow-x: auto;
    background: var(--bg-card); border-top: 1px solid var(--border);
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
    z-index: 100; -webkit-overflow-scrolling: touch;
}
.nav-item {
    text-decoration: none; font-size: 11px; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 8px; border-radius: 8px; transition: color 0.2s;
    min-width: 44px; min-height: 44px; justify-content: center; flex-shrink: 0;
}
.nav-item.active { color: var(--accent); font-weight: 600; }

/* 页面底部留白（避免被导航遮挡） */
.container { padding-bottom: 90px; }

/* 按钮触摸目标 */
.btn-icon { padding: 8px; font-size: 18px; min-width: 44px; min-height: 44px; }
.btn { padding: 12px; font-size: 15px; min-height: 44px; }
.form-group input { padding: 12px; font-size: 15px; min-height: 44px; }
.check-box { min-width: 24px; min-height: 24px; }

/* ===== 精简卡片 ===== */
.card-mini { border: 1px solid var(--border); }
.card-mini .card-header { padding: 8px 10px 2px; }
.card-mini .card-body { padding: 2px 10px 8px; }
.card-mini .price { font-size: 16px; }
.card-mini .targets-row { font-size: 10px; }
.shares-badge { font-size: 11px; color: var(--text-muted); background: var(--bg-indicator); padding: 1px 6px; border-radius: 4px; }

/* ===== 筛选栏（保留CSS，HTML已移除）===== */
.filter-bar {
    display: flex; gap: 8px; margin-bottom: 8px;
}
.filter-input {
    flex: 1; padding: 8px 12px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-heading); font-size: 13px; outline: none;
    transition: border-color 0.2s;
}
.filter-input:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--text-muted); }
.filter-select {
    padding: 8px 10px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-heading); font-size: 13px; outline: none;
    cursor: pointer; min-width: 120px;
}

/* ===== 价格预警边框 ===== */
.card.alert-danger { border-color: var(--red) !important; box-shadow: 0 0 8px rgba(248,81,73,0.15); }
.card.alert-warning { border-color: var(--yellow) !important; box-shadow: 0 0 8px rgba(210,153,34,0.12); }
.card.alert-tp { border-color: var(--green) !important; box-shadow: 0 0 8px rgba(63,185,80,0.12); }

/* ===== 加载条 ===== */
.loading-bar { height: 2px; background: var(--border); margin-bottom: 8px; border-radius: 1px; overflow: hidden; }
.loading-bar-inner {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: loading-slide 0.8s ease-in-out infinite;
}
@keyframes loading-slide {
    0% { transform: translateX(-100%); } 100% { transform: translateX(100%); }
}

/* ===== 汇总栏 ===== */
.summary-bar {
    display: flex; justify-content: space-around;
    background: var(--bg-card); border-radius: 10px;
    padding: 10px 8px; margin-bottom: 10px;
    border: 1px solid var(--border);
}
.summary-item { text-align: center; flex: 1; }
.summary-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.summary-value { display: block; font-size: 15px; font-weight: 600; color: var(--text-heading); }
.summary-value.negative { color: var(--red); }
.summary-value.positive { color: var(--green); }
.summary-time { font-size: 12px !important; font-weight: 400 !important; color: var(--text-muted) !important; }

/* ===== 卡片 ===== */
.grid { display: flex; flex-direction: column; gap: 8px; transition: opacity 0.2s; }
.card-link { text-decoration: none; display: block; }
.card {
    background: var(--bg-card); border-radius: 10px;
    border: 1px solid var(--border); overflow: hidden;
    transition: border-color 0.15s, background 0.3s;
}
.card:hover { border-color: var(--border-hover); }
.card:active { border-color: var(--accent); }
.card:focus-visible, .card-mini:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card-🟢 { border-left: 3px solid var(--green); }
.card-🟢🟢 { border-left: 3px solid var(--green); }
.card-🟡 { border-left: 3px solid var(--yellow); }
.card-🟠 { border-left: 3px solid #f0883e; }
.card-🔴 { border-left: 3px solid var(--red); }
.card-⚪ { border-left: 3px solid var(--text-dim); }

.card-header { display: flex; align-items: center; padding: 10px 12px 4px; gap: 8px; }
.signal-badge { font-size: 16px; flex-shrink: 0; }
.stock-name { font-size: 15px; font-weight: 600; color: var(--text-heading); }
.stock-code { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.card-body { padding: 4px 12px 10px; }

.price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.price { font-size: 17px; font-weight: 700; color: var(--text-heading); }
.cost { font-size: 11px; color: var(--text-muted); }
.pnl { font-size: 14px; font-weight: 600; margin-left: auto; }
.pnl.negative { color: var(--red); }
.pnl.positive { color: var(--green); }

.indicators-row {
    display: flex; gap: 6px; margin-bottom: 1px;
    font-size: 11px; color: var(--text-muted); flex-wrap: wrap;
}
.indicator { background: var(--bg-indicator); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

.action-row { font-size: 12px; color: var(--text-heading); margin: 4px 0 2px; }
.targets-row { font-size: 11px; color: var(--text-muted); }
.note-row { font-size: 11px; color: var(--yellow); margin-top: 4px; padding: 4px 8px; background: var(--bg-indicator); border-radius: 4px; }

/* ===== 图例 ===== */
.legend {
    margin-top: 12px; font-size: 12px; color: var(--text-muted);
    text-align: center; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-buy { background: var(--green); }
.dot-hold { background: var(--yellow); }
.dot-sell { background: var(--red); }
.dot-watch { background: var(--text-dim); }

/* ===== 个股详情 ===== */
.back-link { color: var(--accent); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 4px; }
.detail-card {
    background: var(--bg-card); border-radius: 10px;
    border: 1px solid var(--border); padding: 12px; margin-bottom: 12px;
}
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.signal-badge-large { font-size: 24px; }
.detail-price { font-size: 26px; font-weight: 700; color: var(--text-heading); }
.detail-change { font-size: 15px; color: var(--text-muted); }
.info-row {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.info-row:last-child { border-bottom: none; }
.label { font-size: 12px; color: var(--text-muted); min-width: 40px; }
.value { font-size: 13px; color: var(--text-heading); min-width: 50px; }
.value.full { flex: 1; }
.value.negative { color: var(--red); }
.value.positive { color: var(--green); }
.support-color { color: var(--green) !important; }
.resistance-color { color: var(--red) !important; }

.indicators-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px; margin-bottom: 12px;
}
.indicator-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px; text-align: center;
}
.indicator-title { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.indicator-value { font-size: 14px; font-weight: 600; color: var(--text-heading); }
.indicator-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.indicator-bar {
    width: 100%; height: 4px; background: var(--bar-bg);
    border-radius: 2px; margin-top: 6px; overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.signal-list { margin-bottom: 12px; }
.signal-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 6px;
    margin-bottom: 4px; font-size: 13px;
}
.signal-emoji { font-size: 16px; }

/* Toast */
.toast {
    background: var(--toast-bg); color: var(--green); text-align: center;
    padding: 8px; border-radius: 6px; margin-bottom: 8px; font-size: 13px;
}

/* Footer */
footer { text-align: center; font-size: 11px; color: var(--text-dim); padding: 16px 0 8px; }
footer a { color: var(--text-muted); }

h3 { font-size: 14px; color: var(--accent); margin: 12px 0 6px; }

/* ===== 登录页 ===== */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg);
}
.login-box {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 32px 24px;
    width: 100%; max-width: 380px; margin: 0 12px;
}
.login-box h1 { text-align: center; color: var(--accent); font-size: 22px; margin-bottom: 4px; }
.login-box .subtitle { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input {
    width: 100%; padding: 10px 12px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-heading); font-size: 15px; outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent); }
.btn {
    width: 100%; padding: 10px; background: var(--accent);
    color: #fff; border: none; border-radius: 8px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.9; }
.btn:active { opacity: 0.7; }
.error {
    background: var(--error-bg); color: var(--red); padding: 8px 12px;
    border-radius: 6px; margin-bottom: 12px; font-size: 13px; text-align: center;
}
.login-box .footer { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 16px; }

/* ===== 离线横幅 ===== */
.offline-banner { background: var(--error-bg); color: var(--red); }

/* ===== 离线缓存横幅 ===== */
#offline-cache-bar {
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== 缓存数据标记 ===== */
.cache-indicator {
    display: inline-block;
    background: var(--bg-indicator);
    color: var(--yellow);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ===== 价格变动动画 ===== */
@keyframes flashGreen {
    0% { background-color: rgba(63,185,80,0.4); }
    100% { background-color: transparent; }
}
@keyframes flashRed {
    0% { background-color: rgba(248,81,73,0.4); }
    100% { background-color: transparent; }
}
@keyframes flashUpdate {
    0% { background-color: rgba(210,153,34,0.35); }
    100% { background-color: transparent; }
}
.flash-up { animation: flashGreen 1.2s ease-out; border-radius: 3px; padding: 1px 4px; }
.flash-down { animation: flashRed 1.2s ease-out; border-radius: 3px; padding: 1px 4px; }
.flash-update { animation: flashUpdate 1.2s ease-out; border-radius: 4px; }

/* ===== 骨架屏加载 ===== */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--border-hover) 50%, var(--border) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}
.skeleton-text { height: 14px; margin: 6px 0; width: 80%; }
.skeleton-text.short { width: 50%; }
.skeleton-price { height: 24px; width: 60%; margin: 4px 0; }

/* ===== 状态指示 ===== */
#update-status { transition: color 0.3s; font-variant-numeric: tabular-nums; }

/* ===== Toast 通知 ===== */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== 无障碍：减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== 响应式 ===== */
@media (min-width: 768px) {
    .container { max-width: 720px; padding: 16px 20px; }
    .header-top h1 { font-size: 22px; }
    .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .summary-bar { padding: 12px 16px; }
    .summary-value { font-size: 18px; }
    .hide-mobile { display: block !important; }
}
@media (min-width: 1024px) {
    .container { max-width: 920px; }
    .grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
    .container { padding: 10px; }
    .summary-bar { padding: 8px 4px; }
    .summary-value { font-size: 14px; }
    .card-body { padding: 4px 10px 8px; }
    .indicators-grid { grid-template-columns: repeat(3, 1fr); }
}
