/* --- 1. GLOBAL RESET --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  overflow-x: hidden; /* Prevents horizontal shaking/scrolling */
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #e6e6e6;
  color: #333;
}

/* --- 2. LAYOUT WRAPPERS --- */
.products-container {
  width: 100%;
  padding-bottom: 50px;
}

.latest-header {
  background-color: #ff0000;
  color: white;
  text-align: center;
  padding: 15px;
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* --- 3. THE GRID SYSTEM --- */
.product-grid {
  display: grid;
  /* Desktop Default: 4 columns */
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
  padding: 40px 5%;
  width: 100%;
}

/* --- 4. THE PRODUCT CARD --- */
.product-item {
  background: #fff;
  padding: 20px;
  border-radius: 15px;
  text-align: center;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  min-width: 0; /* Critical for Grid shrinking */
}

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

/* --- 5. CARD CONTENT --- */
.p-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
}

.p-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.p-type {
  color: #006837;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
}

.p-weight {
  color: #006837;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.p-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto; /* Pushes price to bottom */
  padding: 10px 0;
}

.p-price {
  color: #006837;
  font-size: 1.3rem;
  font-weight: 800;
}

.btn-order-now {
  width: 100%;
  background-color: #024626;
  color: white;
  text-decoration: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

/* --- THE SHOP LAYOUT --- */
/* --- SHOP LAYOUT WRAPPER --- */
.shop-layout {
  display: flex;
  gap: 30px;
  padding: 40px 5%;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start; /* Crucial for sticky to work */
}

/* --- SIDEBAR (Desktop) --- */
.sidebar {
  flex: 0 0 280px; /* Fixed width for sidebar */
  background: #fff;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 20px; /* Distance from top of screen when scrolling */
  z-index: 10;
}

.sidebar h3 {
  margin-bottom: 20px;
  color: #006837;
  font-size: 1.4rem;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 10px;
}

.category-list {
  list-style: none;
}

.category-list li {
  margin-bottom: 8px;
}

.category-list a {
  text-decoration: none;
  color: #444;
  font-size: 1.05rem;
  display: block;
  padding: 12px 15px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* Hover & Active States */
.category-list a:hover,
.category-list a.active {
  background-color: #006837;
  color: #fff !important;
  padding-left: 22px;
}

/* --- MAIN CATALOG AREA --- */
.main-catalog {
  flex: 1; /* Takes up remaining space */
  min-width: 0; /* Prevents grid from pushing sidebar out */
}

/* --- MOBILE RESPONSIVE (Samsung A16 / Narrow Screens) --- */
@media (max-width: 850px) {
  .shop-layout {
    flex-direction: column; /* Stack sidebar on top of products */
    padding: 15px;
    gap: 15px;
  }

  .sidebar {
    flex: none;
    width: 100%;
    position: relative; /* Remove sticky on mobile */
    top: 0;
    padding: 15px;
  }

  /* Transform category list into a horizontal scroll bar */
  .category-list {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 10px;
    /* Hide scrollbar for a cleaner look */
    scrollbar-width: none;
  }

  .category-list::-webkit-scrollbar {
    display: none;
  }

  .category-list li {
    flex: 0 0 auto; /* Prevents categories from shrinking */
  }

  .category-list a {
    background: #f0f0f0;
    padding: 8px 20px;
    font-size: 0.9rem;
    white-space: nowrap; /* Keeps names on one line */
  }
}
/* --- THE MAIN CATALOG AREA --- */
.main-catalog {
  flex: 1;
  min-width: 0; /* Critical: prevents grid from breaking container */
}

/* --- THE GRID (The "Magic" Part) --- */
.product-grid {
  display: grid;
  /* This tells the browser: "Fit as many as possible, but cards must be at least 250px wide" */
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
  width: 100%;
}

/* --- THE PRODUCT CARD --- */
.product-item {
  background: #fff;
  padding: 20px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  /* Force all cards in a row to be the same height */
  height: 100%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

/* --- IMAGE SCALING --- */
.p-image {
  width: 100%;
  aspect-ratio: 1 / 1; /* Keeps the box square */
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  border-radius: 10px;
  overflow: hidden;
}

.p-image img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain; /* Ensures the whole jar is visible */
}

/* --- TITLE & TEXT --- */
.p-weight {
  color: #006837;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 10px;
  /* Force title area to be same height across all cards */
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.p-meta {
  margin-top: auto; /* Pushes price and button to the very bottom of the card */
  padding-top: 15px;
}

/* --- MOBILE RESPONSIVE (Samsung A16 / Narrow Screens) --- */
@media (max-width: 600px) {
  .product-grid {
    /* On small phones, force EXACTLY 2 columns, ignoring the 250px rule */
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    padding: 0;
  }

  .product-item {
    padding: 12px;
    /* Lower the min-height for mobile to keep it compact */
  }

  .p-weight {
    font-size: 0.9rem;
    min-height: 2.4em;
  }

  .p-price {
    font-size: 1.1rem;
  }
}
