/* ===== Điện thoại & máy tính bảng nhỏ — theo chuẩn ứng dụng di động:
   vùng chạm ≥ 44px, chữ ô nhập 16px (iOS không tự phóng to), bảng → thẻ, modal → bottom sheet. ===== */

.pm-mobile-only { display: none; }

/* Chip thông tin (trang lớp) */
.pm-meta-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pm-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--pm-border); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--pm-muted); }
.pm-chip b { color: var(--pm-text); font-weight: 600; }
.pm-chip-teacher { background: var(--pm-navy-soft); border-color: #d3dceb; color: var(--pm-navy); }
.pm-chip-teacher b { color: var(--pm-navy); }

/* Thanh công cụ / nút đầu trang */
.pm-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pm-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pm-toolbar form { margin: 0; }
.pm-selectall { align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--pm-navy); margin-bottom: 10px; }
.pm-selectall .form-check-input { width: 22px; height: 22px; margin: 0; }
.pm-swipe-hint { font-size: 13px; color: var(--pm-muted); text-align: center; margin: 0 0 8px; }

@media (max-width: 640px) {
  .pm-mobile-only { display: block; }
  label.pm-mobile-only { display: flex; }

  /* --- Tiêu đề trang --- */
  .pm-page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .pm-page-head h1 { font-size: 22px; }
  .pm-page-head > :not(:first-child) { width: 100%; }
  .pm-page-head > .btn { width: 100%; }
  .pm-page-head > .d-flex, .pm-head-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
  .pm-head-actions form, .pm-page-head > .d-flex form { display: block; margin: 0; }
  .pm-head-actions .btn, .pm-page-head > .d-flex .btn { width: 100%; white-space: nowrap; padding: 8px 6px; font-size: 14px; }

  /* --- Vùng chạm --- */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; }
  .btn-sm { min-height: 40px; font-size: 14px; }
  .form-control, .form-select { min-height: 44px; font-size: 16px; }
  textarea.form-control { min-height: 120px; }
  .form-select-sm { min-height: 44px; font-size: 15px; }
  .form-check-input { width: 22px; height: 22px; }

  /* --- Thanh công cụ: lưới 2 cột, nút rộng hết --- */
  .pm-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pm-toolbar > .btn { width: 100%; }
  .pm-toolbar-wide { grid-column: 1 / -1; }

  /* --- Tabs: cuộn ngang, cao 44px --- */
  .pm-tabs { margin-left: -16px; margin-right: -16px; padding: 0 16px; scrollbar-width: none; }
  .pm-tabs::-webkit-scrollbar { display: none; }
  .pm-tabs button { min-height: 44px; padding: 10px 12px; font-size: 14px; }

  /* --- Bảng → thẻ --- */
  .pm-table-wrap:has(> .pm-cards) { border: 0; background: transparent; overflow: visible; }
  .pm-cards, .pm-cards tbody, .pm-cards tr, .pm-cards td { display: block; width: 100%; }
  .pm-cards thead { display: none; }
  .pm-cards tbody tr { display: flex; flex-direction: column; }
  .pm-cards tr {
    position: relative; background: #fff; border: 1px solid var(--pm-border); border-radius: 14px;
    padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(19, 41, 75, .04);
  }
  .pm-cards tr:hover td { background: transparent; }
  .pm-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: 0; padding: 6px 0; font-size: 14px; text-align: right; min-height: 0;
  }
  .pm-cards td::before { content: attr(data-label); color: var(--pm-muted); font-size: 13px; font-weight: 500; text-align: left; flex-shrink: 0; }
  .pm-cards td:empty, .pm-cards td.pm-td-empty, .pm-cards td.pm-hide-sm { display: none; }
  .pm-cards td.num { text-align: right; }

  /* Dòng tiêu đề thẻ */
  .pm-cards td.pm-c-title { order: -1; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px; text-align: left; font-size: 16px; padding: 0 36px 8px 0; margin-bottom: 4px; border-bottom: 1px solid var(--pm-border); }
  .pm-cards td.pm-c-title::before { display: none; }
  .pm-cards td.pm-c-title > a > b, .pm-cards td.pm-c-title > b { white-space: normal; }
  .pm-cards td.pm-c-title > div { width: 100%; }

  /* Ô chọn ở góc phải trên */
  .pm-cards td.pm-c-check { position: absolute; top: 10px; right: 10px; width: auto; padding: 0; }
  .pm-cards td.pm-c-check::before { display: none; }

  /* Hàng nút thao tác: các nút chia đều, rộng hết thẻ */
  .pm-cards td.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--pm-border); }
  .pm-cards td.actions::before { display: none; }
  .pm-cards td.actions > .btn, .pm-cards td.actions > form { flex: 1 1 0; min-width: 0; margin: 0; }
  .pm-cards td.actions > form .btn { width: 100%; }
  .pm-cards td.actions > .pm-badge { margin-left: auto; }

  .pm-cards tr.pm-empty-row { text-align: center; }
  .pm-cards tr.pm-empty-row td { justify-content: center; text-align: center; }
  .pm-cards tr.pm-empty-row td::before { display: none; }

  /* Bảng ma trận vẫn cuộn ngang, cột tên dính trái + bóng đổ báo còn nội dung */
  .pm-matrix .pm-sticky-col { box-shadow: 4px 0 6px -4px rgba(19, 41, 75, .25); max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .pm-matrix th, .pm-matrix td { padding: 10px 8px; }
  .pm-matrix .pm-score { min-width: 44px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; }

  /* --- Modal → bottom sheet --- */
  .pm-modal { align-items: flex-end; padding: 0; }
  .pm-modal-box, .pm-modal-box.wide {
    max-width: none; width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
    animation: pm-sheet-up .2s ease-out;
  }
  .pm-modal-box::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: #d0d5dd; margin: -8px auto 12px; }
  .pm-modal-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: #fff; margin: 16px -16px calc(-16px - env(safe-area-inset-bottom)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--pm-border); }
  .pm-modal-actions .btn { flex: 1; }
  .pm-slips { grid-template-columns: 1fr; }

  /* --- Thẻ, lưới --- */
  .pm-card { padding: 16px; }
  .pm-grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .pm-stat b { font-size: 24px; }
  .pm-grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pm-grid-4.pm-topic-stats { grid-template-columns: 1fr; gap: 14px; }
  .pm-stat { padding: 14px 16px; }

  /* --- Học sinh: đề thi + chủ đề --- */
  .pm-exam-grid { gap: 8px; }
  .pm-exam-row {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "num info act" "num score act";
    align-items: center; column-gap: 12px; row-gap: 2px; padding: 10px 12px;
  }
  .pm-exam-row .pm-exam-num { grid-area: num; width: 40px; height: 40px; }
  .pm-exam-row .pm-exam-info { grid-area: info; }
  .pm-exam-row .pm-score { grid-area: score; justify-self: start; font-size: 13px; padding: 1px 8px; }
  .pm-exam-row form { grid-area: act; margin: 0; }
  .pm-exam-row form .btn { min-width: 92px; min-height: 44px; }
  .pm-title-full { display: none; }
  .pm-title-short { display: inline; }
  .pm-round-title { margin: 8px 0 6px; }
  .pm-topic form .btn { min-height: 44px; }
  .pm-topic { padding: 14px; gap: 8px; }
  .pm-topic > p { display: none; }
  .pm-topic-icon { width: 40px; height: 40px; font-size: 21px; }
  .pm-topic:hover { transform: none; }
  .pm-resume { flex-wrap: nowrap; padding: 12px; }
  .pm-resume > div { min-width: 0; }
  .pm-resume .btn { flex-shrink: 0; white-space: nowrap; }

  /* Trang kết quả: nút xếp dọc, rộng hết */
  .pm-result-hero { padding: 20px 16px; }
  .pm-result-actions { flex-direction: column; align-items: stretch; }
  .pm-result-actions .btn, .pm-result-actions form, .pm-result-actions form .btn { width: 100%; display: flex; }

  /* Dropdown điện thoại: link cao 48px */
  .pm-dd-menu a, .pm-dd-menu button { min-height: 48px; display: flex; align-items: center; font-size: 15px; }
}

@keyframes pm-sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
