/* ============================================================
   responsive.css — 全站多设备自适应（平板 / 多媒体教学一体机 / 手机）
   ------------------------------------------------------------
   设计原则：
   1) 统一断点：大屏/一体机 (≥1600) · 平板 (768~1599) · 手机 (<768) · 小屏 (<480)
   2) 触摸优先：所有 pointer:coarse 设备（平板、一体机、手机）触控目标 ≥44px，
      关闭 hover 位移粘滞，禁止双击缩放
   3) 顶部导航在窄屏折叠为汉堡抽屉，避免横向滚动溢出被切掉链接
   4) 表格在窄屏可横向滚动，避免撑破页面
   本文件在 page-theme.css 之后引入，相同特异性下覆盖 style.css 的零散规则。
   ============================================================ */

/* ============ 顶部导航：汉堡按钮（默认隐藏，窄屏显示） ============ */
.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    touch-action: manipulation;
}
.nav-toggle:hover { background: var(--gray-100); }
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
    content: "";
    position: absolute;
    left: 11px;
    width: 22px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: transform 0.25s ease, background 0.2s ease, top 0.2s ease;
}
.nav-toggle-bar { top: 21px; }
.nav-toggle-bar::before { top: -7px; }
.nav-toggle-bar::after  { top: 7px; }
/* 展开时变成 ✕ */
.navbar.nav-open .nav-toggle-bar { background: transparent; }
.navbar.nav-open .nav-toggle-bar::before { top: 0; transform: rotate(45deg); }
.navbar.nav-open .nav-toggle-bar::after  { top: 0; transform: rotate(-45deg); }

/* ============ 大屏 / 多媒体教学一体机（横屏大尺寸，远处观看 + 触摸） ============ */
@media (min-width: 1600px) {
    html { font-size: 17px; }                 /* 整体字号放大，适合远距离观看 */
    body { line-height: 1.6; }
    .main-content { max-width: 1600px; padding: 44px 56px; }
    .nav-container { max-width: 1600px; }
    .navbar { font-size: 15px; }
    .page-header h1 { font-size: 30px; }
    /* 一体机多为触摸，行高/间距宽松由 pointer:coarse 段统一处理 */
}

/* ============ 平板横向（768~1599）：维持现状，仅微调导航不溢出 ============ */
/* style.css 的 1100 段已缩小导航，这里补一条让 1024~1100 区间也稳定 */
@media (max-width: 1100px) and (min-width: 901px) {
    .nav-container { padding: 0 10px; }
    .nav-link { padding: 5px 6px; font-size: 12px; }
    .nav-links {
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
}

/* ============ 窄屏（≤900）：导航与用户区同一排，导航在前、设置/退出在后，链接横向滚动 ============ */
@media (max-width: 900px) {
    .nav-toggle { display: none; }

    .nav-links {
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 2px;
        flex: 1 1 auto;
        min-width: 0;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        background: transparent;
        box-shadow: none;
        border-top: none;
        padding: 0;
        order: 1;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;        /* Firefox 隐藏滚动条 */
    }
    .nav-links::-webkit-scrollbar { display: none; }   /* WebKit 隐藏滚动条 */
    /* 兜底：即便被加了 nav-open 类也不折叠 */
    .navbar.nav-open .nav-links {
        max-height: none;
        overflow-y: visible;
        padding: 0;
    }
    .nav-link {
        width: auto;
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 7px 9px;
        font-size: 12.5px;
        text-align: center;
    }
    .nav-link.active { background: var(--primary-light); }

    /* 窄屏只保留角色徽章 + 退出/登录，姓名隐藏省空间；导航默认在设置/退出前面同一排 */
    .nav-user .user-info { display: none; }
    .nav-container { gap: 8px; flex-wrap: nowrap; }
    .nav-user { order: 2; margin-left: auto; gap: 4px; flex: 0 0 auto; }
    .nav-logo { flex: 0 0 auto; }
}

/* ============ 手机（<768）：表格横滚、字号与间距收敛 ============ */
@media (max-width: 768px) {
    /* 表格横向滚动兜底：避免窄屏被撑破 */
    .main-content table,
    .card table,
    .panel table,
    .table-responsive,
    .table-wrap {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .main-content table { border-collapse: collapse; }

    /* 页头操作按钮在手机上换行、占满，方便点按 */
    .pp-hero { flex-direction: column; align-items: flex-start; }
    .pp-hero-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
    .pp-hero-btn { flex: 1 1 auto; text-align: center; justify-content: center; }

    /* 学科/题型 chips 行在手机可横向滚动，避免换行挤成一团 */
    .pp-subject-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .pp-chips { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px;
                scrollbar-width: none; -ms-overflow-style: none; }
    .pp-chips::-webkit-scrollbar { display: none; }

    /* 筛选栏纵向堆叠 */
    .pp-filter { padding: 14px; }
    .pp-filter-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .pp-filter-row > * { width: 100%; }
    .pp-filter-select, .pp-filter input[type="text"], .pp-filter input[type="search"] {
        width: 100%;
    }

    /* 题目卡片操作区换行 */
    .q-actions, .question-actions { flex-wrap: wrap; gap: 8px; }
    .q-actions .btn, .question-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* 图片/公式不溢出 */
    img { max-width: 100%; height: auto; }

    /* ===== 手机端导航栏：与用户区同一排（导航在前、设置/退出在后），链接横向滚动 ===== */
    .nav-toggle { display: none !important; }
    .nav-container { flex-wrap: nowrap; }
    .nav-links {
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 2px;
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        background: transparent;
        box-shadow: none;
        border-top: none;
        padding: 0;
        order: 1;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;        /* Firefox 隐藏滚动条 */
    }
    .nav-links::-webkit-scrollbar { display: none; }   /* WebKit 隐藏滚动条 */
    /* 兜底：即便被加了 nav-open 类也不折叠 */
    .navbar.nav-open .nav-links {
        max-height: none;
        overflow-y: visible;
        padding: 0;
    }
    .nav-link {
        width: auto;
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 6px 8px;
        font-size: 12px;
        text-align: center;
    }
    .nav-user { order: 2; flex: 0 0 auto; }
    .nav-toggle { order: 3; }
}

/* ============ 小屏手机（<480）：进一步收敛 ============ */
@media (max-width: 480px) {
    .main-content { padding: 12px 8px; }
    .page-header h1 { font-size: 21px; }
    .pp-hero h1 { font-size: 22px; }
    .stat-number { font-size: 22px; }
    /* 双列统计卡在小屏更紧凑 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 10px; }
}

/* ============ 触摸设备（pointer:coarse）：触控目标 ≥44px，触摸优先 ============ */
@media (pointer: coarse) {
    .nav-link,
    .btn, .btn-sm, .btn-login,
    .pp-chip, .type-chip, .pp-hero-btn, .pp-pill, .chip,
    .filter-btn, .dropdown-item,
    .pagination a, .pagination button,
    .action-card,
    .table-actions a, .table-actions button,
    td a.btn, td button.btn, .pp-badge,
    .toolbar button, .nav-toggle {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    /* 关闭触摸设备的 hover 位移，避免「粘滞」错觉 */
    .btn:hover, .nav-link:hover, .pp-chip:hover, .pp-hero-btn:hover { transform: none !important; }
    /* 全局禁止双击缩放，提升触摸跟手度 */
    a, button, input, select, textarea, label { touch-action: manipulation; }
    /* 触摸设备去掉聚焦外发光（移动端不需要） */
    *:focus { outline: none; }
}

/* ============ 横屏手机/小平板（高度较矮时，避免导航+内容挤压） ============ */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar { position: static; }
    .nav-container { height: 48px; }
}
