/* ============================================================================
   PROJECT      : Mama’s Community Shop (100% Width Header Fix)
   VERSION      : 2.2.0
   DATE         : 2025-12-30
   DESCRIPTION  : Mobile-First, Vendor-Prefixed, Legacy-Safe Styles.
============================================================================ */

/* ============================================================================
   1. VARIABLES & RESET
============================================================================ */
:root {
  /* Colors */
  --brand-primary: #0B6E60;
  --brand-secondary: #F29E4C;
  --brand-accent: #E85A4F;
  --surface: #FFFFFF;
  --bg: #FAFBFB;
  --text: #081018;
  --muted: #5A5A5A;
  --footer-bg: #081018;
  --footer-text: #BFC9D2;

  /* Spacing */
  --container-width: 1200px;
  --radius-md: 8px;
}

/* Box Sizing Reset for ALL browsers */
*, *::before, *::after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }
img { max-width: 100%; display: block; height: auto; }
button { font-family: inherit; }

/* ============================================================================
   2. LAYOUT UTILITIES
============================================================================ */
.page {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  min-height: 100vh;
}

/* Container Logic - Restricted Widths (REMOVED .header-inner) */
.container, .footer-inner, .main-grid {
  width: 95%;
  max-width: var(--container-width);
  margin-left: auto;
  margin-right: auto;
}

/* Grid Fallback */
.main-grid {
  display: block; 
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Modern Grid (Desktop) */
@media (min-width: 1024px) {
  .main-grid {
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    grid-gap: 2rem; 
    gap: 2rem;
    align-items: start;
  }
}


/* ============================================================================
   4. PRODUCT GRID & CARDS (Refactored for Uniformity)
============================================================================ */

/* 1. The Grid Container */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2rem;
  width: 100%;
}

/* 2. The Card Component */
.product-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid #eee;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

/* 3. Product Media (The Canvas) */
.product-media {
  position: relative;
  width: 100%;
  /* FIX 1: Reduced height (4:3 ratio is 25% shorter than square) */
  aspect-ratio: 4 / 3;
  background: #f8f9fa; /* Light grey background */
  overflow: hidden;
}

/* 4. The Images */
.product-media img {
  /* FIX 3: Absolute position fixes the "height: 0" visibility bug */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  
  /* FIX 1: Contains image within box (no cropping) */
  object-fit: contain;
  padding: 1rem; /* Internal padding so image doesn't touch edges */
  
  /* Smooth transition for the swap */
  transition: opacity 0.3s ease-in-out;
}

/* FIX 2: HOVER SWAP LOGIC */
/* Image 1 (Primary) */
.product-media img:nth-of-type(1) {
  opacity: 1;
  z-index: 2;
}

/* Image 2 (Secondary - Hidden by default) */
.product-media img:nth-of-type(2) {
  opacity: 0;
  z-index: 3; /* Sits on top */
}

/* On Card Hover: Hide Image 1, Show Image 2 */
.product-card:hover .product-media img:nth-of-type(1) {
  opacity: 0;
}
.product-card:hover .product-media img:nth-of-type(2) {
  opacity: 1;
}

/* 5. Flags (New/Sale) */
.product-flag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  pointer-events: none;
}
.product-flag.new { background: var(--brand-secondary); }
.product-flag.sale { background: var(--brand-accent); }
.product-flag.seasonal { background: var(--brand-primary); }

/* 6. Badges (Wishlist/Watchlist) */
.product-badges {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.wish-toggle, 
.watch-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wish-toggle:hover, 
.watch-toggle:hover {
  background: var(--brand-primary);
  color: #fff;
}

/* 7. Card Body */
.product-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #fff;
}

.product-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}
.product-title a { color: var(--text); }
.product-title a:hover { color: var(--brand-primary); }

.product-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 8. Price & Actions */
.product-price {
  margin-top: auto;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--brand-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
}

.price-old {
  text-decoration: line-through;
  color: #999;
  font-size: 0.9rem;
  margin-right: 0.5rem;
  font-weight: 400;
}

.product-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  border: none;
}

.btn-add {
  background: var(--brand-accent);
  color: #fff;
  flex: 2; /* Make Add button wider */
}
.btn-add:hover { background: #d64d42; }

.btn-details {
  background: transparent;
  border: 1px solid var(--brand-primary);
  color: var(--brand-primary);
}
.btn-details:hover { background: var(--brand-primary); color: #fff; }

/* ============================================================================
   CSS-ONLY LANGUAGE DROPDOWN (Rem-Based, No PX)
   - Fully scalable units (rem/em).
   - No JavaScript required (Hover based).
============================================================================ */

/* 1. Container */
.lang-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
  /* Invisible bridge for hover stability */
  padding-bottom: 0.625rem; 
  margin-bottom: -0.625rem;
}

/* 2. The Button (Visual Only) */
#lang-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 0.0625rem solid rgba(255, 255, 255, 0.2);
  padding: 0.4rem 0.8rem;
  border-radius: 0.375rem; /* ~6px */
  font-size: 0.9rem;
  font-weight: 600;
  cursor: default; /* Indicates it's just a label in this mode */
  pointer-events: none; /* Allows hover to pass through to container easily */
  width: auto;
}

/* 3. The Dropdown List (Hidden by default) */
.lang-list {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 10rem; /* ~160px */
  background: #fff;
  border: 0.0625rem solid rgba(0,0,0,0.1);
  border-radius: 0.5rem; /* ~8px */
  box-shadow: 0 0.25rem 1rem rgba(0,0,0,0.15);
  padding: 0.5rem 0;
  z-index: 1000;
  list-style: none;
  margin-top: 0;
}

/* 4. Show List on Container Hover */
.lang-dropdown:hover .lang-list {
  display: block;
  animation: fadeIn 0.2s ease;
}

.lang-dropdown:hover #lang-button {
  background: rgba(255, 255, 255, 0.25);
}

/* 5. List Items */
.lang-list li {
  padding: 0; /* padding moved to link */
  margin: 0;
}

/* 6. Links (Clickable Area) */
.lang-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: #333;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.1s;
  width: 100%;
}

.lang-list a:hover {
  background-color: #f3f4f6;
  color: #0B6E60;
}

/* 7. Active Item */
.lang-list li.active a {
  background-color: rgba(11, 110, 96, 0.05);
  font-weight: 700;
  color: #0B6E60;
}

/* 8. Flag Icons (Scalable) */
.flag-icon {
  width: 1.25rem !important;  /* ~20px */
  height: 0.875rem !important; /* ~14px */
  object-fit: cover;
  border-radius: 0.125rem;    /* ~2px */
  box-shadow: 0 0.0625rem 0.125rem rgba(0,0,0,0.2);
  display: block;
  flex-shrink: 0;
}

/* Utility */
.ms-auto { margin-left: auto; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-0.3125rem); } /* -5px */
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   CONTROL DECK FILTER STYLES
   - Futuristic "Headless" UI concept
   - Fully REM-based (No px)
   - Mobile-First & Touch Friendly
============================================================================ */

/* 1. Main Container (Floating Deck) */
.control-deck {
  background: var(--surface);
  border-radius: 1rem; /* 16px */
  padding: 0.75rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0,0,0,0.06); /* Soft elevation */
  margin-bottom: 2rem;
  position: relative;
  z-index: 50;
  border: 0.0625rem solid rgba(0,0,0,0.05);
}

/* 2. Top Bar Layout */
.deck-row.main-deck {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap; /* Wraps gracefully on mobile */
}

/* 3. Search Capsule (The "Futuristic" Input) */
.search-capsule {
  display: flex;
  align-items: center;
  background: #f4f6f8; /* Light grey surface */
  padding: 0 1rem;
  border-radius: 3rem; /* Pill shape */
  flex: 1; /* Takes available space */
  min-width: 12rem; /* ~200px min width */
  border: 0.0625rem solid transparent;
  transition: all 0.2s ease;
}

.search-capsule:focus-within {
  background: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(11, 110, 96, 0.1); /* Focus ring */
}

.search-capsule i {
  color: var(--muted);
  font-size: 1rem;
  margin-right: 0.5rem;
}

.search-capsule input {
  border: none;
  background: transparent;
  padding: 0.8rem 0;
  outline: none;
  width: 100%;
  font-size: 0.95rem;
  color: var(--text);
}

/* 4. Sort Pills (Radio Buttons as UI Chips) */
.sort-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto; /* Horizontal scroll on very small screens */
}

/* Hide the actual radio button */
.pill-radio input {
  display: none; 
}

/* The visual pill */
.pill-content {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.6rem 1.2rem;
  border-radius: 3rem;
  background: #fff;
  border: 0.0625rem solid #e5e7eb;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.pill-content:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* Active State */
.pill-radio input:checked + .pill-content {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 0.25rem 0.75rem rgba(11, 110, 96, 0.25); /* Glow effect */
  transform: translateY(-0.0625rem);
}

/* 5. Filter Trigger Button */
.deck-btn {
  background: #fff;
  border: 0.0625rem solid #e5e7eb;
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: 3rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  transition: all 0.2s ease;
}

.deck-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.deck-btn i { font-size: 1rem; }

/* Notification Dot */
.badge-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 0.75rem;
  height: 0.75rem;
  background: var(--brand-accent);
  border-radius: 50%;
  border: 0.125rem solid #fff;
}

/* 6. The Drawer (Slide Down Animation) */
.deck-drawer {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s ease;
  background: #f8f9fa;
  margin: 0 -0.75rem -0.75rem -0.75rem; /* Stretch to edges of container */
  border-radius: 0 0 1rem 1rem;
}

.deck-drawer.open {
  max-height: 40rem; /* Arbitrary large height to allow expansion */
  opacity: 1;
  border-top: 0.0625rem solid #e5e7eb;
}

/* Drawer Grid Layout */
.drawer-grid {
  padding: 1.5rem;
  display: grid;
  /* Responsive columns: min 200px wide */
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 1.5rem;
}

.drawer-col h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.drawer-col.wide {
  grid-column: 1 / -1; /* Span full width on mobile */
}

@media(min-width: 1024px) {
    .drawer-col.wide {
        grid-column: auto; /* Auto span on desktop */
    }
}

/* 7. Drawer Inputs & Selects */
.deck-select,
.deck-input-sm {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0.0625rem solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s;
}

.deck-select:focus,
.deck-input-sm:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.125rem rgba(11, 110, 96, 0.1);
}

/* Price Range Group */
.range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-inputs span {
  color: var(--muted);
  font-weight: bold;
}

/* Go Button */
.deck-btn-sm {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.deck-btn-sm:hover {
  background: #08554a; /* Darker shade of primary */
}

/* ============================================================================
   5. FOOTER
============================================================================ */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 3rem 0;
  margin-top: auto;
}

.footer-inner {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  margin: -1rem;
  /* Footer inner still respects container max-width */
  width: 95%;
  max-width: var(--container-width);
  margin-left: auto;
  margin-right: auto;
}

.footer-col {
  -ms-flex: 1 1 200px;
  flex: 1 1 200px;
  margin: 1rem;
}

.footer-col h4 { color: #fff; }
.footer-links a { color: var(--footer-text); display: block; margin-bottom: 0.5rem; }

/* ============================================================================
   6. CONTROL DECK FILTER STYLES (Responsive & Cross-Browser)
============================================================================ */

/* 1. Main Container */
.control-deck {
  background: var(--surface);
  border-radius: 1rem;
  padding: 0.75rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0,0,0,0.06);
  margin-bottom: 2rem;
  position: relative;
  z-index: 50;
  border: 0.0625rem solid rgba(0,0,0,0.05);
}

/* 2. Top Bar Layout */
.deck-row.main-deck {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap; /* Critical for mobile wrapping */
}

/* 3. Search Capsule */
.search-capsule {
  display: flex;
  align-items: center;
  background: #f4f6f8;
  padding: 0 1rem;
  border-radius: 2rem;
  flex: 1 1 200px; /* Grow, Shrink, Min-basis */
  border: 0.0625rem solid transparent;
  transition: all 0.2s ease;
}

.search-capsule:focus-within {
  background: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(11, 110, 96, 0.1);
}

.search-capsule i {
  color: var(--muted);
  font-size: 1rem;
  margin-right: 0.5rem;
}

.search-capsule input {
  border: none;
  background: transparent;
  padding: 0.7rem 0;
  outline: none;
  width: 100%;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 0; /* Fix flexbox input overflow */
}

/* 4. Sort Pills (Horizontal Scroll on Mobile) */
.sort-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px; /* Space for scrollbar if visible */
  -webkit-overflow-scrolling: touch; /* Smooth iOS scroll */
  scrollbar-width: none; /* Firefox */
}
.sort-pills::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.pill-radio input { display: none; }

.pill-content {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  background: #fff;
  border: 0.0625rem solid #e5e7eb;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  user-select: none;
}

.pill-content:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.pill-radio input:checked + .pill-content {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 0.25rem 0.5rem rgba(11, 110, 96, 0.2);
}

/* 5. Filter Trigger Button */
.deck-btn {
  background: #fff;
  border: 0.0625rem solid #e5e7eb;
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  white-space: nowrap;
}

.deck-btn:hover { background: #f9fafb; border-color: #d1d5db; }

.badge-dot {
  position: absolute;
  top: -2px; right: -2px;
  width: 10px; height: 10px;
  background: var(--brand-accent);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* 6. The Drawer (Slide Down) */
.deck-drawer {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  background: #f8f9fa;
  margin: 0 -0.75rem -0.75rem -0.75rem;
  border-radius: 0 0 1rem 1rem;
}

.deck-drawer.open {
  max-height: 50rem; /* Safe max height */
  opacity: 1;
  border-top: 0.0625rem solid #e5e7eb;
}

.drawer-grid {
  padding: 1.5rem;
  display: grid;
  /* Auto-fit columns: stack on mobile, grid on desktop */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
}

.drawer-col h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* 7. Inputs & Selects */
.select-wrapper {
  position: relative;
}
.select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.8rem;
  color: var(--muted);
}

.deck-select,
.deck-input-sm {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0.0625rem solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  /* Remove default appearance for consistency */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-sep {
  color: var(--muted);
  font-weight: bold;
}

.deck-btn-sm {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

/* Mobile Tweaks */
@media (max-width: 600px) {
  .control-deck { padding: 0.5rem; }
  
  .deck-row.main-deck { gap: 0.5rem; }
  
  .search-capsule {
    flex-basis: 100%; /* Search takes full row on mobile */
    order: 3; /* Move to bottom of top bar if desired, or keep top */
  }
  
  .sort-pills {
    flex: 1; /* Take remaining space */
  }
}

