/* ============================================================
   Tinh chỉnh mobile / tablet cho các trang quản trị nhúng (Thú cưng, Shop, Hệ thống, Tình yêu, Thông tin)
   Nạp SAU style nội tuyến của từng trang.
   ============================================================ */

html { -webkit-text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); }

/* Tablet: lưới thẻ 2 cột, bớt lề */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)) !important; gap: 12px !important; }
}

@media (max-width: 720px) {
  /* Hàng tab: 1 dòng cuộn ngang, mờ hai đầu gợi ý còn nội dung, mục tiêu bấm ≥ 44px */
  .tabs {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity;
    margin: 0 -12px; padding: 4px 12px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap; min-height: 44px; padding: 10px 16px !important; display: inline-flex; align-items: center; }
  .bar button.chip { min-height: 40px; padding: 8px 14px; }

  /* Ô nhập đủ lớn, không bị iOS tự phóng to khi chạm */
  input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea { font-size: 16px !important; min-height: 44px; }
  button, .btns button, .up { min-height: 44px; }
  .btns { flex-wrap: wrap; gap: 8px; }

  /* Form 1 cột (riêng cặp giá Rcoin/Gems trong thẻ vật phẩm giữ 2 cột vì ngắn) */
  .f.row2, .add .row2, .panel .row2, .panel.f .row2, .row3 { grid-template-columns: 1fr !important; }
  .it .row2 { grid-template-columns: 1fr 1fr !important; }
  .colors { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .grid { grid-template-columns: 1fr !important; }
  .it .btns { display: grid; grid-template-columns: 1fr 1fr; }
  .it .btns .primary { grid-column: 1 / -1; }

  /* Bảng dữ liệu: cuộn ngang thay vì bóp méo */
  table.t { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  table.t td input, table.t td select { min-width: 110px; }

  /* Thông báo nổi nằm trên thanh Lưu, không đè nội dung */
  .toast, .msg { bottom: calc(88px + env(safe-area-inset-bottom)) !important; max-width: calc(100vw - 28px); }
  .msg { left: 14px !important; right: 14px !important; transform: none !important; text-align: center; }
}

@media (max-width: 420px) {
  .stat b { font-size: 20px; }
  .panel { padding: 12px !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
