/* =========================================================
   79FOOD – mobile.css : trải nghiệm mua hàng trên điện thoại (iOS Safari & Android Chrome)
   Thanh điều hướng dưới · thanh mua cố định · bảng chọn phân loại trượt lên · thanh thanh toán
   ========================================================= */

/* ---------- Chung (mọi màn hình) ---------- */
html { -webkit-tap-highlight-color: transparent; }
a, button, .variant, .tab, summary { touch-action: manipulation; }
.pk-head, .m-gallery, .m-gal-n, .m-tabbar, .m-buybar, .m-actionbar { display: none; }

.pk-qty { margin-bottom: 18px; }
.pk-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pk-actions .btn { flex: 1; min-width: 150px; }
.pk-more { font-size: 14px; }

.co-more { margin: 2px 0 10px; }
.co-more summary { cursor: pointer; color: var(--sea-700); font-weight: 600; font-size: 14px; padding: 6px 0; list-style: none; }
.co-more summary::-webkit-details-marker { display: none; }
.co-more summary::before { content: "+ "; }
.co-more[open] summary::before { content: "− "; }
.co-remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 4px; cursor: pointer; }
.co-remember input { width: 18px; height: 18px; accent-color: var(--sun); }

.cart-count.bump { animation: cc-bump .5s ease; }
@keyframes cc-bump { 0% { transform: scale(1); } 35% { transform: scale(1.5); } 100% { transform: scale(1); } }

/* =========================================================
   ĐIỆN THOẠI & MÁY TÍNH BẢNG NHỎ
   ========================================================= */
@media (max-width: 768px) {
  :root { --bar-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--bar-h) + var(--safe-b)); }
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

  /* iOS tự phóng to khi ô nhập < 16px → giữ đúng 16px */
  input, select, textarea, .input, .search input { font-size: 16px !important; }
  .input { height: 48px; }

  /* ---------- Thanh điều hướng dưới (như app sàn TMĐT) ---------- */
  .m-tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(23, 80, 122, .08);
    padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px); }
  .m-tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--bar-h); font-size: 11px; font-weight: 600; color: var(--muted); }
  .m-tabbar .icon { width: 23px; height: 23px; }
  .m-tabbar a.on { color: var(--sun); }
  .m-tabbar a.on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--sun); }
  .m-tabbar .cart-count { top: 4px; right: calc(50% - 24px); min-width: 19px; height: 19px; font-size: 10.5px; }

  /* Zalo/Gọi đã nằm trong thanh dưới → chỉ giữ nút lên đầu trang */
  .float { right: 12px; bottom: calc(var(--bar-h) + 14px + var(--safe-b)); }
  .float .f-zalo, .float .f-phone { display: none; }
  .toast { bottom: calc(var(--bar-h) + 14px + var(--safe-b)); width: calc(100vw - 32px); justify-content: space-between; }

  /* ---------- Header: giỏ hàng đã có ở thanh dưới → bỏ nút giỏ trên cùng; cuộn xuống chỉ còn ô tìm kiếm ---------- */
  .header-main > .header-actions { display: none; }
  .header-main { gap: 10px 12px; }
  body.m-compact .header-main > .burger,
  body.m-compact .header-main > .logo,
  body.m-compact .header-main > .header-actions { display: none; }
  body.m-compact .header-main { padding: 8px 0; }
  body.m-compact .noel-garland { display: none; }

  /* ---------- Hàng sản phẩm vuốt ngang ---------- */
  .grid.h-scroll { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 44%; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none; gap: 10px; margin: 0 -16px; padding: 2px 16px 8px; scroll-padding-left: 16px; }
  .grid.h-scroll::-webkit-scrollbar { display: none; }
  .grid.h-scroll > * { scroll-snap-align: start; }
  .section { padding: 22px 0; }

  /* ---------- Banner trang chủ gọn hơn ---------- */
  .slide-hero { padding: 20px 18px 30px; }
  .slide-hero p { font-size: 14px; margin-bottom: 16px; }
  .slide-hero .hero-cta { flex-wrap: nowrap; gap: 10px; }
  .slide-hero .hero-cta .btn-lg { flex: 1; height: 46px; font-size: 15px; padding: 0 14px; }

  /* ---------- Bảng chọn phân loại trượt từ dưới lên ---------- */
  .modal { place-items: end center; padding: 0; }
  .modal-box { width: 100%; max-height: 88vh; grid-template-columns: 1fr; border-radius: 20px 20px 0 0;
    transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); padding-bottom: var(--safe-b); }
  .modal.open .modal-box { transform: none; }
  .modal-box > img, .modal-box h3, .modal-box .mb > .pd-price { display: none; }
  .modal-box .mb { padding: 16px 16px 10px; }
  .modal-box .mb::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto 12px; }
  .pk-head { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; padding-right: 40px; }
  .pk-head img { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); flex: none; }
  .pk-price { color: var(--coral); font-size: 22px; font-weight: 800; line-height: 1.2; }
  .pk-price s { color: var(--muted); font-size: 13px; font-weight: 400; }
  .pk-sel { font-size: 13px; color: var(--muted); margin-top: 4px; }
  .modal-box .variants { max-height: 34vh; overflow-y: auto; }
  .variant { min-height: 44px; }
  .pk-qty { display: flex; align-items: center; justify-content: space-between; }
  .pk-qty .opt-label { margin: 0; }
  .pk-actions { flex-wrap: nowrap; }
  .pk-actions .btn { min-width: 0; height: 50px; font-size: 15px; padding: 0 12px; }
  .pk-more { display: flex; justify-content: center; }

  /* ---------- Trang chi tiết sản phẩm ---------- */
  body[data-page="product"] .m-tabbar,
  body[data-page="cart"] .m-tabbar,
  body[data-page="checkout"] .m-tabbar { display: none; }
  body[data-page="product"] .page-head { padding-top: 10px; padding-bottom: 0; }
  body[data-page="product"] .crumbs { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  body[data-page="product"] .crumbs > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pd { padding: 0 0 6px; margin-top: 8px; overflow: hidden; gap: 14px; }
  .pd .pd-info { padding: 0 16px; }
  .pd-media { position: relative; }
  .pd-media .gallery-main, .pd-media .thumbs { display: none; }
  .m-gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; background: var(--sand); }
  .m-gallery::-webkit-scrollbar { display: none; }
  .m-gallery img { flex: 0 0 100%; width: 100%; aspect-ratio: 1; object-fit: cover; scroll-snap-align: center; }
  .m-gal-n { display: block; position: absolute; right: 12px; bottom: 12px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
  .pd-info h1 { font-size: 19px; line-height: 1.35; }
  .pd-price { padding: 10px 14px; margin-bottom: 14px; }
  .pd-price b { font-size: 24px; }
  .pd-info .pd-actions, .pd-info .pd-qty-label { display: none; }
  .pd-perks { font-size: 14px; }

  .m-buybar { display: grid; grid-template-columns: 54px 62px 1fr 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(23, 80, 122, .1);
    padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px); }
  .m-buybar > * { height: var(--bar-h); }
  .bb-ic { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--sea-700); border-right: 1px solid var(--line); }
  .bb-ic .icon { width: 22px; height: 22px; }
  .bb-ic .cart-count { top: 4px; right: 8px; min-width: 18px; height: 18px; font-size: 10px; }
  .bb-add, .bb-buy { border: 0; color: #fff; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.2; }
  .bb-add { background: var(--sea-700); }
  .bb-add .icon { width: 19px; height: 19px; }
  .bb-buy { background: var(--sun); }
  .bb-buy small { font-size: 12px; font-weight: 600; opacity: .95; }
  body[data-page="product"] .float, body[data-page="cart"] .float, body[data-page="checkout"] .float { bottom: calc(var(--bar-h) + 24px + var(--safe-b)); }

  /* ---------- Giỏ hàng & thanh toán: thanh tổng tiền cố định ---------- */
  .m-actionbar { display: flex; align-items: center; gap: 12px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(23, 80, 122, .1);
    padding: 9px max(16px, env(safe-area-inset-right, 0px)) calc(9px + var(--safe-b)) max(16px, env(safe-area-inset-left, 0px)); }
  .ab-sum { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .ab-sum small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ab-sum b { color: var(--coral); font-size: 20px; }
  .m-actionbar .btn { height: 48px; padding: 0 24px; font-size: 16px; flex: none; }
  body[data-page="cart"], body[data-page="checkout"] { padding-bottom: calc(70px + var(--safe-b)); }
  #co-form .panel { position: static !important; }
  #co-submit { display: none; }
  .cart-layout .panel .btn-lg[href="checkout.html"] { display: none; }

  /* ---------- Trang trí Noel không đè thanh dưới ---------- */
  .noel-hi { bottom: calc(var(--bar-h) + 12px + var(--safe-b)) !important; width: calc(100vw - 32px) !important; }
}
