/* ========================================
   智能选股助手 - 深色金融风样式
   ======================================== */

:root {
    --bg-primary: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2333;
    --bg-input: #0d1117;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-gold: #facc15;
    --accent-gold-dim: #b8960a;
    --color-up: #ef4444;       /* A股红涨 */
    --color-up-bg: rgba(239, 68, 68, 0.12);
    --color-down: #22c55e;     /* A股绿跌 */
    --color-down-bg: rgba(34, 197, 94, 0.12);
    --color-blue: #3b82f6;
    --color-purple: #a855f7;
    --color-orange: #f97316;
    --border-color: #21262d;
    --border-light: #30363d;
    --shadow-card: 0 2px 8px rgba(0,0,0,0.3);
    --radius: 10px;
    --tab-height: 60px;
    --header-height: 48px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== 顶部状态栏 ========== */
.app-header {
    height: var(--header-height);
    background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 100;
}

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

.header-icon {
    font-size: 20px;
}

.header-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.5px;
}

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

.clock {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: "SF Mono", "Fira Code", monospace;
}

.net-status {
    font-size: 10px;
    color: var(--color-up);
}

.net-status.offline {
    color: var(--text-muted);
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    padding-bottom: calc(var(--tab-height) + 16px);
}

/* ========== 底部 Tab 导航 ========== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: linear-gradient(0deg, #0d1117 0%, #161b22 100%);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
}

.tab-item:active {
    transform: scale(0.92);
}

.tab-icon {
    font-size: 20px;
    filter: grayscale(1);
    opacity: 0.5;
    transition: all 0.2s;
}

.tab-label {
    font-size: 11px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tab-item.active .tab-icon {
    filter: grayscale(0);
    opacity: 1;
}

.tab-item.active .tab-label {
    color: var(--accent-gold);
    font-weight: 600;
}

/* ========== 卡片通用 ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-title .badge {
    font-size: 11px;
    background: var(--accent-gold);
    color: #000;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}

/* ========== 指数卡片 ========== */
.index-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.index-card {
    background: rgba(22, 27, 34, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 6px;
    text-align: center;
}

.index-name {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.index-price {
    font-size: 15px;
    font-weight: 700;
    font-family: "SF Mono", "Fira Code", monospace;
    margin-bottom: 4px;
}

.index-change {
    font-size: 11px;
    font-weight: 600;
}

/* ========== 表格 ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 11px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 8px 4px;
    border-bottom: 1px solid rgba(33, 38, 45, 0.5);
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:active {
    background: var(--bg-card-hover);
}

.col-code { color: var(--text-secondary); font-size: 12px; }
.col-name { font-weight: 600; }
.col-num { text-align: right; font-family: "SF Mono", monospace; }
.col-up { color: var(--color-up); }
.col-down { color: var(--color-down); }

/* ========== 涨跌幅标签 ========== */
.chg-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    font-family: "SF Mono", monospace;
}

.chg-tag.up { background: var(--color-up-bg); color: var(--color-up); }
.chg-tag.down { background: var(--color-down-bg); color: var(--color-down); }

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent-gold);
    color: #000;
    width: 100%;
}

.btn-primary:active { background: var(--accent-gold-dim); }

.btn-danger {
    background: var(--color-up);
    color: #fff;
    padding: 4px 10px;
    font-size: 12px;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    padding: 6px 12px;
    font-size: 13px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ========== 输入框 ========== */
.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.input:focus {
    border-color: var(--accent-gold);
}

/* ========== 滑块 ========== */
.slider-group {
    margin-bottom: 14px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

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

.slider-label .label-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-gold);
    font-family: "SF Mono", monospace;
}

.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-light);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-gold);
    cursor: pointer;
    border: 2px solid #000;
}

/* ========== 风格选择 ========== */
.style-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.style-btn {
    padding: 8px 4px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.style-btn.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(250, 204, 21, 0.08);
    font-weight: 600;
}

.style-btn.recommended {
    border-color: var(--color-up);
    box-shadow: 0 0 0 1px var(--color-up) inset;
    color: var(--color-up);
}

.style-btn.recommended.active {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 1px var(--accent-gold) inset;
}

/* ========== 评分条 ========== */
.score-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.score-bar .score-label {
    font-size: 12px;
    color: var(--text-secondary);
    width: 50px;
    flex-shrink: 0;
}

.score-bar .score-track {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.score-bar .score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.score-bar .score-num {
    font-size: 13px;
    font-weight: 700;
    font-family: "SF Mono", monospace;
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ========== 详情浮层 ========== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.overlay-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-gold);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
}

.overlay-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.add-watch-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.add-watch-btn.active {
    opacity: 1;
}

.overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

/* ========== 个股头部 ========== */
.stock-header {
    text-align: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.stock-name-code {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stock-price {
    font-size: 36px;
    font-weight: 800;
    font-family: "SF Mono", monospace;
    margin-bottom: 4px;
}

.stock-change {
    font-size: 16px;
    font-weight: 600;
}

/* ========== 图表容器 ========== */
.chart-container {
    width: 100%;
    height: 220px;
    margin-bottom: 12px;
}

.chart-container-tall {
    width: 100%;
    height: 280px;
    margin-bottom: 12px;
}

/* ========== 加载遮罩 ========== */
.loading-mask {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 400;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

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

.empty-state .empty-text {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ========== 预警项 ========== */
.alert-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-item .alert-info {
    flex: 1;
}

.alert-item .alert-condition {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 4px;
}

.alert-item .alert-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.alert-item .alert-status.triggered {
    background: var(--color-up-bg);
    color: var(--color-up);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== 雷达图容器 ========== */
.radar-container {
    width: 100%;
    height: 260px;
}

/* ========== 隐藏类 ========== */
.hidden { display: none !important; }

/* ========== 数据来源标签 ========== */
.data-source-tag {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.data-source-tag.real {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-down);
}

.data-source-tag.mock {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-muted);
}

/* ========== 自选股纵向卡片 (方案A) ========== */
.wl-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.wl-card:active {
    border-color: var(--accent-gold);
}

/* 卡片头部（始终可见） */
.wl-card-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    gap: 10px;
}

.wl-card-left {
    flex: 1;
    min-width: 0;
}

.wl-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wl-card-code {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.wl-card-right {
    text-align: right;
    flex-shrink: 0;
    min-width: 80px;
}

.wl-card-price {
    font-size: 16px;
    font-weight: 700;
    font-family: "SF Mono", "Fira Code", monospace;
}

.wl-card-chg {
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
}

.wl-card-arrow {
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 4px;
    transition: transform 0.2s;
}

/* 展开后的详情区 */
.wl-card-detail {
    padding: 0 14px 14px 14px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    animation: fadeInDown 0.25s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 详情数据网格 */
.wl-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 10px;
    margin-bottom: 12px;
}

.wl-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wl-detail-label {
    font-size: 10px;
    color: var(--text-muted);
}

.wl-detail-val {
    font-size: 12px;
    font-weight: 600;
    font-family: "SF Mono", monospace;
    color: var(--text-primary);
}

/* 图表区域 */
.wl-chart-wrap {
    margin-bottom: 12px;
}

.wl-chart-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

/* 卡片底部操作按钮 */
.wl-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* 搜索结果项 */
.wl-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-color);
}

.wl-search-item:last-child {
    border-bottom: none;
}

.wl-search-name {
    font-size: 13px;
    font-weight: 600;
}

.wl-search-code {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========== 响应式 ========== */
@media (min-width: 480px) {
    .main-content {
        max-width: 480px;
        margin: 0 auto;
    }
}
