﻿/* =========================================================================
 * Web3s Theme - assets/css/responsive.css
 * Mobile & Tablet Responsive + Mobile Bottom Navigation Bar
 * ========================================================================= */

/* Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  z-index: 9990;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-bar-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 0;
  transition: all 0.2s ease;
}
.mobile-bar-btn .dashicons, .mobile-bar-btn svg {
  font-size: 20px;
  width: 20px;
  height: 20px;
  margin-bottom: 2px;
}
.mobile-bar-btn.active, .mobile-bar-btn:hover {
  color: var(--primary, #e4342b);
}
.mobile-bar-call {
  color: #f97316;
}
/* Nhãn icon: không vỡ dòng khi nhiều icon */
.mobile-bar-btn > span:last-child {
  font-size: 10.5px;
  line-height: 1.2;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile Nav Drawer */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 86vw;
  height: 100%;
  background: #fff;
  z-index: 10000;
  box-sizing: border-box;
  box-shadow: 5px 0 25px rgba(0,0,0,0.15);
  transform: translateX(-100%);   /* Ẩn HẲN (không phụ thuộc chiều rộng/padding) */
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 20px;
}
.mobile-nav-drawer.open {
  transform: translateX(0);
}
/* ===== Drawer mobile: header + tiêu đề mục ===== */
.mobile-nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid #e2e8f0;
}
.mnav-logo img { max-height: 38px; width: auto; }
.mnav-logo strong { font-size: 16px; color: #1a1a2e; }
.mobile-nav-close {
  background: none; border: none; font-size: 30px; line-height: 1;
  cursor: pointer; color: #64748b; padding: 0 4px;
}
.mnav-title {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  color: #94a3b8; text-transform: uppercase; margin: 16px 0 4px;
}
.mobile-nav-section + .mobile-cat-list { margin-top: 6px; }

/* ===== Menu chính (phân cấp accordion) ===== */
.mobile-nav-list, .mobile-nav-list .sub-menu {
  list-style: none; padding: 0; margin: 0;
}
.mobile-nav-list li { border-bottom: 1px solid #f1f5f9; position: relative; }
.mobile-nav-list li a {
  display: block; padding: 11px 40px 11px 2px; font-weight: 600; font-size: 15px; color: #1e293b;
}
.mobile-nav-list li a:hover { color: var(--primary, #e4342b); }
.mnav-sub-toggle {
  position: absolute; top: 4px; right: 0; width: 36px; height: 40px;
  background: none; border: none; cursor: pointer; color: #94a3b8;
}
.mnav-sub-toggle .dashicons { transition: transform .2s ease; }
.menu-item-has-children.open > .mnav-sub-toggle .dashicons { transform: rotate(180deg); color: var(--primary,#e4342b); }
.mobile-nav-list .sub-menu { display: none; padding-left: 14px; border-left: 2px solid #f1f5f9; margin: 0 0 6px; }
.menu-item-has-children.open > .sub-menu { display: block; }
.mobile-nav-list .sub-menu li { border-bottom: none; }
.mobile-nav-list .sub-menu li a { font-weight: 500; font-size: 14px; padding: 8px 2px; color: #475569; }

/* ===== Cây danh mục sản phẩm (phân cấp + thu gọn) ===== */
.mobile-cat-list { border-top: 2px solid #e2e8f0; margin-top: 14px; padding-top: 6px; }
.m-cat-tree { list-style: none; margin: 0; padding: 0; }
.m-cat-item { border-bottom: 1px solid #f1f5f9; }
.m-cat-row { display: flex; align-items: center; }
.m-cat-row a {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 2px; font-size: 14px; font-weight: 500; color: #1e293b;
}
.m-cat-row a:hover { color: var(--primary, #e4342b); }
.m-cat-count { flex: 0 0 auto; font-size: 11px; color: #94a3b8; background: #f1f5f9; border-radius: 20px; padding: 1px 8px; }
.m-cat-toggle {
  flex: 0 0 auto; width: 34px; height: 38px; background: none; border: none; cursor: pointer;
  color: #64748b; border-left: 1px solid #f1f5f9;
}
.m-cat-toggle .dashicons { transition: transform .2s ease; }
.m-cat-item.open > .m-cat-row .m-cat-toggle .dashicons { transform: rotate(45deg); color: var(--primary,#e4342b); }
/* Con: ẩn cho tới khi mở */
.m-cat-item > .m-cat-tree { display: none; padding-left: 14px; border-left: 2px solid #f1f5f9; margin: 0 0 4px; }
.m-cat-item.open > .m-cat-tree { display: block; }
.m-cat-item > .m-cat-tree .m-cat-row a { font-size: 13.5px; color: #475569; }

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9995;
}

/* Tablet: max-width 992px */
@media (max-width: 992px) {
  .header-main-inner {
    flex-wrap: wrap;
    gap: 15px;
  }
  .header-search {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .web3s-features-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .single-product-layout {
    grid-template-columns: 1fr;
  }
  .web3s-checkout-wrap {
    grid-template-columns: 1fr;
  }
  /* Mobile/tablet: tóm tắt đơn hiện TRƯỚC form, bỏ dính */
  .checkout-cart-summary { position: static !important; top: auto !important; order: 1 !important; }
  .checkout-form { order: 2 !important; }
}

/* Mobile: max-width 768px */
@media (max-width: 768px) {
  body {
    padding-bottom: 65px; /* space for mobile bottom bar */
  }
  .mobile-bottom-bar {
    display: flex;
  }
  .top-bar {
    display: none;
  }
  .header-bottom-nav {
    display: none;
  }
  .hamburger-btn {
    display: block;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .web3s-features-row {
    grid-template-columns: 1fr;
  }
  .taxonomy-layout {
    display: block;
  }
  .category-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    max-width: 86vw;
    height: 100%;
    background: #fff;
    z-index: 10000;
    box-sizing: border-box;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 5px 0 25px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .category-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: block;
    background: none;
    border: none;
    font-size: 26px;
    float: right;
    cursor: pointer;
  }
  .product-cta-buttons {
    flex-direction: column;
  }
}

/* =========================================================================
 * TỐI ƯU RESPONSIVE CHUYÊN NGHIỆP (bổ sung — media/typography/điện thoại nhỏ)
 * ========================================================================= */
/* Media co giãn + chống tràn ngang */
img, video, iframe, embed, object { max-width: 100%; height: auto; }
.entry-content table, .single-product-specs table, .product-excerpt table { display: block; overflow-x: auto; max-width: 100%; }
html, body { overflow-x: hidden; }
.entry-content { overflow-wrap: break-word; word-wrap: break-word; }

/* Tablet ≤ 992 */
@media (max-width: 992px) {
  h1 { font-size: 1.8rem; }
  .single-product-container h1 { font-size: 1.5rem; }
  .web3s-features-row { gap: 14px; }
}

/* Mobile ≤ 768 */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; line-height: 1.3; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }
  .container { padding-left: 14px; padding-right: 14px; }
  .header-logo img, .site-logo-img { max-height: 40px; width: auto; }
  .header-hotline .hotline-text { display: none; } /* mobile: chỉ hiện icon gọi */
  .product-card-title { font-size: 13px; }
  .product-card-actions .btn { padding: 8px 10px; font-size: 12px; }
  .footer-social-links { justify-content: flex-start; }
  .footer-copyright p { font-size: 12px; text-align: center; }
}

/* Điện thoại nhỏ ≤ 480 */
@media (max-width: 480px) {
  .product-grid-2, .product-grid-3, .product-grid-4, .product-grid-5, .product-grid-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  h1 { font-size: 1.3rem; }
  .single-product-layout { gap: 18px; }
  .product-cta-buttons .btn { width: 100%; }
  .live-search-input { font-size: 14px; }
}

/* =========================================================================
 * Panel bottom-sheet: Tin tức mới / Sản phẩm mới (mở từ thanh dưới mobile)
 * ========================================================================= */
/* Chieu cao thanh duoi (dung de panel chua cho thanh) */
:root { --mb-bar-h: 60px; }
body.mb-panel-active { overflow: hidden; }
/* Backdrop chi phu vung TREN thanh duoi -> thanh bottom bar van hien & bam duoc */
body.mb-panel-active::after {
  content: ''; position: fixed; left: 0; right: 0; top: 0;
  bottom: calc(var(--mb-bar-h) + env(safe-area-inset-bottom, 0px));
  background: rgba(0,0,0,0.45); z-index: 9991;
}
/* Panel mo FULL tu day len sat dinh, dung ngay tren thanh bottom bar */
.mb-panel {
  position: fixed; left: 0; right: 0;
  top: 0;
  bottom: calc(var(--mb-bar-h) + env(safe-area-inset-bottom, 0px));
  background: #fff; z-index: 9992;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
}
.mb-panel.open { transform: translateY(0); }
/* Thanh bottom bar luon noi tren cung khi panel mo */
.mobile-bottom-bar { z-index: 9993; }
.mb-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #eee; flex: 0 0 auto; background: #fff; position: sticky; top: 0; }
.mb-panel-head strong { font-size: 16px; }
.mb-panel-close { background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: #64748b; padding: 0 4px; }
.mb-panel-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
.mb-panel-item { display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #f1f5f9; text-decoration: none; color: #1e293b; align-items: center; }
.mb-panel-thumb { width: 60px; height: 60px; flex: 0 0 auto; border-radius: 8px; overflow: hidden; background: #f1f5f9; }
.mb-panel-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mb-noimg { display: block; width: 100%; height: 100%; background: #e2e8f0; }
.mb-panel-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mb-panel-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.mb-panel-meta { font-size: 12px; color: var(--primary, #e4342b); font-weight: 700; }
.mb-panel-meta .price { color: var(--primary, #e4342b); }
/* Panel + thanh dưới chỉ dùng cho mobile; ẩn hẳn trên desktop */
@media (min-width: 769px) { .mb-panel, body.mb-panel-active::after { display: none !important; } }

/* =========================================================================
 * HEADER MOBILE GỌN (logo/menu/cart/hotline tùy chọn vị trí)
 * ========================================================================= */
.mobile-header, .mobile-header-search { display: none; }

@media (max-width: 768px) {
  /* Thay header desktop bằng mobile-header gọn */
  .header-main { display: none; }
  .header-bottom-nav { display: none; }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    min-height: 52px;
    background: #fff;
    box-sizing: border-box;
  }
  .mh-side { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
  .mh-side-right { justify-content: flex-end; }
  .mh-logo { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; overflow: hidden; }
  .mobile-header.mh-logo-left   .mh-logo { justify-content: flex-start; }
  .mobile-header.mh-logo-center .mh-logo { justify-content: center; }
  .mobile-header.mh-logo-right  .mh-logo { justify-content: flex-end; }
  .mh-logo a { display: inline-flex; align-items: center; max-width: 100%; }
  .mh-logo img { max-height: 40px; width: auto; max-width: 100%; object-fit: contain; }
  .mh-site-name {
    font-weight: 700; font-size: 16px; color: var(--secondary, #1a1a2e);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  }
  .mh-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer;
    color: var(--text-color, #2b3445);
    padding: 6px; position: relative; text-decoration: none; line-height: 1;
  }
  .mh-btn .dashicons { font-size: 23px; width: 23px; height: 23px; }
  .mh-hotline { color: var(--primary, #e4342b); gap: 3px; }
  .mh-hotline-num { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
  .mh-cart-badge {
    position: absolute; top: -2px; right: -2px;
    background: var(--primary, #e4342b); color: #fff;
    font-size: 9.5px; font-weight: 700; line-height: 1;
    min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 1.5px #fff;
  }
  .mobile-header-search {
    display: block; padding: 0 12px 10px; background: #fff;
    box-sizing: border-box;
  }
  .mobile-header-search .live-search-wrap { width: 100%; }
  .mobile-header-search .live-search-form { display: flex; width: 100%; }
  .mobile-header-search .live-search-input { flex: 1 1 auto; min-width: 0; }
  /* Ẩn nút hamburger cũ trong header-main (đã có nút ở mobile-header) */
  .header-actions .hamburger-btn { display: none; }
}

/* Điện thoại rất nhỏ: rút gọn số hotline nếu quá chật */
@media (max-width: 360px) {
  .mh-hotline-num { display: none; }  /* chỉ còn icon gọi để không tràn */
  .mh-btn { padding: 5px; }
}

/* =========================================================================
 * FIX FOOTER TRÀN KHUNG + tối ưu footer mobile
 * ========================================================================= */
.site-footer, .site-footer * { box-sizing: border-box; }
/* Footer container ĐI THEO độ rộng site (--container-w). KHÔNG ép 100% ở đây
   nếu không sẽ đè tùy chọn "Độ rộng nội dung site" trong admin. Full-width là preset riêng. */
.site-footer .container { overflow: hidden; }
.footer-grid > .footer-col { min-width: 0; }               /* cho phép co lại, không đẩy tràn */
.footer-nav-list, .footer-contact-list { list-style: none; padding: 0; margin: 0; }
.footer-nav-list a, .footer-contact-list a,
.footer-about .footer-desc, .footer-col p, .footer-col li {
  overflow-wrap: break-word; word-break: break-word;      /* email/URL/địa chỉ dài không tràn */
}
.footer-contact-list li { display: flex; gap: 8px; align-items: flex-start; }
.footer-contact-list li .dashicons { flex: 0 0 auto; margin-top: 2px; }

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
  .footer-col { text-align: left; }
  .footer-social-links { flex-wrap: wrap; }
  .footer-logo { max-height: 46px; width: auto; }
}

/* =========================================================================
 * TỐI ƯU RESPONSIVE TOÀN DIỆN: ảnh / video / text / form
 * ========================================================================= */
/* Media: luôn co giãn, không tràn, giữ tỉ lệ */
img, svg, video, iframe, embed, object, figure { max-width: 100%; }
img { height: auto; }
figure { margin-left: 0; margin-right: 0; }
.entry-content img, .product-excerpt img, .single-product-specs img { height: auto; border-radius: 6px; }
/* Video/iframe nhúng giữ tỉ lệ 16:9, không tràn */
.entry-content iframe, .entry-content video,
.wp-block-embed iframe, .video-embed iframe {
  width: 100%; aspect-ratio: 16 / 9; height: auto;
}
/* Bảng cuộn ngang trong khung riêng, không đẩy trang */
.entry-content table, .single-product-specs table, .product-excerpt table,
.product-tabs table {
  display: block; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch;
}

/* Form: không tràn, chạm dễ, không auto-zoom iOS */
input, select, textarea, .form-control, button {
  max-width: 100%; box-sizing: border-box;
}
.form-control, .checkout-form input, .checkout-form textarea, .checkout-form select {
  width: 100%;
}
@media (max-width: 768px) {
  /* iOS zoom khi focus nếu font < 16px -> ép 16px cho input mobile */
  input, select, textarea, .form-control, .live-search-input { font-size: 16px !important; }
  .checkout-form .form-row { margin-bottom: 12px; }
  .coupon-row { flex-wrap: wrap; }
  .coupon-row #btn-apply-coupon { width: 100%; }
  .payment-option { display: flex; align-items: flex-start; gap: 8px; }
  .web3s-checkout-wrap { gap: 20px; }
  .checkout-items-table { font-size: 13px; }
}

/* Thanh bottom bar: chống tràn khi nhiều icon */
.mobile-bottom-bar { overflow: hidden; }
.mobile-bar-btn { min-width: 0; }
