/* =============================================
   U-PHIX GADGETS — Responsive & Media Queries
   =============================================*/

@media (max-width: 1200px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .hot-grid { grid-template-columns: repeat(3, 1fr); }
  .flash-sale-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-stats-2 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  /* CRITICAL: Disable fixed background on tablets for scroll performance */
  .hero-bg {
    background-attachment: scroll !important;
  }
  .hero-bg::before {
    background-attachment: scroll !important;
  }
  
  .hero-content { gap: 20px; padding: 20px 0 36px; }
  .hero-right { height: 400px; }
  .hero-h1 { font-size: clamp(1.9rem, 3.2vw, 2.8rem); }
  .modal-body { grid-template-columns: 1fr; }
  .sell-layout, .repair-layout, .about-layout, .contact-layout { grid-template-columns: 1fr; }
  .services-grid { grid-template-columns: 1fr 1fr; }
  .store-category-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .admin-stats-2 { grid-template-columns: 1fr 1fr; }

  /* Show slideshow, hide 3D models on tablets with smaller screens */
  .sf-clip-box { display: none !important; }
  
  #hero-slideshow-wrap { 
    display: block !important; 
    width: 100% !important; 
    height: 100% !important;
  }
  
  /* Show background images on tablets */
  .hero-bg-images-container {
    display: block !important;
  }
  
  /* Adjust z-index for mobile: dunes in front of background images */
  .dune, .dune-1, .dune-2, .dune-3, .dune-4 {
    z-index: 2 !important;
  }
  
  /* Ensure container and content are above background images */
  .container { position: relative; z-index: 10; }
  
  .canvas-label { display: none; }
  
  /* Hide product card on tablets */
  .hero-product-card { display: none !important; }
}

@media (max-width: 768px) {
  /* CRITICAL: Disable fixed background on mobile for scroll performance */
  .hero-bg {
    background-attachment: scroll !important;
  }
  .hero-bg::before {
    background-attachment: scroll !important;
  }
  
  /* ── FIX: Stack catalog header on mobile (Featured/Hot/Flash sections) ── */
  .catalog-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 16px;
  }
  
  .catalog-header > div:first-child {
    width: 100%;
  }
  
  .catalog-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Mobile Product Cards: Additional 5-10% scaling ── */
  .vault-product-card {
    border-radius: 12px;
  }
  .vault-img-badges {
    top: 8px;
    padding: 0 8px;
  }
  .vault-badge-hot, .vault-badge-featured, .vault-badge-cat {
    font-size: 0.55rem;
    padding: 1.5px 4px;
  }
  .vault-img-count {
    bottom: 6px;
    right: 6px;
    font-size: 0.6rem;
    padding: 1.5px 5px;
    gap: 2px;
  }
  .vault-product-info {
    padding: 10px 12px 12px;
  }
  .vault-product-brand {
    font-size: 0.6rem;
    margin-bottom: 2px;
  }
  .vault-product-name {
    font-size: 0.8rem;
    line-height: 1.15;
    margin-bottom: 2px;
  }
  .vault-product-spec {
    font-size: 0.65rem;
    margin-bottom: 8px;
    line-height: 1.25;
  }
  .vault-product-bottom {
    gap: 4px;
  }
  .vault-product-price {
    font-size: 1rem;
  }
  .vault-product-condition {
    font-size: 0.55rem;
  }
  .vault-product-btn {
    padding: 6px 11px;
    font-size: 0.7rem;
    border-radius: 7px;
  }
  
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .btn-wa-desktop { display: none; }
  .hero { align-items: flex-start; }
  
  /* Mobile: Text → 3D Model → Buttons layout */
  .hero-content { 
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 16px 12px 0;
    width: 100%;
    max-width: 100%;
  }
  
  .hero-left { 
    display: contents;
  }
  
  .hero-left > h1 { order: 1; }
  .hero-left > p { order: 2; }
  .hero-right { order: 3; }
  .hero-left > .hero-ctas { order: 4; }
  .hero-left > .hero-stats { order: 5; }

  /* Show slideshow, hide 3D models on mobile */
  .sf-clip-box { display: none !important; }
  
  #hero-slideshow-wrap { 
    display: block !important; 
    width: 100% !important; 
    height: 100% !important;
  }
  
  .canvas-label { display: none; }
  
  /* Text styling - increased sizes and centered */
  .hero-h1 { 
    font-size: clamp(2rem, 6vw, 2.4rem); 
    margin-bottom: 8px;
    line-height: 1.2;
    text-align: center;
    width: 100%;
    max-width: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .hero-h1 em {
    display: block;
    color: var(--accent);
    margin-top: 4px;
  }
  
  .hero-sub { 
    font-size: 0.95rem; 
    width: 100%;
    max-width: 95%;
    margin-bottom: 20px; 
    text-align: center;
    line-height: 1.5;
    padding: 0;
  }
  
  /* CTA Buttons - wider and better spaced */
  .hero-ctas { 
    justify-content: center; 
    align-items: center;
    gap: 12px;
    flex-direction: column;
    width: 100%;
    max-width: 95%;
    padding: 0;
    margin-bottom: 12px;
  }
  
  .hero-ctas .btn { 
    width: 100%;
    padding: 14px 20px; 
    font-size: 0.95rem;
    border-radius: 8px;
    font-weight: 600;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  
  /* Stats styling - centered */
  .hero-stats { 
    justify-content: center; 
    gap: 20px; 
    margin-top: 16px; 
    padding: 16px 8px;
    flex-wrap: wrap;
  }
  
  .hero-stat-num { 
    font-size: clamp(1rem, 4vw, 1.4rem);
  }
  
  .hero-stat-label { 
    font-size: 0.75rem;
  }
  
  /* 3D Model sizing */
  .hero-right { 
    height: 400px; 
    width: 100%;
    padding: 0;
  }
  
  /* Show background images on mobile */
  .hero-bg-images-container {
    display: block !important;
  }
  
  /* Make slideshow container more transparent (glass-like) */
  #hero-slideshow-wrap {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
  }
  
  .hero-slideshow-img {
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
  }
  
  .hero-slideshow-img.active {
    opacity: 1;
  }
  
  /* Hide product card on mobile */
  .hero-product-card { 
    display: none !important; 
  }
  
  .hero-card-btn { 
    display: none; 
  }
  
  /* Other mobile styles */
  .products-grid { grid-template-columns: 1fr 1fr; }
  .hot-grid { grid-template-columns: 1fr 1fr; }
  .flash-sale-grid { grid-template-columns: 1fr 1fr; }
  .services-grid { grid-template-columns: 1fr; }
  .store-category-grid { grid-template-columns: 1fr; gap: 16px; }
  .trust-item { padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--border); }
  .trust-items { flex-direction: column; }
  .how-steps.active { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .sell-stats { grid-template-columns: 1fr 1fr; }
  .repair-imgs { grid-template-columns: 1fr; }
  .repair-img-item.main { grid-column: span 1; }
  
  /* ── ADMIN PANEL MOBILE RESPONSIVE ── */
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { 
    display: none; 
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
  }
  .admin-sidebar.mobile-open { display: flex; }
  .admin-sidebar::after {
    content: '';
    position: fixed;
    left: 260px;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.4);
    z-index: -1;
  }
  .admin-topbar { 
    padding: 12px 16px; 
    gap: 12px;
  }
  .admin-topbar-title { 
    font-size: 1rem; 
    flex: 1;
  }
  .admin-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-primary);
  }
  .admin-hamburger span {
    width: 24px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: var(--transition);
  }
  .admin-content { 
    padding: 16px 12px; 
  }
  .admin-stats { 
    grid-template-columns: 1fr; 
    gap: 12px;
    margin-bottom: 20px;
  }
  .admin-stats-2 { 
    grid-template-columns: 1fr; 
    gap: 12px;
    margin-bottom: 20px;
  }
  .admin-stat-card { 
    padding: 16px; 
  }
  .admin-stat-card .value { 
    font-size: 1.5rem; 
  }
  .admin-form { 
    padding: 16px; 
    border-radius: var(--radius);
  }
  .admin-form h3 { 
    font-size: 1.1rem; 
    margin-bottom: 16px;
  }
  .form-grid { 
    grid-template-columns: 1fr; 
    gap: 12px;
  }
  .form-group { 
    gap: 6px; 
  }
  .form-group.full { 
    grid-column: span 1; 
  }
  .img-upload-grid { 
    grid-template-columns: 1fr 1fr; 
    gap: 8px;
  }
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-table {
    min-width: 500px;
  }
  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
  }
  .admin-table img {
    width: 40px;
    height: 40px;
  }
  .table-actions {
    gap: 4px;
    flex-wrap: wrap;
  }
  .action-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
  .admin-table-header {
    padding: 12px 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  /* Form inputs: iOS Safari zoom prevention + touch targets */
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 14px;
  }
  
  .form-label {
    font-size: 0.85rem;
  }
  
  .btn {
    min-height: 44px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  /* CRITICAL: Disable fixed background on tiny mobile for scroll performance */
  .hero-bg {
    background-attachment: scroll !important;
  }
  .hero-bg::before {
    background-attachment: scroll !important;
  }
  
  .hero-content { padding: 16px 0 0; }
  .hero-h1 { font-size: clamp(1.5rem, 7vw, 2rem); }
  .hero-sub { font-size: 0.82rem; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .hero-ctas .btn { width: 100%; padding: 12px 16px; font-size: 0.875rem; justify-content: center; }
  .hero-right { height: 320px; }
  .hero-stats { gap: 16px; }
  .hero-stat-num { font-size: 1.25rem; }
  
  /* Show slideshow on small mobile */
  .sf-clip-box { display: none !important; }
  
  #hero-slideshow-wrap { 
    display: block !important; 
    width: 100% !important; 
    height: 100% !important;
  }
  
  /* Show background images on small mobile */
  .hero-bg-images-container {
    display: block !important;
  }
  
  /* Adjust z-index for small mobile: dunes in front of background images */
  .dune, .dune-1, .dune-2, .dune-3, .dune-4 {
    z-index: 2 !important;
  }
  
  /* Hide product card on small mobile */
  .hero-product-card { display: none !important; }
  
  .products-grid { grid-template-columns: 1fr 1fr; }
  .hot-grid { grid-template-columns: 1fr 1fr; }
  .flash-sale-grid { grid-template-columns: 1fr 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-stats-2 { grid-template-columns: 1fr; }
  .img-upload-grid { grid-template-columns: 1fr 1fr; }
  
  /* Promo Modal mobile optimization */
  .promo-box {
    border-radius: 12px;
    margin: 16px auto;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Product Modal mobile optimization */
  .product-modal {
    max-width: min(600px, calc(100vw - 24px));
    margin: 16px auto;
  }

  /* ── Promotional slideshow responsive ── */
  .promo-slideshow-wrap {
    height: 140px;
    gap: 8px;
  }

  .promo-slide-nav {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 1.25rem;
  }

  .promo-slide-prev {
    margin-left: 4px;
  }

  .promo-slide-next {
    margin-right: 4px;
  }
}

@media (max-width: 360px) {
  /* CRITICAL: Disable fixed background on ultra-tiny mobile for scroll performance */
  .hero-bg {
    background-attachment: scroll !important;
  }
  .hero-bg::before {
    background-attachment: scroll !important;
  }
  
  .hero-h1 { font-size: 1.35rem; }
  .hero-sub { font-size: 0.78rem; }
  .hero-right { height: 260px; }
  .hero-stats { display: none; }
  
  /* Show slideshow on very small mobile */
  .sf-clip-box { display: none !important; }
  
  #hero-slideshow-wrap { 
    display: block !important; 
    width: 100% !important; 
    height: 100% !important;
  }
  
  /* Show background images on very small mobile */
  .hero-bg-images-container {
    display: block !important;
  }
  
  /* Adjust z-index for very small mobile: dunes in front of background images */
  .dune, .dune-1, .dune-2, .dune-3, .dune-4 {
    z-index: 2 !important;
  }
  
  /* Hide product card on very small mobile */
  .hero-product-card { display: none !important; }
}
