

/* =========================================
   Braga Bazaar – Global CSS (Optimized)
   ========================================= */

/* CSS Variables */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 80px;
  --primary-green: #2d7a32;
  --hover-green: #1e5222;
  --text-dark: #333333;
  --bg-light: #f9f9f9;

  /* Used by progress bar */
  --progress-width: 0%;
}

/* Base */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-color: var(--bg-light);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
}

/* Remove iOS tap highlight */
button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* =========================================
   Sidebar (Desktop: width expand)
   ========================================= */
.sidebar-menu {
  width: var(--sidebar-collapsed); /* collapsed (icons only) */
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: #fff;
  z-index: 2001;
  border-right: 1px solid #eee;
  overflow-x: hidden;
  transition: width 0.3s ease;
}

/* Expanded */
.sidebar-menu.active {
  width: var(--sidebar-width) !important;
}

/* Hide labels in collapsed state (desktop only) */
@media (min-width: 769px) {
  .sidebar-menu:not(.active) .menu-text,
  .sidebar-menu:not(.active) .nav-chevron,
  .sidebar-menu:not(.active) .sidebar-categories-title {
    display: none;
  }
}

/* Ensure close button is clickable */
.sidebar-close-btn {
  position: relative;
  z-index: 2102 !important;
  cursor: pointer;
}

/* Close button inside sidebar – visible only when menu is open */
.sidebar-menu:not(.active) .close-btn {
  display: none !important;
}
.sidebar-menu.active .close-btn {
  display: flex !important;
}
.sidebar-menu .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #334155;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.sidebar-menu .close-btn:hover {
  background: #f1f5f9;
}

.sidebar-menu .sidebar-categories-title {
  padding-top: 48px;
}

/* Content margin to make room for sidebar */
#main-content {
  margin-left: var(--sidebar-collapsed);
  transition: margin-left 0.3s ease;
}

/* When expanded push content */
body.sidebar-expanded #main-content {
  margin-left: var(--sidebar-width);
}

/* Menu toggle button */
.menu-reopen-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  order: -1;
  transition: transform 0.2s ease;
}

.menu-reopen-btn i {
  transition: transform 0.25s ease;
}

/* Rotate bars when open */
body.sidebar-expanded .menu-reopen-btn i {
  transform: rotate(90deg);
}

/* Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2050 !important;
  display: none;
}

/* =========================================
   Modals
   ========================================= */
#locationModal[aria-hidden="false"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.location-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
}
.location-suggestions li:hover {
  background: #f0fdf4;
}

/* =========================================
   Product Grid / Cards
   ========================================= */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px;
}

.product-card {
  background: #fff;
  border-radius: 16px;
  padding: 15px;
  text-align: center;
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;

  /* performance helpers */
  will-change: transform;
  contain: content;

  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.product-card img {
  width: 100%;
  height: 180px;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 12px;
}

/* =========================================
   Quantity Controls
   ========================================= */
.qty-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0;
  background: #f8f8f8;
  padding: 8px;
  border-radius: 50px;
}

.qty-control button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
}

/* =========================================
   Skeleton Loader
   ========================================= */
.skeleton {
  background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
  border-radius: 16px;
  background-size: 200% 100%;
  animation: shine 1.5s linear infinite;
}

@keyframes shine {
  to {
    background-position-x: -200%;
  }
}

.skeleton-card {
  padding: 15px;
  border: 1px solid #eee;
  border-radius: 16px;
  background: #fff;
  height: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-img {
  height: 180px;
  width: 100%;
}
.skeleton-title {
  height: 20px;
  width: 80%;
}
.skeleton-price {
  height: 24px;
  width: 40%;
}
.skeleton-btn {
  height: 40px;
  width: 100%;
  border-radius: 25px;
}

/* =========================================
   Mobile (Transform sidebar + no content push)
   ========================================= */
@media (max-width: 768px) {
  /* Sidebar becomes overlay drawer (JS should add/remove .active) */
  .sidebar-menu {
    width: 85%;
    max-width: 320px;
  }

  /* Don’t push content on mobile */
  #main-content {
    margin-left: 0 !important;
  }

  /* Lock background scroll when menu open */
  body.sidebar-expanded {
    overflow: hidden;
    touch-action: none;
  }

  /* CSS safety: show backdrop when expanded (even if JS lags) */
  body.sidebar-expanded .sidebar-backdrop {
    display: block;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 10px;
  }
}

/* =========================================
   Progress Track (dynamic width via CSS var)
   ========================================= */
.progress-track::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 0;
  width: var(--progress-width, 0%);
  height: 4px;
  background: var(--primary-green);
  z-index: 1;
  transition: width 1s ease-in-out;
}

/* =========================================
   Reduced Motion (accessibility + performance)
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================
   HOMEPAGE SEARCH BAR – FULL FIX
   (Paste at bottom of global.css)
   ========================================= */

/* Ensure nav layout is stable */
.main-header .top-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Let search bar grow naturally */
.main-header .search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  max-width: 700px;
}

/* Input wrapper (rounded pill) */
.main-header .search-bar .search-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #ffffff;
  min-width: 220px;
}

/* Search icon */
.main-header .search-bar .search-bar-icon {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 0.95rem;
}

/* Input field */
.main-header .search-bar input[type="search"] {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  height: 24px;
  line-height: 24px;
  font-size: 0.95rem;
  min-width: 0; /* Important for flex */
  appearance: none;
  -webkit-appearance: none;
}

/* Remove browser search decorations */
.main-header input[type="search"]::-webkit-search-decoration,
.main-header input[type="search"]::-webkit-search-cancel-button,
.main-header input[type="search"]::-webkit-search-results-button,
.main-header input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

/* Submit button */
.main-header .search-bar .search-submit-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 700;
  background: var(--primary-green);
  color: #ffffff;
  white-space: nowrap;
  transition: background 0.2s ease;
}

/* Hover */
.main-header .search-bar .search-submit-btn:hover {
  background: var(--hover-green);
}

/* Box sizing safety */
.main-header .search-bar *,
.main-header .search-bar *::before,
.main-header .search-bar *::after {
  box-sizing: border-box;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .main-header .search-bar {
    max-width: 100%;
  }

  .main-header .search-bar .search-submit-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
  }
}

/* =========================================================
   MOBILE HEADER LAYOUT (Phones)
   - Show: hamburger, logo, search, orders, cart
   - Hide: contact + account to avoid crowding
   - Keep everything fitting perfectly
   ========================================================= */

/* Ensure predictable sizing */
*,
*::before,
*::after { box-sizing: border-box; }

/* MOBILE */
@media (max-width: 768px) {

  /* Make the top nav wrap nicely instead of squishing weirdly */
  .main-header .top-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  /* Row 1: hamburger + logo + icons (orders/cart) */
  .menu-reopen-btn {
    order: 1;
    padding: 10px;
  }

  .top-nav-logo {
    order: 2;
    flex: 1;
    min-width: 120px;
    text-align: left;
    white-space: nowrap;
  }

  /* Put the icon nav on the right, same row */
  .main-header .site-nav {
    order: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
  }

  /* Hide only shop + contact on mobile; show orders, account, cart */
  .main-header .site-nav .site-nav-contact,
  .main-header .site-nav .site-nav-shop {
    display: none !important;
  }

  .main-header .site-nav .site-nav-orders,
  .main-header .site-nav .site-nav-account,
  .main-header .site-nav .site-nav-cart {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Tighten icons so they don't overflow */
  .main-header .site-nav a.site-nav-icon-only {
    padding: 8px 10px;
    border-radius: 12px;
  }

  /* Cart total text: keep it compact */
  .main-header .site-nav .site-nav-cart-total {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* Hide long label text on mobile (optional) */
  .main-header .site-nav .site-nav-label {
    display: none !important;
  }

  /* Row 2: Search bar full width */
  .main-header .search-bar {
    order: 4;
    width: 100%;
    flex: 0 0 100%;
    display: flex;
    gap: 8px;
    margin-top: 6px;
  }

  /* Search input wrapper */
  .main-header .search-bar .search-bar-wrap {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #fff;
  }

  .main-header .search-bar input[type="search"] {
    min-width: 0;
    font-size: 16px; /* IMPORTANT: prevents iOS zoom on focus */
  }

  /* Make the button smaller on mobile */
  .main-header .search-bar .search-submit-btn {
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  /* Ensure main content isn't pushed by sidebar on mobile (you already do this, keep it) */
  #main-content {
    margin-left: 0 !important;
  }

  /* Sidebar overlay should cover nicely */
  .sidebar-backdrop {
    display: none;
  }

  /* Product grid tighter */
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .product-card img {
    height: 150px;
  }

  /* Make tap targets comfortable */
  button, a, input {
    -webkit-tap-highlight-color: transparent;
  }
}
/* =========================
   Header icon nav polish
   ========================= */

/* Make the right-side nav a neat row */
.main-header .site-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Base style for icon links */
.main-header .site-nav a.site-nav-icon-only {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;                 /* space between icon + text (cart) */
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  line-height: 1;
  transition: background 0.18s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Icon size + crisp alignment */
.main-header .site-nav a.site-nav-icon-only i {
  font-size: 1.18rem;
  width: 22px;              /* keeps all icons aligned */
  text-align: center;
}

/* Hover / focus states (desktop & accessibility) */
.main-header .site-nav a.site-nav-icon-only:hover {
  background: rgba(45, 122, 50, 0.10);
  transform: translateY(-1px);
}

.main-header .site-nav a.site-nav-icon-only:focus-visible {
  outline: 3px solid rgba(45, 122, 50, 0.35);
  outline-offset: 2px;
}

/* Current page highlight (optional) */
.main-header .site-nav a.site-nav-current {
  background: rgba(45, 122, 50, 0.14);
}

/* Make the small label under Orders not awkward */
.main-header .site-nav .site-nav-label {
  display: none;            /* hide by default (clean header) */
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.85;
}

/* Cart total pill */
.main-header .site-nav .site-nav-cart-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  font-weight: 800;
  font-size: 0.86rem;
  white-space: nowrap;
}

/* Make cart look slightly “special” */
.main-header .site-nav a.site-nav-cart .site-nav-cart-total {
  background: rgba(45, 122, 50, 0.14);
}

/* -------------------------
   Mobile: keep only icons + cart total
   ------------------------- */
@media (max-width: 768px) {
  .main-header .site-nav {
    gap: 8px;
  }

  .main-header .site-nav a.site-nav-icon-only {
    padding: 10px;
    border-radius: 12px;
  }

  /* Hide text label on mobile (you wanted only main info) */
  .main-header .site-nav .site-nav-label {
    display: none !important;
  }

  /* Make the cart price smaller so header fits */
  .main-header .site-nav .site-nav-cart-total {
    padding: 5px 8px;
    font-size: 0.82rem;
  }
}

/* -------------------------
   Optional: show labels on wider screens
   ------------------------- */
@media (min-width: 1024px) {
  .main-header .site-nav .site-nav-label {
    display: inline;
  }
}
/* Section title accent = green */
.section-title .title-accent{
  color: var(--primary-green);
  font-weight: 800;
}
/* =========================
   HERO (Split)
   ========================= */
   .hero-split{
    background: linear-gradient(180deg,#ffffff 0%, #f7fbf7 100%);
    padding: 28px 16px 10px;
  }
  
  .hero-split-inner{
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 26px;
    align-items: center;
  }
  
  .hero-copy{
    background: #fff;
    border: 1px solid #eef2f6;
    border-radius: 22px;
    padding: 26px 24px;
    box-shadow: 0 8px 26px rgba(0,0,0,0.06);
  }
  
  .hero-kicker{
    margin: 0 0 10px;
    color: #64748b;
    font-weight: 700;
    font-size: 0.95rem;
  }
  
  .hero-link{
    color: var(--primary-green);
    font-weight: 800;
    text-decoration: underline;
  }
  
  .hero-title{
    margin: 0 0 10px;
    font-size: clamp(1.85rem, 3.2vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #0f172a;
  }
  
  .hero-subtitle{
    margin: 0 0 16px;
    color: #475569;
    font-size: 1.02rem;
  }
  
  .hero-actions{
    display:flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
  }
  
  .hero-cta, .hero-cta-ghost{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
    font-weight: 800;
    border-radius: 999px;
    padding: 12px 18px;
  }
  
  .hero-media{
    min-height: 320px;
    border-radius: 22px;
    border: 1px solid #eef2f6;
    box-shadow: 0 10px 28px rgba(0,0,0,0.08);
    background:
      linear-gradient(180deg, rgba(45,122,50,0.08), rgba(255,255,255,0.2)),
      url("assets/hero-groceries.jpg");
    background-size: cover;
    background-position: center;
  }
  
  /* Mobile hero stacks + image stays */
  @media (max-width: 768px){
    .hero-split-inner{
      grid-template-columns: 1fr;
      gap: 14px;
    }
    .hero-media{ min-height: 220px; }
  }
  /* =========================
   MOBILE HEADER: hamburger + search + orders + profile + cart
   ========================= */
@media (max-width: 768px){
  /* Hide only Shop + Contact on mobile */
  .main-header .site-nav .site-nav-contact,
  .main-header .site-nav .site-nav-shop{
    display: none !important;
  }

  /* Show Orders + Profile + Cart */
  .main-header .site-nav .site-nav-orders,
  .main-header .site-nav .site-nav-account,
  .main-header .site-nav .site-nav-cart{
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
}
/* =========================
   MOBILE PRODUCTS: vertical list
   Works for both .product-grid and category blocks
   ========================= */
   @media (max-width: 768px){
    /* 1 column */
    .product-grid{
      grid-template-columns: 1fr !important;
      padding: 12px !important;
    }
  
    /* If you render by category, inner grids should be 1 column too */
    .products-by-category .category-block-grid{
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
    }
  
    .product-card{
      flex-direction: row;
      align-items: center;
      text-align: left;
      gap: 12px;
      padding: 12px;
    }
  
    .product-card img{
      width: 108px;
      height: 92px;
      min-height: auto !important;
      border-radius: 14px;
      object-fit: cover;
      margin: 0;
      flex: 0 0 auto;
    }
  
    .product-card .product-info{
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
  
    .product-card .card-footer{
      margin-top: 8px;
    }
  
    .product-card h3{
      margin: 0;
      font-size: 1rem;
      line-height: 1.2;
    }
  
    .product-card .price{
      margin: 0;
      font-weight: 800;
    }
  }
  /* =========================
   MOBILE SIDEBAR: off-canvas drawer
   ========================= */
@media (max-width: 768px){
  .sidebar-menu{
    width: 85% !important;
    max-width: 320px;
    transform: translateX(-105%);
    transition: transform 0.28s ease;
  }

  .sidebar-menu.active{
    transform: translateX(0);
  }

  /* Make backdrop visible when expanded */
  body.sidebar-expanded .sidebar-backdrop{
    display:block !important;
  }

  /* Float close always on top */
  .sidebar-close-float{
    position: fixed;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: none;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 8px 26px rgba(0,0,0,0.18);
    font-size: 1.6rem;
    z-index: 2600;
  }
}
.section-title .title-main{
  color:#0f172a;
  font-weight: 800;
}
/* Header above sidebar when closed; below when sidebar open on mobile */
.main-header {
  position: sticky;
  top: 0;
  z-index: 1100;
}
@media (max-width: 768px) {
  body.sidebar-expanded .main-header {
    z-index: 1000;
  }
  body.sidebar-expanded .sidebar-menu,
  .sidebar-menu.active {
    z-index: 2700 !important;
  }
  body.sidebar-expanded .sidebar-backdrop {
    z-index: 2650 !important;
  }
  body.sidebar-expanded .sidebar-close-float {
    z-index: 2710 !important;
  }
}

/* Backdrop should NEVER block clicks unless sidebar is open */
.sidebar-backdrop {
  pointer-events: none;
}
body.sidebar-expanded .sidebar-backdrop {
  pointer-events: auto;
}
/* Checkout overlay must be a real overlay */
#checkout.checkout-section {
  position: fixed;
  inset: 0;
  z-index: 2550;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
}

/* =========================================
   Toast (floating, fade in/out)
   ========================================= */
.toast-float {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90vw;
}
.toast-float.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   Mobile optimization
   ========================================= */
@media (max-width: 480px) {
  .cta-primary,
  .add-to-cart-btn,
  button[type="submit"]:not(.search-submit-btn) {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    min-height: 48px;
    font-size: 16px; /* avoids iOS zoom on focus */
  }
  .cart-drawer-panel {
    max-width: 100%;
  }
}
@media (max-width: 768px) {
  .cart-drawer-panel {
    max-width: 100%;
  }
}
