/* ============================================================
   AI 智能股票模拟交易系统 - 全局样式
   深色交易主题 | 红涨绿跌(中国惯例)
   ============================================================ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2333;
    --bg-hover: #21262d;
    --bg-input: #0d1117;
    --border-color: #30363d;
    --border-light: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --color-up: #f85149;       /* 涨 - 红 */
    --color-up-bg: rgba(248,81,73,0.1);
    --color-down: #3fb950;     /* 跌 - 绿 */
    --color-down-bg: rgba(63,185,80,0.1);
    --color-flat: #8b949e;
    --color-accent: #58a6ff;
    --color-accent-bg: rgba(88,166,255,0.1);
    --color-warn: #d29922;
    --color-strong-buy: #f85149;
    --color-buy: #ff7b72;
    --color-hold: #8b949e;
    --color-sell: #7ee787;
    --color-strong-sell: #3fb950;
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 布局 ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-left .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.logo-icon {
    background: linear-gradient(135deg, #58a6ff, #f85149);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
}
.logo-text { font-size: 18px; font-weight: 600; color: var(--text-primary); }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.balance-label { font-size: 11px; color: var(--text-muted); }
.balance-value { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.balance-value.cash { color: var(--color-accent); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--bg-card);
    border-radius: 20px;
}
.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.user-name { color: var(--text-secondary); }

.btn-logout, .btn-login, .btn-register {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    border: none;
    cursor: pointer;
    text-decoration: none;
}
.btn-logout { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-login { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); }
.btn-register { background: var(--color-accent); color: #fff; }

.main-wrapper {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 60px);
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--bg-card);
    color: var(--color-accent);
    border-left-color: var(--color-accent);
}
.nav-icon { font-size: 18px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}
.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.sync-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-down);
}
.sync-dot.active { background: var(--color-up); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.btn-sync {
    width: 100%;
    padding: 8px;
    background: var(--color-accent-bg);
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.btn-sync:hover { background: var(--color-accent); color: #fff; }
.btn-sync:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 主内容区 ===== */
.content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; }

/* ===== 网格布局 ===== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ===== 统计卡片 ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-change { font-size: 13px; margin-top: 4px; }

/* ===== 涨跌色 ===== */
.up, .color-up { color: var(--color-up); }
.down, .color-down { color: var(--color-down); }
.flat, .color-flat { color: var(--color-flat); }
.bg-up { background: var(--color-up-bg); }
.bg-down { background: var(--color-down-bg); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
.data-table tr:hover { background: var(--bg-hover); }
.data-table .stock-name { font-weight: 600; }
.data-table .stock-code { color: var(--text-muted); font-size: 12px; }

/* ===== 信号标签 ===== */
.signal-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.signal-strong_buy { background: var(--color-up-bg); color: var(--color-strong-buy); border: 1px solid var(--color-up); }
.signal-buy { background: rgba(255,123,114,0.1); color: var(--color-buy); border: 1px solid var(--color-buy); }
.signal-hold { background: rgba(139,148,158,0.1); color: var(--color-hold); border: 1px solid var(--color-hold); }
.signal-sell { background: rgba(126,231,135,0.1); color: var(--color-sell); border: 1px solid var(--color-sell); }
.signal-strong_sell { background: var(--color-down-bg); color: var(--color-strong-sell); border: 1px solid var(--color-down); }

/* ===== 按钮 ===== */
.btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}
.btn-primary { background: var(--color-up); color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-success { background: var(--color-down); color: #fff; }
.btn-success:hover { opacity: 0.85; }
.btn-danger { background: var(--color-up); color: #fff; }
.btn-outline { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); }
.btn-outline:hover { background: var(--color-accent); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: 13px; }
.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--color-accent); }
.form-input::placeholder { color: var(--text-muted); }

/* ===== 登录/注册页 ===== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1c2333 100%);
}
.auth-box {
    width: 400px;
    max-width: 90%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}
.auth-title {
    text-align: center;
    margin-bottom: 28px;
}
.auth-title h1 {
    font-size: 22px;
    margin-bottom: 6px;
}
.auth-title p {
    color: var(--text-muted);
    font-size: 13px;
}
.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Toast 通知 ===== */
.toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    min-width: 280px;
    padding: 14px 20px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { border-left: 3px solid var(--color-down); }
.toast.error { border-left: 3px solid var(--color-up); }
.toast.info { border-left: 3px solid var(--color-accent); }

/* ===== 弹窗 ===== */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 480px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-body { padding: 20px; }

/* ===== AI分析卡片 ===== */
.ai-pick-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-pick-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow);
}
.ai-pick-card .pick-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.ai-pick-card .pick-score {
    font-size: 28px;
    font-weight: 700;
}
.ai-pick-card .pick-reasoning {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.6;
}

/* ===== 进度条/置信度 ===== */
.confidence-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-warn), var(--color-up));
    border-radius: 3px;
    transition: width 0.3s;
}

/* ===== 图表容器 ===== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ===== 搜索框 ===== */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.search-box .form-input { flex: 1; }

/* ===== 过滤标签 ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-tab {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-tab.active {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.filter-tab:hover { border-color: var(--color-accent); }

/* ===== 股票头部信息 ===== */
.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}
.stock-info-left h2 { font-size: 22px; margin-bottom: 4px; }
.stock-info-left .stock-meta { color: var(--text-muted); font-size: 13px; }
.price-display {
    text-align: right;
}
.price-display .current-price {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}
.price-display .price-change {
    font-size: 16px;
    margin-top: 4px;
}

/* ===== 交易面板 ===== */
.trade-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
}
.trade-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
}
.trade-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    font-weight: 600;
    transition: all 0.2s;
}
.trade-tab:first-child { border-radius: 6px 0 0 6px; }
.trade-tab:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.trade-tab.buy { color: var(--color-up); }
.trade-tab.sell { color: var(--color-down); }
.trade-tab.active.buy { background: var(--color-up); color: #fff; }
.trade-tab.active.sell { background: var(--color-down); color: #fff; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { width: 60px; }
    .sidebar .nav-item span:not(.nav-icon) { display: none; }
    .sidebar-footer { display: none; }
}
@media (max-width: 640px) {
    .grid-4 { grid-template-columns: 1fr; }
    .navbar-right .nav-balance { display: none; }
    .content { padding: 16px; }
    .sidebar { display: none; }
}

/* ===== 加载动画 ===== */
.loading {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== 新闻列表 ===== */
.news-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}
.news-item:last-child { border-bottom: none; }
.news-item .news-title { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.news-item .news-content { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.news-item .news-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.news-item .sentiment-tag {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}
.pagination button {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
}
.pagination button.active { background: var(--color-accent); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
