/* ===== 股票强弱度系统 - 样式表 ===== */

:root {
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --primary: #1677ff;
    --up: #e01010;
    --down: #1a8e3f;
    --flat: #999;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 8px;
}

* { 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);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ===== 顶部导航 ===== */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #e01010, #ff6b2c);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    background: none;
    font-size: 14px;
}

.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: var(--primary); color: white; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-info {
    color: var(--text-secondary);
    font-size: 13px;
}

.refresh-btn {
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.refresh-btn:hover { opacity: 0.9; }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.refresh-btn.spinning .icon { animation: spin 1s linear infinite; }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ===== 主内容区 ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px;
}

.view { display: none; }
.view.active { display: block; }

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title .badge {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

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

@media (max-width: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== 指标卡片 ===== */
.metric-card {
    text-align: center;
    padding: 24px 16px;
}

.metric-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.metric-sub {
    font-size: 12px;
    margin-top: 8px;
}

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

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

.chart-sm { min-height: 220px; }
.chart-lg { min-height: 400px; }

/* ===== 表格 ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    background: #fafafa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
}

th:hover { background: #f0f0f0; }
th .sort-arrow { font-size: 10px; margin-left: 4px; opacity: 0.5; }
th.sorted .sort-arrow { opacity: 1; }

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tr:hover td { background: #f8f9ff; }
tr.clickable { cursor: pointer; }

.sector-name { font-weight: 500; color: var(--primary); }
.sector-name:hover { text-decoration: underline; }

/* 强弱值条 */
.strength-bar {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 6px;
}

.strength-bar-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
    background: #ccc;
}

/* 八卦标签 */
.bagua-cell {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.bagua-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ===== 板块详情弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.modal-title { font-size: 17px; font-weight: 600; }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 24px; }

/* ===== 排序按钮组 ===== */
.sort-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sort-btn:hover { border-color: var(--primary); color: var(--primary); }
.sort-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== 加载动画 ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== 八卦图例 ===== */
.bagua-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

.bagua-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
}

/* ===== 提示消息 ===== */
.toast {
    position: fixed;
    top: 70px;
    right: 24px;
    padding: 12px 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 300;
    transform: translateX(400px);
    transition: transform 0.3s;
    max-width: 360px;
}

.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--down); }
.toast.error { border-left: 4px solid var(--up); }
.toast.info { border-left: 4px solid var(--primary); }

/* ===== 行情概览条 ===== */
.market-summary {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.summary-item .label { color: var(--text-secondary); }
.summary-item .value { font-weight: 600; }

/* 涨跌分布条 */
.breadth-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.breadth-up { background: var(--up); }
.breadth-flat { background: var(--flat); }
.breadth-down { background: var(--down); }

/* ===== 饼图汇总网格 ===== */
.pie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.pie-card {
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 12px;
    transition: all 0.2s;
    cursor: default;
}

.pie-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(22,119,255,0.15);
    transform: translateY(-1px);
}

.pie-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.pie-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.pie-card-strength {
    font-size: 20px;
    font-weight: 700;
}

.pie-card-chart {
    width: 100%;
    height: 120px;
}

.chart-mini {
    width: 100%;
    height: 100%;
}

.pie-card-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .pie-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .pie-grid {
        grid-template-columns: 1fr;
    }
}
