/* ==========================================================================
   Kamal Medical Storefront Refresh — desktop polish + mobile upgrades.
   Loaded after style.css / components.css / mobile.css, so these rules win.
   All colors use theme vars with fallbacks (light + dark mode safe).
   ========================================================================== */

/* ---------------- DESKTOP (pointer devices, wide screens) ---------------- */
@media (min-width: 1024px), (pointer: fine) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)) !important;
    gap: 24px !important;
  }

  .product-card {
    border-radius: 18px !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  }
  .product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px -12px rgba(5, 150, 105, 0.22) !important;
    border-color: rgba(5, 150, 105, 0.35) !important;
  }
  .product-image-container img {
    transition: transform 0.35s ease;
  }
  .product-card:hover .product-image-container img {
    transform: scale(1.06);
  }

  .current-price {
    font-size: 1.3rem !important;
    letter-spacing: -0.02em;
  }

  .btn-add-cart {
    transition: all 0.2s ease;
  }
  .btn-add-cart:hover {
    background: var(--primary-600, #059669) !important;
    color: #fff !important;
    box-shadow: 0 8px 18px -6px rgba(5, 150, 105, 0.5);
  }
  .qty-stepper-wrap button:hover {
    background: var(--primary-50, #ecfdf5);
  }

  .catalog-header h2 {
    letter-spacing: -0.02em;
  }
  .sort-select {
    cursor: pointer;
  }
}

/* ---------------- MOBILE (touch, small screens) ---------------- */
@media (max-width: 768px) {
  /* Sticky cart bar — sits above the bottom nav, appears when cart non-empty */
  #stickyCartBar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(62px + 10px + env(safe-area-inset-bottom));
    z-index: 1999;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    border-radius: 16px;
    padding: 10px 10px 10px 16px;
    box-shadow: 0 12px 28px -8px rgba(5, 150, 105, 0.55);
    transform: translateY(140%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
  }
  #stickyCartBar.show {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  #stickyCartBar .scb-info {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
  }
  #stickyCartBar .scb-count {
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 0.9;
  }
  #stickyCartBar .scb-total {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }
  #stickyCartBar .scb-btn {
    border: none;
    background: #fff;
    color: #047857;
    font-weight: 800;
    font-size: 0.88rem;
    padding: 12px 20px;
    min-height: 48px;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
  }
  #stickyCartBar .scb-btn:active {
    transform: scale(0.96);
  }

  /* Comfortable touch targets on cards */
  .btn-add-cart {
    min-height: 44px !important;
    font-size: 0.82rem !important;
    border-radius: 12px !important;
  }
  .qty-stepper-wrap {
    min-height: 44px !important;
    border-radius: 12px !important;
  }
  .qty-stepper-wrap button {
    min-width: 44px !important;
    font-size: 1.1rem;
  }
  .qty-stepper-wrap .qty-val {
    font-size: 0.95rem;
    min-width: 30px;
    text-align: center;
  }

  /* Denser, cleaner cards */
  .product-salt {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.72rem !important;
  }
  .product-category-tag {
    font-size: 0.66rem !important;
  }
  .wishlist-heart-btn {
    width: 38px !important;
    height: 38px !important;
  }
  .variant-chips {
    gap: 6px;
  }
  .variant-chip {
    min-height: 36px;
    font-size: 0.72rem !important;
  }

  /* Quick tags scroll sideways instead of wrapping */
  .quick-search-tags {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .quick-search-tags::-webkit-scrollbar {
    display: none;
  }
  .quick-tag-chip {
    flex-shrink: 0;
  }

  /* Catalog header stacks neatly */
  .catalog-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }
  .catalog-controls {
    width: 100%;
  }
  .sort-dropdown-wrap {
    width: 100%;
  }
  .sort-select {
    flex: 1;
    min-height: 44px;
    font-size: 0.85rem;
  }

  /* Toasts float above nav + cart bar, never behind them */
  .toast-container {
    bottom: calc(134px + env(safe-area-inset-bottom)) !important;
    z-index: 4000 !important;
  }

  /* Modals become bottom sheets on phones */
  .modal-card {
    border-radius: 22px 22px 0 0 !important;
    max-height: 92dvh !important;
    animation: sheetUp 0.28s ease;
  }
  @keyframes sheetUp {
    from { transform: translateY(40px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }
  .profile-modal-card,
  #checkoutModal .modal-card,
  #invoiceModal .modal-card {
    width: 100% !important;
    margin: auto 0 0 !important;
  }

  /* Keep last content clear of the fixed nav */
  main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

/* Small phones: keep 2-col grid breathable */
@media (max-width: 380px) {
  #stickyCartBar {
    left: 8px;
    right: 8px;
  }
  #stickyCartBar .scb-btn {
    padding: 12px 14px;
  }
}
