/* ============================================================
   APP GIÁ TỐT — Dedicated Mobile App Stylesheet (Chuyên biệt Mobile)
   Áp dụng tối ưu cho màn hình điện thoại (< 768px)
   ============================================================ */

@media screen and (max-width: 768px) {

  /* ─── 1. Khung Layout & Chống Tràn Màn Hình ─── */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative;
    -webkit-text-size-adjust: 100%;
  }

  .page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .main-content {
    flex: 1;
    padding-bottom: 96px !important; /* Đệm an toàn để không bị Bottom Bar che */
  }

  .container {
    padding-left: 14px !important;
    padding-right: 14px !important;
    max-width: 100% !important;
  }

  .section {
    padding: 28px 0 !important;
  }

  .section-sm {
    padding: 18px 0 !important;
  }

  .section-header {
    margin-bottom: 20px !important;
  }

  .section-title {
    font-size: 1.4rem !important;
  }

  .section-subtitle {
    font-size: 0.85rem !important;
  }

  /* ─── 2. Top App Bar (Thanh Menu Trên) ─── */
  .navbar {
    height: 56px !important;
    padding: 0 8px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 900 !important;
    background: var(--bg-surface) !important;
    border-bottom: 1px solid var(--border) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
  }

  .navbar-container {
    height: 56px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4px !important;
  }

  /* Ẩn thanh menu ngang trên PC */
  .navbar-nav {
    display: none !important;
  }

  .navbar-logo {
    gap: 5px !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
  }

  .logo-icon {
    width: 28px !important;
    height: 28px !important;
    flex-shrink: 0 !important;
  }

  .logo-text {
    font-size: 0.95rem !important;
    white-space: nowrap !important;
  }

  .navbar-actions {
    gap: 4px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  #navbar-user {
    gap: 4px;
    align-items: center;
  }

  #navbar-auth {
    gap: 4px;
    align-items: center;
  }

  #navbar-auth .btn {
    padding: 5px 10px !important;
    font-size: 0.78rem !important;
    border-radius: var(--radius-full) !important;
    white-space: nowrap !important;
  }

  .balance-chip {
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    border-radius: var(--radius-full) !important;
    max-width: 125px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex-shrink: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  .user-menu-btn {
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    border: none !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .user-menu-btn .avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem !important;
    flex-shrink: 0 !important;
    border: 1.5px solid var(--border-hover) !important;
  }

  .user-menu-btn #user-name,
  .user-menu-btn span:last-child {
    display: none !important; /* Ẩn chữ Tên và icon mũi tên để avatar luôn hiển thị trọn vẹn */
  }

  .theme-toggle-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }

  .cart-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }

  /* ─── 3. Bottom Tab Bar 5 Tab (Chuẩn Native App) ─── */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    z-index: 1000 !important;
    padding: 0 !important;
    padding-bottom: max(env(safe-area-inset-bottom, 4px), 4px) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2) !important;
    box-sizing: border-box !important;
  }

  .notch-container {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    align-items: center !important;
    justify-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  .bottom-tab-item {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    padding: 4px 0 !important;
    transition: var(--transition-fast) !important;
    gap: 3px !important;
    box-sizing: border-box !important;
  }

  .bottom-tab-item .tab-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .bottom-tab-item .tab-icon svg {
    width: 20px !important;
    height: 20px !important;
  }

  .bottom-tab-item .tab-label {
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    white-space: nowrap !important;
    line-height: 1 !important;
  }

  .bottom-tab-item.active,
  .bottom-tab-item:hover {
    color: var(--primary) !important;
  }

  .bottom-tab-item.active .tab-icon {
    transform: scale(1.15) !important;
    color: var(--primary) !important;
  }

  .bottom-tab-item.active .tab-icon svg {
    stroke: var(--primary) !important;
  }

  .bottom-tab-item.active .tab-label {
    color: var(--primary) !important;
    font-weight: 700 !important;
  }


  /* ─── 4. Lưới Sản Phẩm 2 Cột Đối Xứng (2-Column Grid) ─── */
  .products-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .product-card {
    border-radius: 12px !important;
    overflow: hidden !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .product-card-img-wrapper {
    aspect-ratio: 1/1 !important;
    height: auto !important;
    position: relative !important;
    background: var(--bg-elevated) !important;
  }

  .product-card-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .product-card-badge {
    top: 6px !important;
    left: 6px !important;
  }

  .product-card-badge .badge {
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
  }

  .product-card-body {
    padding: 8px 10px !important;
    flex: 1 !important;
  }

  .product-card-title {
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin-bottom: 3px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  .product-card-note {
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  .product-card-footer {
    padding: 6px 10px 10px !important;
    border-top: 1px solid var(--border) !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }

  .product-price {
    font-size: 0.92rem !important;
    font-weight: 800 !important;
    color: var(--primary) !important;
  }

  .product-price-from {
    font-size: 0.7rem !important;
    font-weight: 500 !important;
    margin-right: 2px !important;
  }

  .product-card-footer .btn {
    width: 100% !important;
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    border-radius: var(--radius-sm) !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* ─── 5. Hero Section & Feature Cards ─── */
  .hero-section {
    padding: 32px 0 20px !important;
  }

  .hero-title {
    font-size: 1.75rem !important;
    line-height: 1.25 !important;
    margin-bottom: 12px !important;
  }

  .hero-subtitle {
    font-size: 0.9rem !important;
    margin-bottom: 20px !important;
  }

  .hero-actions {
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .hero-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .hero-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    margin-top: 24px !important;
  }

  .hero-stat-value {
    font-size: 1.2rem !important;
  }

  .hero-stat-label {
    font-size: 0.72rem !important;
  }

  .hero-visual {
    display: none !important; /* Ẩn banner nổi 3D của PC để tối ưu tốc độ mobile */
  }

  .feature-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .feature-card {
    padding: 16px !important;
  }

  .trust-strip {
    padding: 12px 0 !important;
  }

  .trust-items {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .trust-item {
    font-size: 0.78rem !important;
  }

  /* ─── 6. Modal chuyển thành Bottom Sheet ─── */
  .modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(8px) !important;
  }

  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 20px 16px 32px !important;
    animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    border-bottom: none !important;
  }

  .modal::before {
    content: '' !important;
    display: block !important;
    width: 44px !important;
    height: 5px !important;
    border-radius: 3px !important;
    background: var(--border-hover) !important;
    margin: 0 auto 16px !important;
  }

  .modal-header {
    margin-bottom: 16px !important;
    padding-bottom: 12px !important;
  }

  .modal-title {
    font-size: 1.15rem !important;
  }

  .modal-footer {
    margin-top: 20px !important;
    padding-top: 14px !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .modal-footer .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  @keyframes slideUpSheet {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* ─── 7. Search & Filter Tabs ─── */
  .page-header-inner {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .search-bar {
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 14px !important;
  }

  .filter-tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .filter-chip {
    white-space: nowrap !important;
    font-size: 0.8rem !important;
    padding: 5px 12px !important;
  }

  .price-chips-group {
    display: flex !important;
    align-items: center !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    width: 100% !important;
  }
  .price-chips-group::-webkit-scrollbar {
    display: none !important;
  }

  .price-chip-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 32px !important;
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
  }

  .search-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .search-filter-bar .form-select {
    width: 100% !important;
  }

  /* ─── 8. Trang Chi Tiết Sản Phẩm (Product Detail) ─── */
  .product-detail-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  .product-main-col {
    display: contents !important;
  }

  .product-image-card {
    order: 1 !important;
  }

  .product-side-col {
    order: 2 !important;
    position: static !important;
  }

  .product-desc-card {
    order: 3 !important;
  }

  .product-image-card img {
    aspect-ratio: 16/10 !important;
  }

  .cycle-option {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }

  .cycle-name {
    font-size: 0.95rem !important;
  }

  .cycle-price {
    font-size: 1rem !important;
  }

  /* ─── 9. Bảng Dữ Liệu Chống Tràn (Table Wrapper) ─── */
  .table-wrapper {
    border-radius: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-card) !important;
    margin-bottom: 20px !important;
  }

  table {
    min-width: 650px !important;
    width: 100% !important;
  }

  th, td {
    padding: 10px 12px !important;
    font-size: 0.82rem !important;
    white-space: nowrap !important;
  }

  /* ─── 10. Thống Kê & Admin Mobile Experience ─── */
  .admin-layout {
    display: block !important;
    grid-template-columns: 1fr !important;
    min-height: 100vh !important;
    background: var(--bg-base) !important;
  }

  .admin-sidebar {
    display: none !important;
  }

  .admin-content {
    padding: 16px 14px 84px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Admin Mobile Bottom Tab Bar (5 Tabs) */
  .admin-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 60px !important;
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    z-index: 900 !important;
    padding: 0 !important;
    padding-bottom: max(env(safe-area-inset-bottom, 4px), 4px) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3) !important;
    box-sizing: border-box !important;
  }

  .admin-bottom-nav-container {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    align-items: center !important;
  }

  .admin-bottom-tab {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.7rem !important;
    font-weight: 500 !important;
    transition: var(--transition-fast) !important;
    height: 100% !important;
    position: relative !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .admin-bottom-tab .tab-icon {
    font-size: 1.15rem !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .admin-bottom-tab .tab-icon svg {
    width: 20px !important;
    height: 20px !important;
    stroke-width: 2 !important;
  }

  .admin-bottom-tab .tab-label {
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
  }

  .admin-bottom-tab.active {
    color: var(--primary) !important;
  }

  .admin-bottom-tab.active .tab-icon svg {
    stroke: var(--primary) !important;
  }

  .admin-bottom-tab.active::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 20% !important;
    right: 20% !important;
    height: 2.5px !important;
    background: var(--gradient-primary) !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5) !important;
  }

  /* Admin Header & Title on Mobile */
  .admin-header,
  .admin-page-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
    padding-bottom: 14px !important;
    border-bottom: 1px solid var(--border) !important;
  }

  .admin-page-header-title,
  .admin-title {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    font-size: 1.25rem !important;
    font-weight: 800 !important;
  }

  .admin-page-header-actions,
  #admin-user {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .admin-page-header-actions .btn,
  #admin-user .btn {
    flex: 1 !important;
    justify-content: center !important;
    font-size: 0.82rem !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
  }

  /* Modals on Mobile — Above bottom nav */
  .modal-backdrop {
    z-index: 1500 !important;
    padding: 12px !important;
    align-items: flex-end !important;
  }

  .modal {
    max-height: 88vh !important;
    max-width: 100% !important;
    margin-bottom: max(env(safe-area-inset-bottom, 12px), 12px) !important;
    border-radius: var(--radius-xl) !important;
    overflow-y: auto !important;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6) !important;
  }

  .modal-footer {
    padding: 14px 16px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }


  /* Search & Filter Bar */
  .search-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
    width: 100% !important;
  }

  .search-filter-bar .search-bar {
    width: 100% !important;
    min-width: 0 !important;
  }

  .search-filter-bar .form-select {
    width: 100% !important;
    padding: 9px 14px !important;
  }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .stat-card {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .stat-val, .stat-value {
    font-size: 1.25rem !important;
  }

  .recent-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Table Touch Scroll */
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border) !important;
  }

  .table-wrapper table {
    min-width: 600px !important;
  }

  /* ─── 11. Trang Profile & Wallet ─── */
  .profile-layout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .profile-header-card {
    flex-direction: column !important;
    text-align: center !important;
    padding: 18px !important;
  }

  .profile-avatar-large {
    width: 64px !important;
    height: 64px !important;
    font-size: 1.75rem !important;
  }

  .wallet-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .vietqr-card {
    padding: 16px !important;
  }

  .vietqr-image-wrapper img {
    max-width: 200px !important;
  }

  /* ─── 12. Chân trang Footer ─── */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    text-align: left !important;
  }

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