/* ========================================================
   TECHSTORE - RESPONSIVE STYLESHEET (CHUẨN MOBILE / TABLET)
   Xử lý chống tràn viền (overflow), khắc phục triệt để lỗi màn hình
   đen xám khi mua hàng hoặc mở popup trên thiết bị di động.
   ======================================================== */

/* Đảm bảo toàn bộ hệ thống không bị tràn ngang */
html, body {
  max-width: 100%;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}

/* Thanh điều hướng cố định dưới đáy màn hình trên Mobile */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.mobile-bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  flex: 1;
  height: 100%;
  transition: color 0.2s ease;
}

.mobile-nav-item i {
  font-size: 18px;
}

.mobile-nav-item.active, .mobile-nav-item:hover {
  color: var(--primary-color);
}

.mobile-nav-item.highlight {
  color: #fbbf24;
}

/* KHẮC PHỤC TRIỆT ĐỂ LỖI ĐEN XÁM MÀN HÌNH (MODAL OVERLAY GLITCH) */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

.modal-overlay {
  /* Luôn đảm bảo overlay bao trọn khung nhìn màn hình và touch events hoạt động */
  pointer-events: auto !important;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.modal-content-box {
  /* Chống tràn chiều cao trên điện thoại */
  max-height: 85vh;
  margin: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  /* Thu gọn Sidebar trên Desktop nhỏ và Tablet */
  .sidebar-wrapper {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: none;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  }

  .sidebar-wrapper.show {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
  }

  .content-wrapper {
    margin-left: 0 !important;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  /* Lớp phủ mờ khi mở menu trên mobile */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
  }

  .sidebar-backdrop.show {
    display: block;
  }
}

@media (max-width: 768px) {
  /* Hiển thị thanh bottom navigation trên Mobile */
  .mobile-bottom-nav {
    display: block;
  }

  /* Đẩy footer và content lên tránh bị thanh bottom che */
  .footer-container {
    padding-bottom: 80px !important;
  }

  .app-header {
    padding: 10px 16px;
  }

  .user-balance-badge {
    padding: 4px 10px;
    font-size: 12px;
  }

  .banner-container {
    padding: 12px 14px;
  }

  .notice-box {
    margin: 0 14px 14px;
    padding: 10px 14px;
  }

  .category-header {
    margin: 20px 14px 14px;
  }

  .category-title {
    font-size: 22px;
  }

  /* Lưới sản phẩm 2 cột đều trên Mobile */
  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    padding: 0 12px 24px;
  }

  .card-body {
    padding: 12px;
  }

  .card-title {
    font-size: 13px;
    min-height: 36px;
  }

  .price-current {
    font-size: 16px;
  }

  .stat-pill {
    padding: 4px 6px;
    font-size: 11px;
  }

  .product-btn-view {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Nút Back to top dời lên trên thanh bottom nav */
  #btn-back-to-top {
    bottom: 75px;
    right: 14px;
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  /* ========================================================
     CHỐNG TRÀN TOÀN DIỆN CHO CÁC TRANG DỊCH VỤ / PROFILE / NẠP TIỀN
     ======================================================== */
  .service-container,
  .affiliate-container,
  .deposit-bank-wrapper,
  .orders-page-wrapper,
  .transactions-page-wrapper {
    padding: 14px 10px 85px 10px !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* Toàn bộ các box / card nội dung trong trang */
  .service-container > div,
  .service-card,
  .admin-card {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* Chuyển grid 2 cột sang 1 cột gọn gàng trên mobile */
  .service-grid-2col,
  .deposit-grid-2col,
  div[style*="minmax(360px"],
  div[style*="minmax(340px"],
  div[style*="minmax(320px"],
  div[style*="minmax(300px"] {
    grid-template-columns: 1fr !important;
  }

  /* Thanh tìm kiếm và bộ lọc trên Mobile: xếp dọc, full width, không tràn viền */
  .service-filter-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  .service-filter-wrap > *,
  .service-filter-item {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }

  .service-filter-wrap input,
  .service-filter-wrap select,
  .service-filter-wrap .custom-select-wrapper,
  .service-filter-wrap .custom-select-trigger {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Khung cuộn ngang bảng chuẩn mobile, chạm vuốt mượt mà */
  .service-table-responsive,
  div[style*="overflow-x: auto"] {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
    display: block !important;
    margin: 0 !important;
  }

  /* Giảm padding của các card lớn trên màn hình nhỏ */
  .service-container div[style*="padding: 22px"],
  .service-container div[style*="padding: 24px"],
  .service-container div[style*="padding: 26px"] {
    padding: 16px 14px !important;
  }
}

@media (max-width: 480px) {
  /* Màn hình điện thoại nhỏ */
  .card-badge-id {
    font-size: 10px;
    padding: 2px 6px;
  }

  .card-badge-rank {
    font-size: 9px;
    padding: 2px 6px;
  }

  .price-current {
    font-size: 15px;
  }

  .modal-content-box {
    padding: 16px;
  }
}
