/* ============================================================
   MOBILE FIX - SỬA LỖI UI MOBILE
   ⚠️ TẤT CẢ RULES ĐỀU NẰM TRONG @media max-width
   KHÔNG có bất kỳ style global nào ảnh hưởng PC (min-width >= 992px)
   ============================================================ */

/* ============================================================
   1. FIX: ẢNH LAZY LOAD - HIỂN THỊ ĐÚNG TRÊN MOBILE
   Vấn đề: img[loading="lazy"] { opacity:0 } trong layout-modern.css
   làm ảnh không hiện khi JS chậm hoặc tắt
   ============================================================ */
@media (max-width: 991.98px) {
  /* Đảm bảo ảnh product luôn thấy được dù lazy hay không */
  .product-image,
  .anic-category-card img,
  .category-swipe-wrapper img {
    opacity: 1 !important;
  }

  /* Fallback cho lazy images - show sau 0.5s để tránh flash */
  img[loading="lazy"] {
    opacity: 0;
    animation: imgFadeIn 0.1s ease 0.4s forwards;
  }
}

@keyframes imgFadeIn {
  to { opacity: 1; }
}

/* ============================================================
   2. FIX: HERO BANNER - TỐI ƯU CHO MÀN HÌNH NHỎ
   ============================================================ */
@media (max-width: 767.98px) {
  /* Giảm chiều cao hero banner xuống phù hợp mobile */
  .hero-banner-premium {
    height: 300px !important;
  }

  /* Text hero nhỏ hơn, fit màn hình */
  .hero-text-box h2 {
    font-size: 1.45rem !important;
    margin-bottom: 0.5rem !important;
  }

  .hero-text-box p.lead {
    font-size: 0.82rem !important;
    margin-bottom: 1rem !important;
    line-height: 1.5 !important;
  }

  /* Buttons hero nhỏ hơn, vẫn pill shape */
  .hero-btn {
    padding: 9px 18px !important;
    font-size: 12px !important;
    letter-spacing: 0.5px !important;
  }

  /* Flex wrap cho nút hero khi quá chật */
  .hero-text-box .d-flex.flex-wrap {
    gap: 0.5rem !important;
  }
}

@media (max-width: 400px) {
  .hero-banner-premium {
    height: 260px !important;
  }

  .hero-text-box h2 {
    font-size: 1.2rem !important;
  }

  .hero-text-box p.lead {
    display: none !important; /* Ẩn description trên màn rất nhỏ */
  }

  .hero-btn {
    padding: 8px 14px !important;
    font-size: 11px !important;
  }
}

/* ============================================================
    3. FIX: DANH MỤC NỔI BẬT - KHÔNG TRÀN NGANG
    Vấn đề: .anic-category-wrapper bị set width cố định gây tràn,
    item cuối bị cắt chữ và cắt card
    ============================================================ */
@media (max-width: 767.98px) {
  .category-swipe-wrapper {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 10px !important;
    padding: 6px 0 12px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    scroll-snap-type: x mandatory !important;
  }
  /* Đệm phải cho thanh cuộn ngang để item cuối không bị cắt */
  .category-swipe-wrapper::after {
    content: "";
    flex: 0 0 12px;
    min-width: 12px;
    height: 1px;
  }

  .category-swipe-wrapper::-webkit-scrollbar {
    display: none !important;
  }

  .anic-category-wrapper {
    flex: 0 0 auto !important;
    width: 110px !important;
    min-width: 96px !important;
    scroll-snap-align: start !important;
  }

  .anic-category-card {
    border-radius: 10px !important;
    overflow: hidden !important;
    width: 100% !important;
  }

  /* Ảnh category: giữ aspect-ratio để ảnh không bị méo */
  .anic-category-img-wrapper {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden;
  }

  .anic-category-img-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Text category: chống tràn + ellipsis */
  .category-swipe-wrapper .anic-category-card > div:last-child {
    font-size: 10px !important;
    padding: 8px 4px !important;
    min-height: 40px !important;
    overflow: hidden;
  }

  .category-swipe-wrapper .anic-category-card > div:last-child span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Responsive cho danh mục nổi bật - màn hình nhỏ hơn */
@media (max-width: 480px) {
  .anic-category-wrapper {
    width: 100px !important;
    min-width: 88px !important;
    scroll-snap-align: start;
  }
}

@media (max-width: 360px) {
  .anic-category-wrapper {
    width: 84px !important;
    min-width: 76px !important;
  }

  .category-swipe-wrapper .anic-category-card > div:last-child {
    font-size: 8px !important;
    min-height: 36px !important;
    padding: 6px 3px !important;
  }
}

/* ============================================================
    6. FIX: HEADER MOBILE - CÂN BẰNG LAYOUT
   ============================================================ */
@media (max-width: 767.98px) {
  /* Col hamburger menu: đủ vùng tap */
  .main-header .col-2 {
    display: flex;
    align-items: center;
    padding-right: 0;
  }

  /* Col logo: canh giữa đẹp hơn */
  .main-header .col-6 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  /* Col icons: canh phải gọn */
  .main-header .col-4 {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 0;
    gap: 4px !important;
  }

  /* Mobile search bar sát hơn */
  .mobile-search-wrapper {
    padding: 4px 0 6px !important;
  }

  /* Logo size */
  .main-logo {
    height: 34px !important;
    max-width: 140px;
    object-fit: contain;
  }
}

/* Fixed header trên mobile */
@media (max-width: 767.98px) {
  .main-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1020;
  }
  body {
    padding-top: 90px;
  }
}

@media (max-width: 360px) {
  .main-logo {
    height: 28px !important;
  }
  .btn-mobile-menu {
    font-size: 22px !important;
  }
}

/* ============================================================
   7. FIX: CATEGORY SWIPE - CUỘN NGANG MỀM MẠI
   (Các rule section 3 đã xử lý chính, section này bổ sung)
   ============================================================ */
@media (max-width: 767.98px) {
  .category-swipe-wrapper {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px !important;
  }

  .anic-category-card {
    border-radius: 10px !important;
    overflow: hidden;
  }

  /* Ảnh category: giữ nhất quán aspect-ratio */
  .anic-category-img-wrapper {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden;
  }

  /* Text category canh giữa */
  .category-swipe-wrapper .anic-category-card > div:last-child {
    font-size: 10px !important;
    padding: 6px 4px !important;
    min-height: 36px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .category-swipe-wrapper .anic-category-card > div:last-child span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 360px) {
  .category-swipe-wrapper .anic-category-card > div:last-child {
    font-size: 8px !important;
    padding: 4px 3px !important;
    min-height: 32px !important;
  }
}

/* ============================================================
   8. FIX: SEARCH BAR FILTER - KHÔNG BỊ VỠ LAYOUT
   ============================================================ */
@media (max-width: 767.98px) {
  /* Filter card padding nhỏ hơn */
  .card.shadow-sm.border-0.mb-5 {
    margin-bottom: 1rem !important;
    border-radius: 12px !important;
  }

  /* Select và button cạnh nhau gọn */
  .card .row.g-2 .col-7 .form-select,
  .card .row.g-2 .col-5 .btn {
    height: 38px;
    font-size: 13px !important;
    padding: 6px 10px !important;
  }

  /* Search input */
  .card .search-box input.form-control {
    height: 38px !important;
    font-size: 14px !important;
  }
}

/* ============================================================
    9. FIX: FOOTER MOBILE - ACCORDION, CONTACT LEFT, MAP BUTTON, PADDING
    ============================================================ */
@media (max-width: 768px) {
  .footer-premium {
    padding: 28px 0 140px !important;
  }

  /* --- Accordion: Danh Mục & Hỗ Trợ --- */
  .footer-accordion {
    text-align: left !important;
    margin-bottom: 0 !important;
  }

  .footer-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 14px 0;
    margin-bottom: 0 !important;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .footer-accordion-header:active {
    opacity: 0.7;
  }

  .footer-accordion-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 18px;
    font-weight: 300;
    color: #ECA91E;
    transition: transform 0.3s ease;
    line-height: 1;
  }

  .footer-accordion-icon.active {
    transform: rotate(45deg);
  }

  .footer-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.3s ease;
    padding: 0 0;
  }

  .footer-accordion-body.open {
    max-height: 300px;
    padding: 10px 0 14px;
  }

  .footer-accordion-body a {
    padding: 6px 0;
  }

  /* --- Liên hệ: căn trái --- */
  .footer-contact-col {
    margin-bottom: 0 !important;
  }

  .footer-contact-col h5 {
    text-align: left !important;
  }

  .footer-contact-info {
    align-items: flex-start !important;
    text-align: left !important;
    padding: 12px 0 8px;
  }

  .footer-contact-info a,
  .footer-contact-info div {
    width: 100%;
  }

  /* --- Ẩn Google Maps iframe trên mobile --- */
  .footer-map-desktop {
    display: none !important;
  }

  /* --- Nút bản đồ thay thế --- */
  .footer-map-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 90%;
    padding: 16px 20px;
    margin: 10px auto 6px;
    background: linear-gradient(135deg, #ECA91E, #D4950E);
    color: #1f1a0e !important;
    font-weight: 600;
    font-size: 15px;
    border: none;
    border-radius: 12px;
    text-decoration: none !important;
    box-shadow: 0 4px 15px rgba(236, 169, 30, 0.25);
    transition: all 0.3s ease;
    cursor: pointer;
    letter-spacing: 0.3px;
  }

  .footer-map-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(236, 169, 30, 0.15);
  }

  /* --- Copyright: dòng bản quyền --- */
  .footer-copyright {
    padding-top: 16px !important;
    margin-top: 16px !important;
  }

  /* Underline của h5 footer - canh trái cho accordion header */
  .footer-premium h5::after {
    left: 0 !important;
    transform: none !important;
  }

  /* Links footer */
  .footer-premium a.custom-hover:hover {
    transform: none !important;
  }
}

/* ============================================================
   10. FIX: FORM INPUTS - TRÁNH AUTO-ZOOM TRÊN IOS
   ============================================================ */
@media (max-width: 767.98px) {
  /* iOS tự zoom vào input có font-size < 16px */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
  }

  /* Nhưng giữ display compact */
  .search-input-v2 {
    font-size: 15px !important;
  }
}

/* ============================================================
   11. FIX: PRODUCT DETAIL - MODAL & CTA BUTTONS
   ============================================================ */
@media (max-width: 767.98px) {
  /* Nút quick-buy trong detail không bị style chồng lên */
  .btn-quick-buy,
  button.btn-quick-buy {
    border-radius: 30px !important;
    padding: 10px 20px !important;
    font-size: 13px !important;
    min-height: 42px !important;
  }

  /* Modal liên hệ vừa màn hình */
  #contactChoiceModal .modal-dialog {
    margin: 12px !important;
    max-width: calc(100vw - 24px) !important;
  }

  #contactChoiceModal .btn {
    padding: 12px 16px !important;
    font-size: 14px !important;
    min-height: 48px !important;
  }
}

/* ============================================================
   12. FIX: OVERFLOW TOÀN TRANG - TRÁNH HORIZONTAL SCROLL
   ============================================================ */
@media (max-width: 991.98px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* Container không được vượt viewport */
  .container,
  .container-fluid {
    max-width: 100% !important;
    overflow-x: hidden;
  }

  /* Hero banner container-fluid */
  .container-fluid.px-0 {
    overflow: hidden !important;
  }
}

/* ============================================================
    14. FIX: PAGINATION - GỌN TRÊN MÀN NHỎ
    ============================================================ */
@media (max-width: 480px) {
  .pagination .page-item .page-link {
    padding: 6px 10px !important;
    font-size: 12px !important;
    min-width: 34px;
    text-align: center;
  }
}

/* ============================================================
   15. FIX: OFFCANVAS MENU - KÍCH THƯỚC ĐÚNG
   ============================================================ */
@media (max-width: 991.98px) {
  #mobileMenuOffcanvas {
    width: min(300px, 82vw) !important;
  }

  /* List group items to hơn, dễ tap */
  #mobileMenuOffcanvas .list-group-item {
    padding: 13px 16px !important;
    font-size: 14px !important;
  }

  /* Collapse item có đủ tap area */
  #mobileMenuOffcanvas .mobile-category-item .d-flex a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  #mobileMenuOffcanvas button.btn.btn-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================================
   16. FIX TRIỆT ĐỂ: RESET GLOBAL OVERRIDES - CHỈ MOBILE
   Vấn đề: layout-modern.css set body { margin-bottom: 0 !important }
   và các style global khác gây conflict trên mobile
   ============================================================ */
@media (max-width: 991.98px) {
  /* Reset body margin-bottom đúng cho mobile */
  body {
    margin-bottom: 0 !important;
  }
}

/* ============================================================
   17. FIX: BUTTON OVERRIDE - KHÔNG LÀM HỎNG NÚT SẢN PHẨM
   Vấn đề: layout-modern.css @media (max-width: 767.98px) set
   .btn-primary, .btn-danger... { padding: 8px 18px; font-size: 12px }
   làm hỏng các nút pill nhỏ trong product card
   ============================================================ */
@media (max-width: 767.98px) {
  /* Reset nút trong product card về đúng pill shape */
  .product-card .btn-primary,
  .product-card .btn-danger,
  .product-card .btn-dark,
  .product-card .btn-quick-buy,
  .product-card button.btn,
  .product-body .btn {
    padding: 5px 10px !important;
    font-size: 0.7rem !important;
    border-radius: 40px !important;
    min-height: 32px !important;
    line-height: 1.2 !important;
  }

  /* Các nút chính (checkout, submit) vẫn giữ size to */
  .btn-checkout,
  .btn-lg.btn-danger,
  .btn-lg.btn-primary,
  .btn-payment,
  button[type="submit"].btn-primary {
    padding: 12px 20px !important;
    font-size: 14px !important;
    border-radius: 12px !important;
    min-height: 44px !important;
  }
}

/* ============================================================
   18. FIX: BREADCRUMB - KHÔNG BỊ TRÀN MÀN HÌNH NHỎ
   ============================================================ */
@media (max-width: 575.98px) {
  .breadcrumb {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 10px !important;
    gap: 2px !important;
  }

  .breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .breadcrumb .breadcrumb-item {
    white-space: nowrap !important;
    font-size: 11px !important;
  }

  .breadcrumb .breadcrumb-item.active {
    max-width: 130px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    display: inline-block !important;
  }

  .breadcrumb .breadcrumb-item a {
    font-size: 11px !important;
  }
}

/* ============================================================
   19. FIX: MAIN CONTENT - THOÁNG HƠN, KHÔNG TRẮNG QUÁ NHIỀU
   ============================================================ */
@media (max-width: 767.98px) {
  main[role="main"].container.my-5 {
    margin-top: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .container.mt-5.mb-5 {
    margin-top: 0.75rem !important;
    margin-bottom: 1rem !important;
  }
}

/* ============================================================
   20. FIX: HEADER COLUMNS - CÂN CHỈNH LINH HOẠT MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
  .main-header .col-2 {
    flex: 0 0 auto;
    width: auto !important;
    padding-right: 4px;
  }

  .main-header .col-6 {
    flex: 1 1 auto !important;
    width: auto !important;
  }

  .main-header .col-4 {
    flex: 0 0 auto;
    width: auto !important;
    padding-left: 4px;
  }

  .main-header .gap-3 {
    gap: 6px !important;
  }
}

/* ============================================================
    21. FIX: PRODUCT CARD TRONG GRID - ĐẸP, 2 CỘT
    SỬA: Gỡ height:auto trên product-image (mâu thuẫn với aspect-ratio 1/1 của product_list.css)
   ============================================================ */
@media (max-width: 767.98px) {
  .product-card {
    height: 100% !important;
  }

  .product-image {
    width: 100% !important;
    /* Giữ aspect-ratio từ product_list.css, KHÔNG ghi đè height:auto */
    max-width: 100% !important;
    object-fit: contain !important;
  }

  .product-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
  }

  .product-price {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* ============================================================
   22. FIX: NỘI DUNE ẢNH - KHÔNG TRÀN NGANG
   ============================================================ */
@media (max-width: 767.98px) {
  .description-wrapper img,
  .product-detail-content img,
  .content-page img {
    max-width: 100% !important;
    height: auto !important;
  }

  .description-wrapper table,
  .product-detail-content table {
    display: block;
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   23. FIX: FORM LABEL & VALIDATION MOBILE
   ============================================================ */
@media (max-width: 767.98px) {
  .form-group {
    margin-bottom: 0.75rem !important;
  }

  label.control-label {
    font-size: 13px !important;
    margin-bottom: 4px !important;
  }

  .field-validation-error,
  .text-danger {
    font-size: 11px !important;
  }
}

/* ============================================================
    24. FIX: CART MOBILE - GỌN GÀNG
    ============================================================ */
@media (max-width: 767.98px) {
  .cart-item-card .row {
    flex-wrap: nowrap !important;
  }

  .cart-item-card .col-3 {
    width: 80px !important;
    flex: 0 0 80px !important;
  }

  .cart-item-card .col {
    min-width: 0;
  }

  .cart-qty-control {
    gap: 2px !important;
  }

  .cart-qty-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
  }

  .cart-qty-input {
    width: 36px !important;
    font-size: 13px !important;
  }
}

/* ============================================================
    25. FIX TRIỆT ĐỂ: RESET GLOBAL BUTTON OVERRIDE - TẤT CẢ BUTTON
    Vấn đề: layout-modern.css @media (max-width: 767.98px) set
    .btn-primary, .btn-danger, .btn-dark { padding: 8px 18px; font-size: 12px }
    làm hỏng mọi button trên mobile (giỏ hàng, checkout, profile...)
    Fix: Reset từng class button về kích thước phù hợp với từng ngữ cảnh
    ============================================================ */
@media (max-width: 991.98px) {
  /* reset layout-modern.css override: .btn-primary, .btn-danger, .btn-dark
     chỉ giữ cho hero-btn và btn-lg, còn lại về auto */
  .btn-primary:not(.hero-btn):not(.btn-lg):not(.btn-checkout):not(.btn-payment),
  .btn-danger:not(.btn-lg):not(.btn-checkout):not(.btn-payment),
  .btn-dark:not(.btn-lg):not(.hero-btn),
  .btn-quick-buy:not(.btn-lg) {
    padding: 6px 14px !important;
    font-size: 13px !important;
    min-height: 36px !important;
  }

  /* Button nhỏ cho product card */
  .product-card .btn-primary,
  .product-card .btn-danger,
  .product-card .btn-dark,
  .product-card .btn-quick-buy,
  .product-card button.btn,
  .product-body .btn {
    padding: 5px 10px !important;
    font-size: 0.7rem !important;
    border-radius: 40px !important;
    min-height: 30px !important;
    line-height: 1.2 !important;
  }
}

/* ============================================================
    26. FIX: HERO BANNER - TẤT CẢ MOBILE SIZE
    Vấn đề: layout-modern.css @media (max-width: 768px) set height: 380px
    Fix: mobile-fix.css section 2 chỉ set height: 300px cho max-width: 767.98px
    Cần thêm cả 768px để khớp
    ============================================================ */
@media (max-width: 768px) {
  .hero-banner-premium {
    height: 300px !important;
  }

  .hero-text-box h2 {
    font-size: 1.45rem !important;
    margin-bottom: 0.5rem !important;
  }

  .hero-text-box p.lead {
    font-size: 0.82rem !important;
    margin-bottom: 1rem !important;
  }
}

@media (max-width: 400px) {
  .hero-banner-premium {
    height: 260px !important;
  }

  .hero-text-box h2 {
    font-size: 1.2rem !important;
  }

  .hero-text-box p.lead {
    display: none !important;
  }
}

/* ============================================================
    27. FIX: PRODUCT LIST - HEADER, FILTER, GRID ĐẸP TRÊN MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  /* Product list heading */
  #danh-sach-san-pham-title,
  .product-list-title {
    font-size: 1.1rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Filter row - thu gọn spacing */
  .row.g-2.mb-3.align-items-end {
    --bs-gutter-x: 6px;
    --bs-gutter-y: 6px;
  }

  /* Button "Xem thêm" hoặc load more full width */
  .btn-load-more,
  .load-more-btn {
    width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
  }
}

/* ============================================================
    28. FIX: CHECKOUT + ORDER CONFIRM - UI ĐẸP MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  .checkout-form .row {
    --bs-gutter-x: 8px;
  }

  .order-summary-card {
    padding: 14px !important;
    border-radius: 12px !important;
  }

  .order-summary-card .table td,
  .order-summary-card .table th {
    padding: 6px 8px !important;
    font-size: 12px !important;
  }

  /* Payment buttons */
  .btn-payment,
  .btn-checkout {
    padding: 14px !important;
    font-size: 15px !important;
    min-height: 48px !important;
    border-radius: 12px !important;
  }
}

/* ============================================================
    29. FIX: PROFILE PAGE MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  .profile-card .card-body {
    padding: 12px !important;
  }

  .profile-info-row {
    flex-direction: column !important;
    gap: 4px !important;
  }

  .profile-label {
    font-size: 12px !important;
    min-width: auto !important;
  }

  .profile-value {
    font-size: 14px !important;
  }
}

/* ============================================================
    30. FIX: CATEGORY PAGE - HEADING & LAYOUT
    ============================================================ */
@media (max-width: 767.98px) {
  .category-header h1 {
    font-size: 1.15rem !important;
  }

  .category-description {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  /* Sort dropdown */
  .form-select.sort-select {
    font-size: 13px !important;
    padding: 6px 28px 6px 10px !important;
    min-height: 36px !important;
  }
}

/* ============================================================
    31. FIX: OFFCANVAS BACKDROP - CLOSE KHI CLICK BÊN NGOÀI
    ============================================================ */
@media (max-width: 991.98px) {
  .offcanvas-backdrop {
    opacity: 0.5 !important;
  }
}

/* ============================================================
    32. FIX: MODAL TRÊN MOBILE - ĐẸP HƠN
    ============================================================ */
@media (max-width: 576px) {
  .modal-content {
    border-radius: 16px !important;
    border: none !important;
  }

  .modal-header {
    border-bottom-width: 1px !important;
    padding: 14px 16px !important;
  }

  .modal-footer {
    padding: 12px 16px !important;
  }

  .modal-body {
    padding: 16px !important;
  }

  .modal-title {
    font-size: 1rem !important;
  }

  /* Close button to hơn */
  .modal-header .btn-close {
    width: 32px !important;
    height: 32px !important;
    font-size: 18px !important;
  }
}

/* ============================================================
    33. FIX: TOOLTIP/POPOVER TRÊN MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  .tooltip {
    font-size: 11px !important;
  }

  .popover {
    max-width: 240px !important;
    font-size: 12px !important;
  }
}

/* ============================================================
    34. FIX: ADMIN PAGES - BẢNG BIỂU TRÊN MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  .table-responsive table {
    min-width: 500px !important;
  }

  .admin-action-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    min-height: 30px !important;
  }

  .admin-card-header {
    font-size: 0.95rem !important;
    padding: 10px 12px !important;
  }

  .admin-card-body {
    padding: 10px !important;
  }
}

/* ============================================================
    35. FIX: TOAST/THÔNG BÁO TRÊN MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  .toast,
  .toast-container {
    max-width: calc(100vw - 24px) !important;
    left: 12px !important;
    right: 12px !important;
    margin: 0 auto !important;
  }

  .toast-body {
    font-size: 13px !important;
    padding: 10px 14px !important;
  }
}

/* ============================================================
    36. FIX: PRODUCT DETAIL - TỐI ƯU TOÀN DIỆN MOBILE
    ============================================================ */
@media (max-width: 767.98px) {
  /* Main image thích ứng */
  .main-image-wrapper {
    margin-left: -12px !important;
    margin-right: -12px !important;
    border-radius: 0 !important;
    height: auto !important;
    aspect-ratio: 1/1;
    max-height: 320px;
  }

  .detail-title {
    font-size: 1.1rem !important;
    line-height: 1.4 !important;
  }

  .detail-price {
    font-size: 1.2rem !important;
  }

  /* Thumbnail cuộn ngang */
  .thumbnail-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 6px !important;
    padding-bottom: 4px;
  }

  .thumbnail-wrapper {
    scroll-snap-align: start;
    flex-shrink: 0;
    width: 52px !important;
    height: 52px !important;
  }

  /* Thông số kỹ thuật */
  .spec-table td {
    padding: 6px 8px !important;
    font-size: 12px !important;
  }

  .spec-table td:first-child {
    width: 40% !important;
  }
}

/* ============================================================
    38. FIX: BOTTOM SPACING - TRÁNH FOOTER DÍNH SÁT
    ============================================================ */
@media (max-width: 767.98px) {
  body {
    padding-bottom: 0 !important;
  }

  .container.mb-5,
  main[role="main"].mb-5 {
    margin-bottom: 1rem !important;
  }
}

/* ============================================================
    39. FIX: SEARCH RESULT - KHÔNG BỊ VỠ LAYOUT
    ============================================================ */
@media (max-width: 767.98px) {
  .search-result-count {
    font-size: 12px !important;
    margin-bottom: 0.5rem !important;
  }

  .search-result-item {
    padding: 8px 10px !important;
  }

  .search-result-item .row {
    --bs-gutter-x: 8px;
  }
}

/* ============================================================
    40. FIX: EMPTY STATE - GIỎ HÀNG TRỐNG, KHÔNG SP
    ============================================================ */
@media (max-width: 767.98px) {
  .empty-state-icon {
    font-size: 3rem !important;
  }

  .empty-state-text {
    font-size: 14px !important;
  }

  .empty-state-btn {
    padding: 10px 20px !important;
    font-size: 13px !important;
  }
}
