/* ============================================================
   product.css — Products page
   Requires: shared.css loaded first
   ============================================================ */

/* ============================================================
   PRODUCTS SECTION
   ============================================================ */
.products-section {
  padding: 3rem 0 5rem;
  min-height: 60vh;
}

/* ============================================================
   TOOLBAR (search + filters + view toggle)
   ============================================================ */
.products-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Search bar */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  min-width: 220px;
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(45,106,45,0.1);
}
.search-icon {
  padding: 0 0.75rem 0 1.1rem;
  color: var(--clr-text-muted);
  font-size: 0.9rem;
  pointer-events: none;
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 0.75rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--clr-text-primary);
  min-width: 0;
}
.search-bar input::placeholder { color: var(--clr-text-muted); }
.search-bar button {
  background: var(--clr-primary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.search-bar button:hover { background: var(--clr-primary-dark); }

/* Toolbar right: pills + view toggle */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Category filter pills */
.filter-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pill {
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  color: var(--clr-text-secondary);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.pill:hover { border-color: var(--clr-primary); color: var(--clr-primary); }
.pill.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* View toggle */
.view-toggle { display: flex; gap: 0.35rem; }
.view-btn-toggle {
  width: 38px; height: 38px;
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  color: var(--clr-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition);
}
.view-btn-toggle:hover { border-color: var(--clr-primary); color: var(--clr-primary); }
.view-btn-toggle.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* Results count */
.results-bar { margin-bottom: 1.5rem; }
.results-count {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  font-weight: 500;
}

/* Cart badge in nav */
.cart-nav-link { position: relative; }
.cart-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--clr-accent);
  color: #1a2e1a;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px; height: 18px;
  border-radius: var(--radius-full);
  padding: 0 4px;
  margin-left: 2px;
  vertical-align: middle;
}

/* ============================================================
   PRODUCT GRID — GRID MODE
   ============================================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
}

/* ============================================================
   PRODUCT CARD
   ============================================================ */
.product-card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}
.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(45,106,45,0.2);
}

/* Stock badge */
.stock-badge {
  position: absolute;
  top: 0.75rem; left: 0.75rem;
  z-index: 2;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--clr-border);
  color: var(--clr-primary);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}
.stock-badge.out { color: #e53e3e; border-color: #fed7d7; background: rgba(255,245,245,0.95); }

/* Product image */
.product-image {
  height: 210px;
  overflow: hidden;
  background: var(--clr-surface-2, #eef7ec);
  position: relative;
}
.product-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.55s var(--ease);
}
.product-card:hover .product-image img { transform: scale(1.07); }

/* Product info */
.product-info { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }

.product-category {
  font-family: var(--font-heading);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--clr-primary);
  margin-bottom: 0.4rem;
}

.product-title {
  font-family: var(--font-heading);
  font-size: 0.975rem; font-weight: 700;
  color: var(--clr-text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 2; /* standard property for future compatibility */
}

.product-price {
  font-family: var(--font-heading);
  font-size: 1.2rem; font-weight: 800;
  color: var(--clr-primary);
  margin-bottom: 0.75rem;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.product-meta .meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}
.product-meta .meta-tag i { font-size: 0.68rem; }

/* Product actions */
.product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: auto;
}
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.view-btn {
  background: rgba(45,106,45,0.08);
  color: var(--clr-primary);
  border: 1.5px solid rgba(45,106,45,0.2);
}
.view-btn:hover {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}
.addtocart-btn {
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent-dark));
  color: #1a2e1a;
  box-shadow: 0 2px 8px rgba(244,166,35,0.25);
}
.addtocart-btn:hover {
  background: linear-gradient(135deg, var(--clr-accent-light), var(--clr-accent));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(244,166,35,0.4);
}
.addtocart-btn:disabled,
.addtocart-btn.disabled {
  background: #e0e0e0;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   LIST MODE
   ============================================================ */
.product-grid.list-mode {
  grid-template-columns: 1fr;
}
.product-grid.list-mode .product-card {
  flex-direction: row;
  align-items: stretch;
}
.product-grid.list-mode .product-image {
  width: 200px;
  height: auto;
  min-height: 160px;
  flex-shrink: 0;
}
.product-grid.list-mode .product-info {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}
.product-grid.list-mode .product-title {
  flex: 1 1 220px;
  -webkit-line-clamp: 1;
  line-clamp: 1; /* standard property for future compatibility */
  margin-bottom: 0;
}
.product-grid.list-mode .product-price { margin-bottom: 0; }
.product-grid.list-mode .product-meta { margin-bottom: 0; }
.product-grid.list-mode .product-actions {
  grid-template-columns: 1fr 1fr;
  min-width: 220px;
  margin-top: 0;
}

/* ============================================================
   SKELETON LOADERS
   ============================================================ */
.skeleton-card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--clr-border);
  overflow: hidden;
  height: 380px;
  position: relative;
}
.skeleton-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    #e8f0e8 0%, #e8f0e8 55%,
    var(--clr-surface) 55%
  );
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--clr-text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--clr-border);
}
.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem; font-weight: 700;
  color: var(--clr-text-secondary);
  margin-bottom: 0.5rem;
}
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }
.reset-btn {
  background: var(--clr-primary);
  color: #fff; border: none;
  padding: 0.7rem 1.75rem;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.reset-btn:hover { background: var(--clr-primary-dark); transform: translateY(-1px); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}
.pagination a {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.875rem; font-weight: 600;
  color: var(--clr-text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination a:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}
.pagination a.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* ============================================================
   RESPONSIVE — TABLET (max 900px)
   ============================================================ */
@media (max-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  }
  .product-grid.list-mode .product-image {
    width: 160px;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE (max 640px)
   ============================================================ */
@media (max-width: 640px) {
  .products-section { padding: 2rem 0 4rem; }

  /* Toolbar stacks vertically */
  .products-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .search-bar { flex: 1 1 auto; }

  .toolbar-right {
    justify-content: space-between;
    width: 100%;
  }

  /* Pills scroll horizontally */
  .filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    flex: 1;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .pill { flex-shrink: 0; }

  /* Grid: 2 cards per row on mobile */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
  }

  .product-image { height: 150px; }

  .product-info { padding: 0.875rem; }

  .product-title { font-size: 0.855rem; }
  .product-price { font-size: 1rem; margin-bottom: 0.5rem; }

  .product-meta { display: none; } /* hide meta tags on mobile for space */

  /* Actions stack in a column */
  .product-actions {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .action-btn { padding: 0.6rem 0.5rem; font-size: 0.78rem; }

  /* Disable list mode on mobile */
  .product-grid.list-mode {
    grid-template-columns: repeat(2, 1fr);
  }
  .product-grid.list-mode .product-card { flex-direction: column; }
  .product-grid.list-mode .product-image { width: 100%; height: 150px; }
  .product-grid.list-mode .product-info { flex-direction: column; }
  .product-grid.list-mode .product-actions { min-width: auto; grid-template-columns: 1fr; }

  /* Skeleton */
  .skeleton-card { height: 280px; }

  /* Pagination compact */
  .pagination a { width: 36px; height: 36px; font-size: 0.8rem; }
}

/* ============================================================
   RESPONSIVE — VERY SMALL (max 360px)
   ============================================================ */
@media (max-width: 360px) {
  .product-grid { grid-template-columns: 1fr; }
  .product-image { height: 200px; }
  .product-actions { grid-template-columns: 1fr 1fr; }
}
