/* ══════════════════════════════════════════════════════════════════════
   🔮 CRYSTALXSTORE MASTER MOBILE & TABLET RESPONSIVE SYSTEM 3.5 (FLAWLESS)
   Zero Overlap & 100% Clean Layout Across All Screens
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. GLOBAL RESET & ZERO-OVERFLOW ── */
:root {
  --cx-bottom-nav-height: 64px;
  --cx-safe-bottom: env(safe-area-inset-bottom, 0px);
  --cx-safe-top: env(safe-area-inset-top, 0px);
  --cx-admin-topbar-h: 60px;
}

html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Fix iOS font auto-zoom on inputs */
@media (max-width: 768px) {
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ── 2. DESKTOP NAVBAR LINKS HIDDEN ON MOBILE (NO OVERLAP!) ── */
@media (max-width: 991.98px) {
  /* HIDE ALL DESKTOP NAVBAR PILL BOXES AND CENTER MENUS ON MOBILE */
  .cx-nav-pill-box,
  .cx-navbar-classic .cx-nav-pill-box,
  .cx-navbar-floating .cx-nav-pill-box,
  .cx-nav-center-col,
  .cx-nav-center-pill,
  .cx-navbar-nav,
  .cx-nav-links,
  .navbar-nav.cx-nav-links,
  .navbar-collapse {
    display: none !important;
  }

  /* STOREFRONT NAVBAR ROW: LOGO ON LEFT, COMPACT ACTIONS ON RIGHT */
  .cx-storefront-navbar-wrap {
    padding: 6px 12px !important;
    height: auto !important;
    min-height: 52px !important;
  }

  .cx-nav-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
  }

  .cx-nav-left-col {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }

  .cx-nav-right-col {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }

  /* PADDING BOTTOM FOR FIXED MOBILE BOTTOM BAR */
  body:not(.is-backend) {
    padding-bottom: calc(var(--cx-bottom-nav-height) + var(--cx-safe-bottom) + 16px) !important;
  }

  /* MOBILE BOTTOM NAVIGATION BAR */
  .cx-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(var(--cx-bottom-nav-height) + var(--cx-safe-bottom)) !important;
    padding-bottom: var(--cx-safe-bottom) !important;
    background: rgba(13, 11, 24, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(139, 92, 246, 0.25) !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.85), 0 -2px 10px rgba(124, 58, 237, 0.2) !important;
    z-index: 1040 !important;
    justify-content: space-around !important;
    align-items: center !important;
  }

  .cx-bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    color: #94a3b8;
    text-decoration: none !important;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
  }

  .cx-bnav-item i, .cx-bnav-item svg {
    font-size: 1.2rem;
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
  }

  .cx-bnav-item.active {
    color: #a855f7 !important;
    font-weight: 700;
  }

  .cx-bnav-item.active i, .cx-bnav-item.active svg {
    transform: translateY(-2px) scale(1.1);
    color: #a855f7 !important;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.8));
  }
}

/* ── 3. PHONES (< 576px) NAVBAR ULTRA-COMPACT ── */
@media (max-width: 575.98px) {
  .cx-brand-name,
  .cx-brand-name-text {
    display: none !important;
  }

  .cx-brand-logo {
    height: 28px !important;
    width: auto !important;
  }

  /* Compact Discord */
  .cx-discord-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.85rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  /* Compact Language Selector */
  .cx-lang-btn {
    height: 30px !important;
    padding: 2px 8px !important;
    font-size: 0.78rem !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  /* Compact Balance Pill */
  .cx-balance-pill {
    height: 30px !important;
    padding: 2px 8px 2px 4px !important;
    gap: 4px !important;
  }

  .cx-balance-amount {
    font-size: 0.78rem !important;
  }

  .cx-avatar-wrap, .cx-avatar-glow-ring {
    width: 30px !important;
    height: 30px !important;
  }
}

/* ── 4. HERO SECTION ON MOBILE (NO HORIZONTAL OVERFLOW!) ── */
@media (max-width: 991.98px) {
  .p0-hero-grid, .hero-grid {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 16px !important;
  }

  .p0-hero-left {
    width: 100% !important;
    text-align: center !important;
  }

  .p0-hero-title {
    font-size: 1.85rem !important;
    line-height: 1.25 !important;
  }

  .p0-hero-actions {
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .p0-hero-actions a, .p0-hero-actions .btn {
    flex: 1 !important;
    max-width: 180px !important;
  }

  /* Hide or stack the right feature items so it doesn't push width */
  .p0-hero-right {
    display: none !important;
  }

  /* Banner & Stats Grid */
  .p0-banner-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .p0-stats-col, .p0-stats-row, .stats-container-row {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .p0-stat-card {
    padding: 12px 14px !important;
  }

  .p0-stat-num {
    font-size: 1.35rem !important;
  }
}

/* ── 5. PRODUCT CATALOG 2-COLUMN GRID (MOBILE FIRST) ── */
@media (max-width: 768px) {
  .product-shelf-grid, .products-grid, .product-grid-compact, .v2-prod-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .product-card-link, .product-card, .shop-item {
    width: 100% !important;
  }

  .product-card-thumb, .prod-thumb, .product-card-thumb img {
    height: 115px !important;
    object-fit: cover !important;
  }

  .product-card-title, .prod-title {
    font-size: 0.84rem !important;
    line-height: 1.25 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    min-height: 2.5em !important;
  }

  .product-card-price, .prod-price {
    font-size: 0.95rem !important;
  }
}

/* ── 6. MODALS & SWEETALERT2 ON MOBILE ── */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 8px !important;
    max-width: calc(100vw - 16px) !important;
  }
  .modal-content {
    border-radius: 18px !important;
    max-height: 88vh !important;
  }
  .modal-body {
    max-height: 72vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 14px !important;
  }

  .swal2-popup {
    width: 92vw !important;
    padding: 16px !important;
    border-radius: 20px !important;
  }
}
