/**
 * ========================================================
 * TECHSTORE - RESPONSIVE STYLESHEET (RESPONSIVE.CSS)
 * Xử lý hoàn hảo hiển thị đa thiết bị (Mobile, Tablet, Desktop)
 * Khắc phục triệt để lỗi tràn viền (overflow-x) và lỗi màn hình xám/đen
 * ========================================================
 */

/* Ngăn ngừa tràn khung ngang trên toàn bộ hệ thống */
html, body {
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* ========================================================
   TABLET RESPONSIVE (MAX-WIDTH: 1024PX)
   ======================================================== */
@media screen and (max-width: 1024px) {
  .hero-title {
    font-size: 40px;
  }

  .floating-icon.icon-tl, 
  .floating-icon.icon-bl {
    left: 10px;
  }

  .floating-icon.icon-tr, 
  .floating-icon.icon-br {
    right: 10px;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 30px;
  }

  .bank-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media screen and (max-width: 1220px) {
  .nav-menu {
    gap: 12px;
  }
  .nav-link {
    font-size: 13px;
  }
}

/* Ẩn mục chỉ dành cho mobile trên desktop */
.mobile-only-menu-item {
  display: none;
}

@media screen and (max-width: 992px) {
  .mobile-only-menu-item {
    display: block;
    width: 100%;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
  }

  .nav-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: #ffffff;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-150%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 999;
  }

  .nav-menu.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .mobile-nav-toggle {
    display: flex !important;
  }
}

/* ========================================================
   MOBILE LANDSCAPE & TABLET (MAX-WIDTH: 768PX)
   ======================================================== */
@media screen and (max-width: 768px) {
  /* Ẩn các icon floating để tránh che chữ và không gây tràn ngang */
  .floating-icon {
    display: none !important;
  }

  /* Header Mobile chống tràn x và lệch giao diện */
  .site-header {
    height: auto;
    max-width: 100vw;
  }

  .navbar {
    height: 60px;
    padding: 0 12px !important;
    gap: 8px !important;
    max-width: 100%;
  }

  .nav-brand {
    font-size: 16px;
    gap: 8px !important;
    flex-shrink: 0;
  }

  /* Ẩn nút CTA dài trên mobile để navbar không bao giờ bị tràn */
  .header-cta-desktop {
    display: none !important;
  }

  /* Rút gọn tên user trên mobile chỉ giữ lại avatar tròn gọn gàng */
  .user-profile-name,
  .user-profile-chevron {
    display: none !important;
  }

  .user-profile-btn {
    padding: 2px !important;
    gap: 0 !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    justify-content: center !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }

  .user-avatar-mini {
    width: 28px !important;
    height: 28px !important;
  }

  .user-dropdown .dropdown-menu {
    right: 0 !important;
    top: calc(100% + 10px) !important;
    width: 240px !important;
    max-width: 88vw !important;
  }

  .nav-actions {
    gap: 8px !important;
    flex-shrink: 0;
  }

  .cart-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
  }

  .mobile-nav-toggle {
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
  }

  .header-login-btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }

  .nav-link {
    font-size: 15px;
    width: 100%;
    display: block;
    padding: 6px 0;
  }

  /* Hero Section */
  .hero-section {
    padding: 40px 0 60px 0;
  }

  .hero-badge {
    font-size: 12px;
    padding: 6px 14px;
  }

  .hero-title {
    font-size: 30px;
    line-height: 1.25;
    letter-spacing: -0.5px;
    padding: 0 10px;
  }

  .hero-desc {
    font-size: 15px;
    padding: 0 10px;
    margin-bottom: 24px;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
    padding: 0 15px;
  }

  .hero-cta-group .btn {
    width: 100%;
  }

  .commit-bar {
    gap: 14px;
    padding: 0 10px;
  }

  .commit-item {
    font-size: 12.5px;
  }

  /* Mockup Box */
  .mockup-card {
    padding: 20px 16px;
    border-radius: 16px;
  }

  .bank-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .bank-item {
    padding: 8px 4px;
    font-size: 12px;
  }

  .price-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .price-item {
    padding: 10px 8px;
    font-size: 14px;
  }

  .qr-preview-box {
    flex-direction: column;
    padding: 18px 14px;
    gap: 16px;
    text-align: center;
  }

  .qr-image-wrapper img {
    width: 150px;
    height: 150px;
  }

  .qr-info-content {
    width: 100%;
  }

  .qr-detail-row {
    font-size: 13.5px;
  }

  /* Products */
  .product-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .section {
    padding: 50px 0;
  }

  .section-title {
    font-size: 26px;
  }

  /* Giỏ hàng & Thanh toán Mobile (Chống lỗi màn hình đen xám) */
  .checkout-grid, .cart-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .table-responsive table {
    min-width: 550px;
  }

  /* Form Inputs chống zoom trên iOS Safari */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Modal và Backdrop Fix: Không bị che đen màn hình */
  .site-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }

  .site-modal-overlay.active {
    display: flex !important;
  }

  .site-modal-content {
    background: #ffffff;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 16px;
    z-index: 9999;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
}

/* ========================================================
   SMALL MOBILE PHONES (MAX-WIDTH: 480PX)
   ======================================================== */
@media screen and (max-width: 480px) {
  .hero-title {
    font-size: 26px;
  }

  .bank-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mockup-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .qr-image-wrapper img {
    width: 140px;
    height: 140px;
  }
}
