/*
Theme Name: SuperMart
Theme URI: https://supermart.example.com
Author: SuperMart Inc.
Author URI: https://supermart.example.com
Description: A full-featured retail/grocery supermarket theme built with Tailwind CSS. Includes product listings, department navigation, mega menu, cart functionality, pharmacy, photo center, auto care, and more.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: supermart
Tags: e-commerce, retail, shopping, full-width-template, custom-menu, responsive-layout
*/

/* =====================================================
   BRAND COLOR TOKENS  (variable-driven theming)
   -----------------------------------------------------
   The theme's blue/yellow brand colours are mapped onto CSS variables below.
   Override the variables to recolour the WHOLE storefront without touching any
   template — via Appearance → Customize → "Brand Colors", `wp theme mod set`,
   a child theme, or an injected  :root{ --primary:#xxxxxx }  block.
   ===================================================== */
:root{
  --sm-primary:#2563eb;        /* main brand colour (Tailwind blue-600) */
  --sm-primary-dark:#1d4ed8;   /* hover/active shade (blue-700) */
  --sm-accent:#facc15;         /* accent: logo + search button (yellow-400) */
  /* Generic aliases so external tools that target --primary / --accent work too */
  --primary:var(--sm-primary);
  --primary-dark:var(--sm-primary-dark);
  --accent:var(--sm-accent);
}
.bg-blue-600,.hover\:bg-blue-600:hover{background-color:var(--primary)!important}
.bg-blue-700,.bg-blue-800,.hover\:bg-blue-700:hover,.active\:bg-blue-800:active,.group:hover .group-hover\:bg-blue-700{background-color:var(--primary-dark)!important}
.text-blue-600,.text-blue-700,.hover\:text-blue-600:hover,.group:hover .group-hover\:text-blue-700{color:var(--primary)!important}
.border-blue-500,.border-blue-600,.focus\:border-blue-400:focus,.hover\:border-blue-400:hover{border-color:var(--primary)!important}
.bg-yellow-400,.hover\:bg-yellow-300:hover,.active\:bg-yellow-500:active{background-color:var(--accent)!important}
.text-yellow-300,.text-yellow-400{color:var(--accent)!important}

/* ====================================================
   SuperMart Custom Styles
   Tailwind CSS handles all utility styling via CDN.
   This file holds only supplemental styles.
   ==================================================== */

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Font */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Kill horizontal overflow / side white-space on mobile. overflow-x:clip clips
   the overflow WITHOUT establishing a scroll container, so position:sticky (the
   header) keeps working — overflow-x:hidden here would break the sticky header. */
html, body {
  max-width: 100%;
  overflow-x: clip;
}

/* Remove default WP styles on nav menus that conflict */
.wp-block-navigation { display: none; }

/* Mega menu overlay */
#sm-mega-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 40;
}
#sm-mega-overlay.active { display: block; }

/* Mega menu panel */
#sm-mega-panel {
  display: none;
  position: absolute;
  left: 0; right: 0;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  z-index: 50;
  border-top: 1px solid #f3f4f6;
}
#sm-mega-panel.active { display: flex; }

/* Mobile menu */
#sm-mobile-menu {
  display: none;
  overflow-y: auto;
  max-height: 75vh;
}
#sm-mobile-menu.active { display: block; }

/* Accordion */
.sm-accordion-body {
  display: none;
}
.sm-accordion-body.open {
  display: block;
}

/* Gallery thumbnails active state */
.sm-thumb.active {
  border-color: #2563eb;
}

/* Cart badge animation */
@keyframes sm-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.sm-cart-badge.pop { animation: sm-pop 0.25s ease; }

/* Product hover shadow */
.sm-product-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.10); }

/* Product card images: always show the FULL product (contain, never crop/zoom),
   centered on white with a little breathing room — Walmart-style list images. */
.sm-product-card img { object-fit: contain; background: #ffffff; }

/* Line clamp for product names */
.sm-line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Ensure images fill their containers properly */
.sm-hero-img { object-fit: cover; object-position: center; }

/* Tab underline transition */
.sm-tab { transition: border-color 0.15s, color 0.15s; }

/* Prevent WP admin bar from clipping sticky header */
.admin-bar header.sm-header { top: 32px; }
@media (max-width: 782px) {
  .admin-bar header.sm-header { top: 46px; }
}

/* ==========================================================================
   MINI-CART DRAWER  (fixes: cart popup was never rendered)
   Design notes addressing the 3 reported front-end concerns:
   1) Z-INDEX: overlay 9998 / drawer 9999 → always above the sticky header
      (z-50), the department nav, the mega-menu and any announcement bar.
   2) OVERFLOW CLIPPING: the drawer uses position:fixed, so it is anchored to
      the viewport and can NEVER be clipped by an ancestor's overflow:hidden.
      A defensive rule below also forces the header wrapper to overflow:visible.
   3) HEIGHT & POSITION: the drawer is full viewport height; the items region
      flex-grows and scrolls INTERNALLY (overflow-y:auto), so a cart with many
      lines shows a scrollbar instead of stretching off-screen. The footer
      (subtotal + checkout) stays pinned. dvh + admin-bar offsets keep it fully
      rendered at every resolution.
   ========================================================================== */

/* Defensive: never let the header wrapper clip floating panels */
header.sm-header,
.sm-header { overflow: visible; }

/* Dimmed backdrop */
#sm-cart-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#sm-cart-overlay.open { opacity: 1; }

/* The drawer itself */
#sm-cart-popup {
  display: none;                 /* toggled to flex by JS */
  position: fixed;               /* immune to ancestor overflow:hidden */
  z-index: 9999;                 /* above everything, incl. sticky header */
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;                /* correct height on mobile browser chrome */
  width: 380px;
  max-width: 92vw;
  background: #fff;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
  flex-direction: column;        /* header · scrollable items · footer */
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
#sm-cart-popup.open { transform: translateX(0); }

/* Header row */
.sm-cart-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
}
.sm-cart-title { margin: 0; font-weight: 800; font-size: 16px; color: #111827; }
.sm-cart-count { margin: 2px 0 0; font-size: 12px; color: #6b7280; }
.sm-cart-close {
  background: #f8fafc; border: none; border-radius: 8px;
  padding: 6px; color: #475569; cursor: pointer; line-height: 0;
}
.sm-cart-close:hover { background: #eef2f7; color: #111827; }

/* Scrollable items region — the key to never overflowing the screen */
.sm-cart-items {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

/* One product row */
.sm-cart-row {
  display: flex; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #f6f7f9;
}
.sm-cart-thumb {
  flex: 0 0 auto; width: 60px; height: 60px;
  border-radius: 10px; overflow: hidden; background: #f3f4f6; display: block;
}
.sm-cart-thumb img { width: 100%; height: 100%; object-fit: contain; background: #ffffff; }
.sm-cart-info { flex: 1 1 auto; min-width: 0; }
.sm-cart-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; font-weight: 600; color: #1f2937; text-decoration: none; line-height: 1.3;
}
.sm-cart-name:hover { color: #2563eb; }
.sm-cart-price { font-size: 12px; color: #6b7280; margin: 2px 0 6px; }
.sm-cart-qty { display: flex; align-items: center; gap: 6px; }
.sm-cart-qty button {
  border: 1px solid #e5e7eb; background: #fff;
  width: 24px; height: 24px; border-radius: 6px;
  font-size: 15px; line-height: 1; color: #374151; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sm-cart-qty button:hover { background: #f9fafb; border-color: #d1d5db; }
.sm-cart-qnum { min-width: 22px; text-align: center; font-size: 13px; font-weight: 600; color: #111827; }
.sm-cart-remove {
  width: auto !important; padding: 0 6px; margin-left: 4px;
  font-size: 11px !important; color: #ef4444 !important;
  border: none !important; background: none !important;
}
.sm-cart-remove:hover { text-decoration: underline; background: none !important; }
.sm-cart-line { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: #111827; }

/* Pinned footer */
.sm-cart-foot {
  flex: 0 0 auto;
  border-top: 1px solid #f1f5f9;
  padding: 14px 18px 16px;
  background: #fff;
}
.sm-cart-ship {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #16a34a; margin-bottom: 10px;
}
.sm-cart-subtotal {
  display: flex; justify-content: space-between;
  font-size: 15px; font-weight: 800; color: #111827;
}
.sm-cart-note { font-size: 11px; color: #9ca3af; margin: 2px 0 12px; }
.sm-cart-checkout {
  display: block; text-align: center;
  background: #2563eb; color: #fff; font-weight: 700; font-size: 14px;
  padding: 12px; border-radius: 999px; text-decoration: none;
}
.sm-cart-checkout:hover { background: #1d4ed8; }
.sm-cart-continue {
  display: block; width: 100%; text-align: center;
  background: none; border: none; color: #6b7280;
  font-size: 13px; font-weight: 600; padding: 10px 0 0; cursor: pointer;
}
.sm-cart-continue:hover { color: #111827; }

/* Empty state */
.sm-cart-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 24px;
}
.sm-cart-empty-title { margin: 14px 0 4px; font-weight: 700; font-size: 15px; color: #111827; }
.sm-cart-empty-sub { margin: 0 0 16px; font-size: 13px; color: #6b7280; }
.sm-cart-shop-btn {
  background: #2563eb; color: #fff; font-weight: 700; font-size: 13px;
  padding: 10px 20px; border-radius: 999px; text-decoration: none;
}
.sm-cart-shop-btn:hover { background: #1d4ed8; }

/* Sit below the WordPress admin bar when present */
.admin-bar #sm-cart-popup { height: calc(100vh - 32px); top: 32px; }
@media (max-width: 782px) {
  .admin-bar #sm-cart-popup { height: calc(100vh - 46px); top: 46px; }
}

/* ==========================================================================
   PRODUCT DETAIL PAGE  —  Walmart-aligned pixel tuning
   Scoped to .sm-pdp (added on the product page wrapper). Selectors are kept
   at >= 2-class specificity (or use the #id) so they reliably override the
   Tailwind CDN utility classes regardless of stylesheet source order.
   Reference target: walmart.com product pages (Bogle/Arial, tight spacing).
   ========================================================================== */

/* Walmart-style sans stack (Bogle falls back to Helvetica/Arial) */
.sm-pdp { font-family: "Bogle", "Helvetica Neue", Helvetica, Arial, sans-serif; }

/* Content is already capped at 1280px via .max-w-7xl (80rem); enforce + center */
.sm-pdp .max-w-7xl { max-width: 1280px; margin-left: auto; margin-right: auto; }

/* ---- Typography ---------------------------------------------------------- */
/* Breadcrumbs + secondary meta → 12px, mid-gray #46474a */
.sm-pdp .sm-pdp-crumbs { font-size: 12px; }
.sm-pdp .sm-pdp-crumbs a,
.sm-pdp .sm-pdp-crumbs span { color: #46474a; }
.sm-pdp .sm-pdp-meta { font-size: 12px; }
.sm-pdp .sm-pdp-sku  { color: #46474a; font-size: 12px; }

/* Product title → 24–28px, bold 700, near-black #2e2f32 */
.sm-pdp .sm-pdp-title {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  color: #2e2f32;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
@media (min-width: 1024px) { .sm-pdp .sm-pdp-title { font-size: 28px; } }

/* Price → ~32px bold, near-black; dollar sign as small superscript */
.sm-pdp .sm-pdp-price {
  font-size: 32px;
  font-weight: 700;
  color: #2e2f32;
  line-height: 1;
  letter-spacing: -0.02em;
}
.sm-pdp .sm-pdp-cur {
  font-size: 18px;
  font-weight: 700;
  vertical-align: 7px;
  margin-right: 1px;
}

/* ---- Layout: 55 : 45 columns on large screens (image slightly wider) ----- */
@media (min-width: 1024px) {
  .sm-pdp .sm-pdp-grid {
    grid-template-columns: minmax(0, 55fr) minmax(0, 45fr);
  }
}

/* ---- Add to Cart → Walmart blue, 48px tall, full 24px-radius pill -------- */
#sm-pdp-atc {
  background: #0071dc !important;
  color: #fff;
  height: 48px;
  min-height: 48px;
  border-radius: 24px !important;
  font-weight: 700;
  font-size: 16px;
  box-shadow: none;
}
#sm-pdp-atc:hover  { background: #004f9a !important; }
#sm-pdp-atc:active { background: #003d78 !important; }

/* ---- Trust badges → refined hairline card, 16px bottom gap --------------- */
.sm-pdp .sm-pdp-trust {
  background: #fff;
  border: 1px solid #e6e7e8;
  border-radius: 8px;
  margin-top: 8px;
  margin-bottom: 16px;
}
.sm-pdp .sm-pdp-trust > div { padding: 14px 16px; border-color: #f0f0f1; }
.sm-pdp .sm-pdp-trust p:first-child { color: #2e2f32; font-size: 13px; }
.sm-pdp .sm-pdp-trust p:last-child  { color: #46474a; font-size: 12px; }
