/* ═══════════════════════════════════════════════════════════════
   common.css — Stock Data Hub 公共样式
   所有页面共享的基础组件样式
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS 变量（主题） ─────────────────── */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-input: #0f1a2b;
    --border: #1e3a5f;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    /* A股风格：红涨绿跌 */
    --color-up: #ef4444;
    --color-up-bg: rgba(239,68,68,0.15);
    --color-down: #10b981;
    --color-down-bg: rgba(16,185,129,0.15);
    --accent-purple: #8b5cf6;
    --accent-orange: #f97316;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #06b6d4);
    --gradient-orange: linear-gradient(135deg, #f97316, #f59e0b);
    --gradient-monitor: linear-gradient(135deg, #06b6d4, #8b5cf6);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);

    /* ── Design System v2.0 Token（渐进式对齐） ── */
    /* 背景色阶 */
    --color-bg-primary: #0F172A;
    --color-bg-secondary: #1E293B;
    --color-bg-tertiary: #334155;
    --color-surface: #1E293B;
    --color-surface-hover: #263348;
    /* 边框色 */
    --color-border: #334155;
    --color-border-light: #475569;
    /* 文本色阶 */
    --color-text-primary: #F1F5F9;
    --color-text-secondary: #94A3B8;
    --color-text-muted: #64748B;
    /* 品牌色 */
    --color-accent-cyan: #06B6D4;
    --color-accent-purple: #8B5CF6;
    --color-accent-blue: #3B82F6;
    /* 语义色 */
    --color-success-dim: rgba(16,185,129,.15);
    --color-danger-dim: rgba(239,68,68,.15);
    --color-warning: #F59E0B;
    --color-warning-dim: rgba(245,158,11,.15);
    --color-info: #3B82F6;
    --color-info-dim: rgba(59,130,246,.15);
    /* 渐变 */
    --gradient-hero: radial-gradient(ellipse at 50% 0%, rgba(6,182,212,.18) 0%, transparent 65%);
    --gradient-cyan: linear-gradient(135deg, #06B6D4, #22D3EE);
    --gradient-purple: linear-gradient(135deg, #8B5CF6, #A78BFA);
    --gradient-blue: linear-gradient(135deg, #3B82F6, #60A5FA);
    /* 字体 */
    --font-display: 'SF Pro Display', -apple-system, 'PingFang SC', sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', 'Menlo', monospace;
    --font-body: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    /* 字号阶梯 */
    --text-xs: .7rem;
    --text-sm: .8rem;
    --text-base: .875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    /* 字重 */
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --fw-extrabold: 800;
    /* 间距 */
    --space-1: 4px;
    --space-2: 6px;
    --space-3: 10px;
    --space-4: 14px;
    --space-5: 18px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 42px;
    /* 圆角 */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 999px;
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
    --shadow-md: 0 4px 12px rgba(0,0,0,.3);
    --shadow-glow-cyan: 0 0 20px rgba(6,182,212,.25);
    --shadow-glow-purple: 0 0 20px rgba(139,92,246,.25);
    /* 过渡动画 */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-bounce: 400ms cubic-bezier(.34,1.56,.64,1);
    /* 安全区 */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── 全局重置 ─────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', Roboto, sans-serif;
    background: var(--bg-primary); color: var(--text-primary); min-height: 100vh;
}

/* ── 布局 ─────────────────────────────── */
.main { max-width: 1400px; margin: 2rem auto; padding: 0 1.5rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-desc { color: var(--text-secondary); font-size: 0.95rem; }

/* ── 卡片 ─────────────────────────────── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 1.5rem 2rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-lg);
}
.card-title {
    font-size: 1.05rem; font-weight: 600; margin-bottom: 1.25rem;
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.card-title-left { display: flex; align-items: center; gap: 0.5rem; }

/* ── 按钮 ─────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 1.5rem; border: none; border-radius: 10px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary { background: rgba(59,130,246,0.15); color: var(--accent-blue); border: 1px solid rgba(59,130,246,0.3); }
.btn-secondary:hover { background: rgba(59,130,246,0.25); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--color-danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success { background: rgba(16,185,129,0.15); color: var(--color-success); border: 1px solid rgba(16,185,129,0.3); }
.btn-success:hover { background: rgba(16,185,129,0.25); }
.btn-amber { background: rgba(245,158,11,0.15); color: var(--accent-amber); border: 1px solid rgba(245,158,11,0.3); }
.btn-amber:hover { background: rgba(245,158,11,0.25); }

/* ── 表单 ─────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.form-input, .form-select {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; padding: 0.6rem 0.85rem;
    color: var(--text-primary); font-size: 0.9rem; outline: none; transition: all 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent-cyan); box-shadow: 0 0 0 3px rgba(6,182,212,0.15); }
.form-hint { font-size: 0.72rem; color: var(--text-muted); }
.quick-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.quick-tag {
    background: rgba(6,182,212,0.1); border: 1px solid rgba(6,182,212,0.3);
    border-radius: 20px; padding: 0.2rem 0.65rem; font-size: 0.72rem;
    color: var(--accent-cyan); cursor: pointer; transition: all 0.2s;
}
.quick-tag:hover { background: rgba(6,182,212,0.25); border-color: var(--accent-cyan); }

/* ── Toggle 开关 ──────────────────────── */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: rgba(100,116,139,0.3);
    border-radius: 12px; transition: all 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: all 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--color-success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── 表格 ─────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); max-height: 500px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
    background: rgba(6,182,212,0.08); color: var(--text-secondary);
    padding: 0.7rem 0.8rem; text-align: left; font-weight: 600;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1;
}
tbody td {
    padding: 0.6rem 0.8rem; text-align: left;
    border-bottom: 1px solid rgba(30,58,95,0.4); font-variant-numeric: tabular-nums;
}
tbody tr:hover { background: rgba(6,182,212,0.04); }
.ratio-high { color: var(--color-danger); font-weight: 700; }

/* ── Modal ────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 2rem; width: 95%; max-width: 680px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}
.modal-wide { max-width: 960px; }
.modal-title { font-size: 1.15rem; font-weight: 600; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* ── 空状态 ───────────────────────────── */
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── Spinner ──────────────────────────── */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(6,182,212,0.3); border-top-color: var(--accent-cyan);
    border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── 工具类 ───────────────────────────── */
.hidden { display: none !important; }

/* ── 引擎状态徽章 ─────────────────────── */
.engine-badge {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem; border-radius: 20px; font-size: 0.82rem; font-weight: 600;
}
.engine-badge.running { background: rgba(16,185,129,0.15); color: var(--color-success); border: 1px solid rgba(16,185,129,0.3); }
.engine-badge.stopped { background: rgba(239,68,68,0.15); color: var(--color-danger); border: 1px solid rgba(239,68,68,0.3); }
.engine-dot { width: 8px; height: 8px; border-radius: 50%; }
.engine-badge.running .engine-dot { background: var(--color-success); animation: pulse 2s infinite; }
.engine-badge.stopped .engine-dot { background: var(--color-danger); }

/* ── 状态徽章 ─────────────────────────── */
.status-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.72rem; font-weight: 600;
}
.status-running { background: rgba(16,185,129,0.15); color: var(--color-success); }
.status-paused { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.status-finished { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ── 任务列表 ─────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }
.task-item {
    background: rgba(15,26,43,0.6); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem 1.25rem; transition: all 0.2s;
}
.task-item:hover { border-color: rgba(6,182,212,0.3); }
.task-item.paused { opacity: 0.65; }
.task-item.finished { opacity: 0.5; }
.task-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
.task-name { font-weight: 600; font-size: 1rem; }
.task-actions { display: flex; gap: 0.5rem; align-items: center; }
.task-meta { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: 0.82rem; color: var(--text-secondary); }
.task-meta-item { display: flex; align-items: center; gap: 0.3rem; }
.task-meta-item strong { color: var(--text-primary); }

/* ── 分组标题 ─────────────────────────── */
.section-title {
    font-size: 0.82rem; font-weight: 600; color: var(--accent-cyan);
    margin: 1rem 0 0.5rem; padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(6,182,212,0.2);
}

/* ── 时段区块 ─────────────────────────── */
.time-period-row {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.5rem; flex-wrap: wrap;
}
.time-period-row .form-input { width: 130px; flex-shrink: 0; }
.time-period-label {
    font-size: 0.78rem; color: var(--text-muted); font-weight: 600;
    min-width: 30px; text-align: center;
}

/* ── Toast 通知 ───────────────────────── */
.toast-container {
    position: fixed; top: 1.5rem; right: 1.5rem; z-index: 9999;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    padding: 0.8rem 1.2rem; border-radius: 10px;
    font-size: 0.85rem; font-weight: 500;
    animation: slideIn 0.3s ease; max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast-success { background: rgba(16,185,129,0.2); color: var(--color-success); border: 1px solid rgba(16,185,129,0.3); }
.toast-error { background: rgba(239,68,68,0.2); color: var(--color-danger); border: 1px solid rgba(239,68,68,0.3); }
.toast-info { background: rgba(59,130,246,0.2); color: var(--accent-blue); border: 1px solid rgba(59,130,246,0.3); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 分页 ─────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem; margin-top: 1.5rem;
}
.pagination .btn { min-width: 36px; justify-content: center; }
.pagination .page-info { font-size: 0.82rem; color: var(--text-secondary); }
