/* ========================================
   首页样式 - 股票市场概览
   涨红跌绿 | 响应式 | 美观大方
   ======================================== */

:root {
    --up-color: #e63946;
    --down-color: #2a9d5c;
    --flat-color: #999;
    --primary: #1a73e8;
    --primary-light: #4a90d9;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --text-primary: #1a1a2e;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #e8ecf1;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 1400px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: #fff;
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.header .container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.header h1 { font-size: 20px; font-weight: 700; white-space: nowrap; }
.header h1 span { opacity: 0.7; font-weight: 400; font-size: 14px; margin-left: 8px; }

/* Search */
.search-wrap { flex: 1; max-width: 420px; position: relative; }
.search-wrap input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: none;
    border-radius: 24px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: background 0.3s;
}
.search-wrap input::placeholder { color: rgba(255,255,255,0.5); }
.search-wrap input:focus { background: rgba(255,255,255,0.2); }
.search-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: 0.5; }
.search-results-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; background: #fff; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover); max-height: 360px; overflow-y: auto; display: none; z-index: 200; margin-top: 4px;
}
.search-results-dropdown.show { display: block; }
.search-item {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid var(--border); color: var(--text-primary); transition: background 0.15s;
}
.search-item:hover { background: #f8f9ff; }
.search-item .name { font-weight: 600; font-size: 14px; }
.search-item .code { color: var(--text-muted); font-size: 12px; margin-left: 6px; }
.search-item .price { font-weight: 700; font-size: 14px; }

/* Nav */
.nav-links { display: flex; gap: 4px; }
.nav-links a {
    color: rgba(255,255,255,0.65); text-decoration: none; padding: 6px 14px; border-radius: 20px;
    font-size: 13px; transition: all 0.2s; white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active { color: #fff; background: rgba(255,255,255,0.15); }

/* Auth */
.auth-area { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.user-name { font-size: 13px; color: rgba(255,255,255,0.85); font-weight: 500; }
.btn-login {
    padding: 6px 18px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.4);
    background: transparent; color: #fff; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-login:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.7); }
.btn-logout {
    padding: 4px 12px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.25);
    background: transparent; color: rgba(255,255,255,0.6); font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.btn-logout:hover { color: #fff; border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.1); }

/* ===== Main ===== */
.main { padding: 20px 0 40px; }

/* Cards */
.card {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 20px; transition: box-shadow 0.3s;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title {
    font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.card-title .emoji { font-size: 18px; }

/* ===== 指数卡片 ===== */
.indices-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.index-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.index-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
    opacity: 0.8;
}

.index-card.up::before { background: linear-gradient(90deg, #ff6b6b, #ee5a5a); }
.index-card.down::before { background: linear-gradient(90deg, #51cf66, #40c057); }

.index-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.index-card.up { border-color: rgba(230,57,70,0.12); }
.index-card.down { border-color: rgba(42,157,92,0.12); }

.index-name {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 1px;
}

.index-price {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'DIN Alternate', sans-serif;
}

.index-change {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.index-breadth {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 13px;
    font-weight: 500;
}

.index-breadth .up-count { color: var(--up-color); }
.index-breadth .down-count { color: var(--down-color); }
.index-breadth .flat-count { color: var(--flat-color); }

.up-text { color: var(--up-color); }
.down-text { color: var(--down-color); }
.flat-text { color: var(--flat-color); }

/* ===== 情绪指数 ===== */
.sentiment-bar {
    background: var(--card-bg); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); margin-bottom: 20px;
}
.sentiment-meter { height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--down-color), #f0c040, var(--up-color)); position: relative; margin: 16px 0 8px; }
.sentiment-needle {
    position: absolute; top: -6px; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 3px solid var(--primary); box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transform: translateX(-50%); transition: left 0.8s ease;
}
.sentiment-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.sentiment-value { text-align: center; margin-top: 8px; }
.sentiment-score { font-size: 36px; font-weight: 800; }
.sentiment-label { font-size: 14px; font-weight: 600; margin-top: 4px; }

/* ===== 图表行 ===== */
.charts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-box {
    min-height: auto;
    padding: 16px 16px 12px !important;
    background: linear-gradient(135deg, #fff 0%, #fafbff 100%);
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
}

.chart-box .card-title {
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
    font-weight: 600;
}

.chart-box .card-title .emoji { font-size: 15px; }

.chart-box > div[id^="chart-"] {
    width: 100%;
    height: 180px;
}

/* ===== 排行榜 ===== */
.rank-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.rank-tab {
    padding: 8px 18px; border-radius: 20px; border: 1px solid var(--border);
    background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); transition: all 0.2s;
}
.rank-tab:hover { border-color: var(--primary); color: var(--primary); }
.rank-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.rank-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rank-table th {
    text-align: left; padding: 12px 16px; font-size: 13px; color: var(--text-muted);
    font-weight: 600; border-bottom: 2px solid var(--border); background: #fafbfc;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 列宽均匀分配: 排名6% 名称22% 代码18% 现价18% 涨跌幅18% 成交额18% */
.rank-table th:nth-child(1), .rank-table td:nth-child(1) { width: 6%; text-align: center; }
.rank-table th:nth-child(2), .rank-table td:nth-child(2) { width: 22%; }
.rank-table th:nth-child(3), .rank-table td:nth-child(3) { width: 18%; }
.rank-table th:nth-child(4), .rank-table td:nth-child(4) { width: 18%; text-align: right; }
.rank-table th:nth-child(5), .rank-table td:nth-child(5) { width: 18%; text-align: right; }
.rank-table th:nth-child(6), .rank-table td:nth-child(6) { width: 18%; text-align: right; }
.rank-table td {
    padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #f0f0f0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}
.rank-table tr:hover { background: #f8f9ff; transition: background 0.15s; }
.rank-table .rank-num { color: var(--text-muted); font-weight: 700; font-size: 15px; }
.rank-table .rank-num.top3 { color: var(--up-color); font-size: 16px; }
.rank-table .stock-name { font-weight: 600; font-size: 14px; }
.rank-table .stock-code { color: var(--text-muted); font-size: 13px; }

/* ===== 行业板块 ===== */
.sector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.sector-item {
    padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: #fff; transition: all 0.2s;
}
.sector-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.sector-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.sector-pct { font-size: 18px; font-weight: 700; }
.sector-leader { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 股票详情卡片 ===== */
.stock-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); display: none; margin-bottom: 20px; border: 2px solid transparent;
}
.stock-card.show { display: block; animation: fadeIn 0.3s; }
.stock-card.up { border-color: rgba(230,57,70,0.2); }
.stock-card.down { border-color: rgba(42,157,92,0.2); }
.stock-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.stock-card-name { font-size: 20px; font-weight: 700; }
.stock-card-code { color: var(--text-muted); font-size: 13px; }
.stock-card-price { font-size: 32px; font-weight: 800; margin: 12px 0 4px; }
.stock-card-change { font-size: 15px; font-weight: 600; }
.stock-card-info { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 16px; }
.stock-info-item { }
.stock-info-label { font-size: 12px; color: var(--text-muted); }
.stock-info-value { font-size: 14px; font-weight: 600; }
.stock-card-close { cursor: pointer; font-size: 20px; color: var(--text-muted); background: none; border: none; padding: 4px 8px; }
.stock-card-close:hover { color: var(--text-primary); }

/* ===== Loading ===== */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Footer ===== */
.footer { padding: 24px 0; text-align: center; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .indices-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .header .container { flex-wrap: wrap; }
    .search-wrap { max-width: 100%; order: 3; width: 100%; margin-top: 8px; }
    .nav-links { order: 2; }
    .indices-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .index-price { font-size: 18px; }
    .index-card { padding: 14px; }
    .charts-row { grid-template-columns: 1fr; }
    .sector-grid { grid-template-columns: repeat(2, 1fr); }
    .rank-table { font-size: 12px; }
    .rank-table th, .rank-table td { padding: 8px 8px; font-size: 12px; }
    .rank-table th:nth-child(1), .rank-table td:nth-child(1) { width: 8%; }
    .rank-table th:nth-child(2), .rank-table td:nth-child(2) { width: 24%; }
    .rank-table th:nth-child(3), .rank-table td:nth-child(3) { width: 18%; }
    .rank-table th:nth-child(6), .rank-table td:nth-child(6) { display: none; }
    .card { padding: 16px; }
    .stock-card-price { font-size: 24px; }
    .sentiment-score { font-size: 28px; }
}
@media (max-width: 480px) {
    .indices-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .index-card { padding: 12px; }
    .index-price { font-size: 16px; }
    .sector-grid { grid-template-columns: 1fr; }
    .container { padding: 0 12px; }
}



/* ===== 图表内嵌点评 ===== */
.chart-comment {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8f9fb;
    border-radius: 8px;
    border-left: 3px solid #ddd;
    min-height: 50px;
}

.chart-comment .comment-val {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.chart-comment .comment-val .up { color: #e63946; }
.chart-comment .comment-val .down { color: #2ec573; }

.chart-comment .comment-text {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}
