/* ================= RESET SAFETY ================= */
* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ================= TOOLBAR ================= */
.products-toolbar {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 20px;
  align-items: center;
  margin: 40px auto 20px;
  position: relative;
  z-index: 10;
}

.categories-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

#catArrow {
  transition: transform 0.3s ease;
}

#catArrow.rotate {
  transform: rotate(-90deg);
}

/* ================= SEARCH + SORT ================= */
.search-sort {
  display: flex;
  gap: 15px;
  align-items: center;
}

.product-search {
  position: relative;
  flex: 1;
}

.product-search input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 18px;
  border-radius: 25px;
  border: 1px solid #ccc;
}

.product-search button {
  position: absolute;
  right: 15px;
  top: 0;
  height: 100%;
  background: none;
  border: none;
  cursor: pointer;
}

.product-sort select {
  height: 44px;
  padding: 0 16px;
  border-radius: 25px;
  border: 1px solid #ccc;
}

/* ================= VIEW BUTTONS ================= */
.product-actions {
  display: flex;
  gap: 10px;
}

.view-btn {
  padding: 8px 10px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.view-btn.active,
.view-btn:hover {
  background: #e53935;
  color: #fff;
  border-color: #e53935;
}

/* ================= MAIN LAYOUT ================= */
.products-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
}

/* ================= CATEGORIES ================= */
.categories-panel {
  max-height: 600px;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.categories-panel.hide {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-list li {
  padding: 10px 0;
}

.category-list li a {
  font-size: 14px;
  display: block;
  transition: padding-left 0.25s ease, color 0.25s ease;
}

.category-list li a:hover {
  padding-left: 8px;
  color: #2e7d32;
}

.category-list li.active a {
  color: #e53935;
  font-weight: 600;
}

/* ================= PRODUCTS GRID ================= */
.products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 25px;
}

.product-card {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  position: relative;
}

.product-image {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 6px;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ================= HOVER ICONS ================= */
.product-hover {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.product-card:hover .product-hover {
  opacity: 1;
}

.product-hover button,
.product-hover a {
  width: 46px;
  height: 46px;
  background: #fff;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  z-index: 2;
}

.product-hover i {
  font-size: 18px;
  color: #333;
  transition: color 0.25s ease;
}

.product-hover button:hover,
.product-hover a:hover {
  background: #e53935;
}

.product-hover button:hover i,
.product-hover a:hover i {
  color: #fff;
}

.product-card h4 {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

/* ================= LIST VIEW ================= */
.products.list-view {
  grid-template-columns: 1fr;
}

.products.list-view .product-card {
  display: flex;
  gap: 16px;
  align-items: center;
}

.products.list-view .product-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.products.list-view .product-hover {
  position: static;
  background: none;
  opacity: 1;
  margin-top: 6px;
}

.products.list-view .product-info {
  display: flex;
  flex-direction: column;
}

/* ================= PAGINATION ================= */
.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 40px 0;
}

.page {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-weight: 600;
}

.page:hover {
  background: #2e7d32;
  color: #fff;
}

.page.active {
  background: #2e7d32;
  color: #fff;
  pointer-events: none;
}

/* ================= FILTER DRAWER ================= */
.filter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  z-index: 999;
}

.filter-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: 85%;
  height: 100%;
  background: #fff;
  z-index: 1000;
  padding: 20px;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.filter-drawer.open {
  right: 0;
}

.filter-overlay.show {
  display: block;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.filter-header button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.filter-section {
  margin-top: 20px;
}

.filter-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.filter-title i {
  transition: transform 0.3s;
}

.filter-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: none;
}

.filter-list li {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.filter-list a {
  text-decoration: none;
  color: #333;
}

.filter-signin {
  margin-top: auto;
  border-top: 1px solid #eee;
  padding-top: 20px;
}

.filter-signin a {
  display: block;
  text-align: center;
  padding: 12px;
  background: #e53935;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

/* ================= MOBILE ONLY ================= */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
  }
}

/* ================= MOBILE ================= */
@media (max-width: 768px) {
  .products-page {
    display: block;
  }

  .categories-header,
  .categories-panel,
  .product-sort {
    display: none !important;
  }

  .products-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
  }

  .search-sort {
    flex: 1;
    display: flex;
  }

  .product-search {
    flex: 1;
  }

  .product-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    justify-content: flex-end;
  }

  .view-btn {
    padding: 6px 8px;
  }

  .products {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .product-image {
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .product-hover {
    position: static;
    background: none;
    opacity: 1;
    margin-top: 6px;
  }

  .product-hover button {
    width: 36px;
    height: 36px;
  }

  .product-card h4 {
    font-size: 14px;
  }
}

/* ================= CLICK SAFETY ================= */
.product-link,
.product-card,
.products,
.products-page,
.products-toolbar {
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

/* ================= CART TOAST ================= */
.cart-toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2e7d32;
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: all 0.35s ease;
}

.cart-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes cartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.cart-pop {
  animation: cartPop 0.4s ease;
}

.hidden {
  display: none !important;
}