/* ============================================
 * 竞价猎手 Pro - 移动端 & 响应式覆盖
 * 不修改原HTML，只用CSS覆盖
 * ============================================ */

/* ====== 通用：防止横向滚动 ====== */
html, body { max-width: 100vw; overflow-x: hidden; }
* { -webkit-tap-highlight-color: transparent; }

/* ====== 平板：1024-1200px ====== */
@media (max-width: 1200px) {
    .main-container { grid-template-columns: 260px 1fr 300px; }
    .logo-text { font-size: 18px; }
    .logo-sub { display: none; }
    .header { padding: 10px 16px; }
    .header-right { gap: 8px; }
    .header-right .btn { padding: 6px 12px; font-size: 12px; }
}

/* ====== 小平板：768-1024px ====== */
@media (max-width: 1024px) {
    .header-right { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
    .header-right .btn { padding: 5px 10px; font-size: 11px; }
    .time-display { font-size: 14px; padding: 4px 8px; }
    .phase-indicator { font-size: 11px; padding: 4px 10px; }
    .data-source-badge { font-size: 10px; padding: 3px 8px; }
}

/* ====== 手机：≤768px - 核心改造 ====== */
@media (max-width: 768px) {
    /* Header */
    .header {
        flex-direction: column; align-items: stretch;
        padding: 8px 12px; gap: 8px;
    }
    .logo { justify-content: center; }
    .logo-icon { width: 32px; height: 32px; font-size: 14px; }
    .logo-text { font-size: 16px; }
    .header-right {
        display: grid; grid-template-columns: repeat(4, 1fr);
        gap: 6px; width: 100%;
    }
    .header-right .btn {
        padding: 8px 4px; font-size: 11px;
        text-align: center; justify-content: center;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* 时间和阶段 跨2列 */
    .time-display, .phase-indicator {
        grid-column: span 2; text-align: center; margin: 0;
    }
    .time-display { font-size: 16px; }
    .data-source-badge { grid-column: span 4; justify-content: center; }
    /* 用户菜单单独一行 */
    #jjlsUserBox { grid-column: span 4; justify-content: center; }

    /* 主容器：垂直堆叠 + tab切换 */
    .main-container {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr !important;
        height: calc(100vh - 200px);
        position: relative;
    }
    .panel-left, .panel-center, .panel-right {
        max-height: none !important; height: 100%;
        position: absolute; inset: 0;
        display: none;
    }
    .panel-left.mobile-active,
    .panel-center.mobile-active,
    .panel-right.mobile-active {
        display: flex !important;
    }
    /* 默认显示左侧（股票池） */
    .panel-left { display: flex; }

    /* 底部 Tab 栏（JS会注入） */
    .mobile-tabbar {
        position: fixed; bottom: 0; left: 0; right: 0;
        background: #1a1f2e; border-top: 1px solid #2d3748;
        display: flex; z-index: 100;
        padding: 0; padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-tabbar-item {
        flex: 1; padding: 10px 4px;
        text-align: center; cursor: pointer;
        color: #94a3b8; font-size: 11px;
        border-top: 2px solid transparent;
    }
    .mobile-tabbar-item.active {
        color: #ff4d4d; border-top-color: #ff4d4d;
        background: rgba(255,77,77,0.05);
    }
    .mobile-tabbar-item .mtab-icon {
        display: block; font-size: 18px; margin-bottom: 2px;
    }

    /* 给底部 tabbar 留空间 */
    body { padding-bottom: 60px; }
    .log-panel { display: none !important; }

    /* 左面板适配 */
    .panel-header { padding: 10px 12px; }
    .panel-title { font-size: 14px; }
    .filter-bar { padding: 8px 10px; gap: 4px; }
    .filter-bar label span { font-size: 12px; }
    .filter-bar input[type="number"] { width: 48px !important; padding: 3px 4px !important; font-size: 12px !important; }
    .stock-item { padding: 10px; }
    .stock-code { font-size: 13px; }
    .stock-name { font-size: 11px; }
    .stock-metrics { font-size: 11px; gap: 4px; }

    /* 中间图表 */
    .chart-container { padding: 10px; }
    .chart-title { font-size: 13px; }
    .chart-title > div:first-child { flex-direction: column; align-items: flex-start; gap: 4px; }
    .chart-type-tabs .btn { padding: 4px 8px; font-size: 11px; }
    .chart-legend { gap: 8px; font-size: 10px; flex-wrap: wrap; }
    .chart-area { min-height: 280px; height: calc(100vh - 360px) !important; }

    /* 右侧筛选结果 */
    .result-tabs { overflow-x: auto; }
    .result-tab { padding: 10px 6px; font-size: 12px; }
    .tab-count { font-size: 10px; padding: 1px 4px; min-width: 16px; }
    .result-card { padding: 10px; }
    .result-code-text { font-size: 15px; }
    .result-name-text { font-size: 13px; }
    .score-number { font-size: 22px; }
    .result-dims-compact { gap: 4px; }
    .dim-item { padding: 4px 2px; }
    .dim-label { font-size: 10px; }
    .dim-val { font-size: 13px; }
    .rule-tag-compact { font-size: 11px; padding: 3px 6px; }
    .rule-text-compact { max-width: 110px; }

    /* 弹窗 */
    .modal { width: 95%; max-height: 80vh; }
    .modal-header { padding: 12px 16px; }
    .modal-body { padding: 12px 16px; }
    .form-grid { grid-template-columns: 1fr; gap: 10px; }
    .setting-item { flex-direction: column; align-items: flex-start; gap: 6px; }
    .setting-control { width: 100%; justify-content: space-between; }
    input[type="range"] { width: 100% !important; }
}

/* ====== 超小屏：≤375px (iPhone SE) ====== */
@media (max-width: 375px) {
    .header-right { grid-template-columns: repeat(2, 1fr); }
    .time-display, .phase-indicator { grid-column: span 1; }
    .data-source-badge, #jjlsUserBox { grid-column: span 2; }
    .chart-area { height: calc(100vh - 380px) !important; }
}

/* ====== 横屏适配 ====== */
@media (max-width: 900px) and (orientation: landscape) {
    .main-container { height: calc(100vh - 140px); }
    .chart-area { height: calc(100vh - 280px) !important; }
}
