/**
 * Globex Sky — mobile.css
 * Comprehensive mobile-first responsive CSS overhaul.
 * Breakpoints: 480px (mobile small), 768px (mobile/tablet), 1024px (tablet/small desktop)
 */

/* ─── Fluid Typography ──────────────────────────────────────────────────────── */
:root {
  --fs-xs: clamp(0.65rem, 1.5vw, 0.75rem);
  --fs-sm: clamp(0.75rem, 1.8vw, 0.875rem);
  --fs-base: clamp(0.875rem, 2vw, 1rem);
  --fs-md: clamp(1rem, 2.5vw, 1.125rem);
  --fs-lg: clamp(1.1rem, 3vw, 1.25rem);
  --fs-xl: clamp(1.25rem, 4vw, 1.5rem);
  --fs-2xl: clamp(1.4rem, 5vw, 2rem);
  --fs-3xl: clamp(1.6rem, 6vw, 2.5rem);
  --touch-target: 44px;
}

/* ─── Utility: hide/show on mobile ─────────────────────────────────────────── */
.hide-mobile { display: block; }

/* ─── Base mobile improvements ─────────────────────────────────────────────── */
* { -webkit-tap-highlight-color: transparent; }

/* ─── 1024px — Tablet / Small Desktop ──────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Product grid: 3 columns */
  .products-grid,
  .product-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }

  /* Category cards: wrap */
  .category-grid,
  .categories-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Hero section: reduce padding */
  .hero-section,
  .hero-banner {
    padding: 40px 24px !important;
  }

  /* Navigation: reduce padding */
  .navbar,
  .nav-container {
    padding: 0 16px !important;
  }
}

/* ─── 768px — Mobile / Tablet ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Global font size */
  body { font-size: var(--fs-base); }

  /* Buttons: min 44px height */
  button,
  .btn,
  .button,
  input[type="submit"],
  input[type="button"],
  a.btn {
    min-height: var(--touch-target);
    padding: 10px 16px;
    font-size: var(--fs-sm);
  }

  /* Forms: full-width */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    font-size: var(--fs-base); /* prevent iOS zoom */
    min-height: var(--touch-target);
  }

  /* ── Navigation ── */
  .navbar { position: sticky; top: 0; z-index: 1000; }
  .navbar-brand img,
  .logo img { max-height: 32px; }

  /* Show hamburger, hide desktop nav links */
  .hamburger,
  .nav-toggle,
  .mobile-menu-btn,
  [data-mobile-toggle] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    cursor: pointer;
  }

  .nav-links,
  .navbar-nav,
  .nav-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: #fff;
    flex-direction: column !important;
    padding: 60px 20px 20px;
    gap: 4px !important;
    overflow-y: auto;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    transition: left 0.3s ease;
    z-index: 1001;
  }

  .nav-links.open,
  .nav-links.active,
  .navbar-nav.open,
  .nav-menu.open {
    left: 0;
  }

  .nav-links a,
  .navbar-nav a,
  .nav-menu a {
    display: block;
    padding: 12px 16px;
    min-height: var(--touch-target);
    border-radius: 8px;
    font-size: var(--fs-base);
  }

  /* Dropdown: full width on mobile */
  .dropdown-menu,
  .nav-dropdown {
    position: static !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    border-left: 3px solid #e2e8f0;
    margin: 4px 0 4px 12px;
    border-radius: 0 !important;
  }

  /* Search bar: full-width below nav */
  .search-bar,
  .search-container,
  .nav-search {
    width: 100% !important;
    order: 10;
    padding: 8px 16px;
  }

  .search-bar input,
  .search-container input {
    width: 100% !important;
  }

  /* ── Product Grid: 2 columns ── */
  .products-grid,
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* ── Category Cards: horizontal scroll ── */
  .category-grid,
  .categories-grid,
  .category-cards {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px !important;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .category-grid::-webkit-scrollbar,
  .categories-grid::-webkit-scrollbar { display: none; }

  .category-grid > *,
  .categories-grid > *,
  .category-cards > * {
    flex: 0 0 140px;
    scroll-snap-align: start;
    min-width: 140px;
  }

  /* ── Flash Sale Countdown: smaller fonts ── */
  .countdown-item,
  .flash-sale-timer,
  .countdown-timer {
    font-size: var(--fs-lg) !important;
  }
  .countdown-label { font-size: var(--fs-xs) !important; }

  /* ── Hero Section: stack vertically ── */
  .hero-section,
  .hero-banner,
  .hero-content {
    flex-direction: column !important;
    padding: 24px 16px !important;
    text-align: center;
    gap: 20px;
  }

  .hero-section h1,
  .hero-banner h1 { font-size: var(--fs-2xl) !important; }

  .hero-section p,
  .hero-banner p { font-size: var(--fs-base) !important; }

  .hero-image,
  .hero-illustration {
    max-width: 100%;
    margin: 0 auto;
  }

  /* ── Footer: single column ── */
  footer,
  .footer {
    padding: 32px 16px 16px !important;
  }

  .footer-grid,
  .footer-columns,
  .footer-row {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
    gap: 24px !important;
  }

  /* ── Cart Sidebar: full-screen ── */
  .cart-sidebar,
  .cart-drawer,
  #cart-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    z-index: 2000;
    border-radius: 0 !important;
    overflow-y: auto;
  }

  .cart-sidebar .cart-actions,
  .cart-drawer .cart-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .cart-sidebar .cart-actions .btn,
  .cart-drawer .cart-actions .btn {
    width: 100%;
  }

  /* ── Modal Dialogs: full-screen ── */
  .modal,
  .modal-dialog,
  .modal-overlay {
    padding: 0 !important;
  }

  .modal-content,
  .modal-box,
  .modal-body {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }

  /* ── Tables: horizontal scroll ── */
  .table-responsive,
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Remove hover-only effects, add active states ── */
  .product-card:hover,
  .card:hover { transform: none !important; box-shadow: none !important; }

  .btn:active,
  button:active,
  a:active { opacity: 0.75; transform: scale(0.98); }

  /* ── Hide non-essential elements ── */
  .hide-mobile {
    display: none !important;
  }

  /* ── Spacing adjustments ── */
  .container,
  .page-container {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .section,
  .section-padding { padding: 32px 0 !important; }

  /* ── Admin Panel on mobile ── */
  .admin-sidebar { display: none; }
  .admin-sidebar.open { display: block !important; }
  .admin-content,
  .admin-main { margin-left: 0 !important; }

  /* ── Stats / Info Cards ── */
  .stats-grid,
  .info-cards,
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
}

/* ─── 480px — Mobile Small ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Product grid: single column */
  .products-grid,
  .product-grid {
    grid-template-columns: 1fr !important;
  }

  /* Category cards: narrower */
  .category-grid > *,
  .categories-grid > *,
  .category-cards > * {
    flex: 0 0 120px;
    min-width: 120px;
  }

  /* Stats: single column */
  .stats-grid,
  .info-cards,
  .dashboard-stats {
    grid-template-columns: 1fr !important;
  }

  /* Hero */
  .hero-section,
  .hero-banner {
    padding: 16px !important;
  }
  .hero-section h1,
  .hero-banner h1 { font-size: var(--fs-xl) !important; }

  /* Flash sale countdown */
  .countdown-item,
  .flash-sale-timer { font-size: var(--fs-md) !important; }

  /* Section headings */
  h1 { font-size: var(--fs-2xl) !important; }
  h2 { font-size: var(--fs-xl) !important; }
  h3 { font-size: var(--fs-lg) !important; }

  /* Compact product cards */
  .product-card { padding: 8px !important; }
  .product-card img { border-radius: 6px; }
  .product-card .product-title { font-size: var(--fs-sm) !important; }
  .product-card .product-price { font-size: var(--fs-md) !important; }

  /* Nav: even smaller logo */
  .navbar-brand img,
  .logo img { max-height: 28px; }

  /* Checkout stepper: hide labels */
  .stepper-label,
  .checkout-step-label { display: none; }
}

/* ─── Touch-friendly: remove hover-only effects universally on touch ─────────── */
@media (hover: none) and (pointer: coarse) {
  *:hover { transition: none !important; }
  .product-card:hover,
  .card:hover,
  a:hover { transform: none !important; }
}
