/* --- Container Setup --- */
.product-cards-main-container {
  padding: 80px 20px;
  min-height: 80vh;
}

@media (max-width: 991px) {
  .product-cards-main-container {
    padding: 60px 10px;
  }
}

h1 {
  text-align: center;
  margin-bottom: 20px;
}

/* --- Product Grid Layout --- */
#productsContainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;

  .inactive {
    pointer-events: none;

    .product-info {
      .product-bag-price {
        margin-top: var(--padding-m);
        font-size: var(--font-size-xxl);
        color: var(--color-red);
        opacity: 0.5;
      }
    }
  }
}
#productsContainer:has(> :only-child),
#productsContainer:has(> :nth-child(2):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(320px, auto));
  justify-content: center;
}


@media (max-width: 991px) {
  #productsContainer {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 767px) {
  #productsContainer {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 445px) {
  #productsContainer {
    grid-template-columns: repeat(1, 1fr);
    gap: 10px;
    padding: 0px 5px;

    .product-card {
      display: flex;
      flex-direction: row;

      .quantity-select {
        width: 85%;
        margin-top: 3px;
      }
    }

    .product-info {
      padding: 16px;
      width: 200px;
      flex: 100%;
      display: flex;
      flex-direction: column;
      text-align: left;
    }

    .product-card-image {
      height: 250px;
      align-self: center;
    }
  }


}

/* --- Product Card --- */
.product-card {
  border-radius: var(--padding-s);
  padding: 15px;
  box-shadow: var(--product-card-shadow);
  background: var(--color-white);
  border: 1px solid var(--color-gray);
  text-align: center;
  transition: transform 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* .product-card {
  border: 0.5px solid;
} */

.product-card:hover {
  transform: translateY(-5px);
}

/* --- Image Container --- */
.product-card-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--padding-s);
}

@media (max-width: 767px) {
  .product-card-image {
    height: 160px;
  }
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* --- Text & Price --- */
.product-name {
  font-size: var(--font-size-xxl);
  margin-bottom: var(--padding-s);
  color: var(--Primary-Text);
}

.quantity-select {
  width: 60%;
  padding: 8px;
  margin-bottom: var(--padding-s);
  font-size: 16px;
  border-radius: 8px;
}

.error-message {
  font-size: var(--font-size-m);
  margin-bottom: 0px;
}



.price-info {
  margin-bottom: var(--padding-s);
}

.price,
.price-per-kg {
  display: block;
  font-weight: bold;
  margin: 5px 0;
}

/* --- Dashboard Button --- */
#go-to-dashboard {
  display: block;
  margin: 30px auto 0;
  padding: 12px 20px;
  background: var(--primary-color);
  color: var(--color-white);
  font-size: 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.dashboard.active {
  h3 {
    font-size: var(--font-size-xl);
    text-align: center;
    font-weight: var(--font-weight-s);
  }
}

/* --- Skeleton Loader --- */
.skeleton-card {
  height: 220px;
  background: var(--skeleton-background-light);
  animation: pulse 1s infinite;
  border-radius: 10px;

  @media (max-width: 445px) {
    display: flex;
    flex-direction: row;
  }
}

.skeleton-img {
  width: 100%;
  height: 150px;
  background: var(--skeleton-background);
  border-radius: 10px;
  margin-bottom: 10px;

  @media (max-width: 445px) {
    width: 50%;
    height: 200px;

  }
}

.skeleton-name,
.skeleton-quantity {
  background: var(--skeleton-background);
  border-radius: 5px;
  margin: 5px auto;
}

.skeleton-name {
  width: 80%;
  height: 20px;
}

.skeleton-quantity {
  width: 50%;
  height: 20px;
}

@keyframes pulse {

  0%,
  100% {
    background-color: var(--skeleton-background-light);
  }

  50% {
    background-color: var(--skeleton-background);
  }
}

/* --- Quantity Button Actions --- */
.actions {
  margin-top: 10px;
  display: flex;
  flex-direction: row;
  justify-content: center;

  @media (max-width: 445px) {
    justify-content: start;

  }
}

.actions button {
  padding: 6px 10px;
  margin: 0 5px;
  border: 1px solid var(--primary-color);
  background-color: var(--primary-color);
  color: var(--color-white);
  border-radius: 8px;

  &:hover {
    background-color: var(--color-white);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
  }

  &:active {
    background-color: var(--color-white);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
  }
}

/* --- Dashboard Styles --- */
.dashboard-container .cart-summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.cart-summary-table th,
.cart-summary-table td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: center;
}

.cart-summary-table thead {
  background-color: #f2f2f2;
}

.cart-summary-table tfoot td {
  background-color: #eee;
}

#dashboard-overlay {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: 33%;
  transform:  translateY(100%); /* Center horizontally and start off-screen */
  background: var(--color-white);
  border-top: 2px solid #e0e0e0;
  padding: 16px 24px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Faster, smoother transition */
  opacity: 0;
  pointer-events: none;
  border-radius: 15px;

  @media (min-width:1024px) {
    left:35%;
  }
}

#dashboard-overlay.active {
  transform: translateY(0%); /* Center and slide up */
  opacity: 1;
  pointer-events: auto;
}

#dashboard-overlay.active {
  /* transform: translateY(0%);
  opacity: 1;
  pointer-events: auto;
  z-index: 1000;
  border-radius: var(--padding-s);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); */
}
.Error {
  text-align: center;
  padding: 20px;
  color: #dc3545;
  font-size: 1.2em;
}
.retry-btn {
  margin-top: 10px;
  padding: 10px 20px;
  background-color: #28a745;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}
.retry-btn:hover {
  background-color: #218838;
}


@media (max-width: 991px) {
  #dashboard-overlay {
    left: 20%;
    width: 70%;
  }
}

@media (max-width: 576px) {
  #dashboard-overlay {
    left: 0;
    width: 100%;
  }
}

#dashboard-overlay.hidden {
  display: none;
}

#dashboard-content {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-left: var(--padding-s);

  .tfoot{
    border-top:#999 1px solid;
    border-bottom: #999 1px solid;
  }
}

#dashboard-content div {
  padding: 8px 0;
  font-size: 1rem;
  color: #444;
  border-bottom: 1px solid #f0f0f0;
}

#dashboard-content div:last-child {
  border-bottom: none;
}

#checkout-final {
  background-color: var(--color-white);
  color: var(--primary-color);
  font-weight: bold;
  font-size: var(--font-size-m);
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid var(--primary-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;

  .fa-truck {}
}

#checkout-final:hover {
  background-color: var(--primary-color);
  color: var(--color-white);
  border: 1px solid #ccc;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.close-btn {
  position: absolute;
  right: 12px;
  top: 8px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #555;

  .fa-circle-xmark {
    color: var(--color-red);
  }
}

.dashboard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#modify-cart {
  background-color: var(--color-white);
  color: var(--GoGreen);
  border: 1px solid var(--GoGreen);
  font-size: var(--font-size-m);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;

  .fa-pen-to-square {
    position: relative;
    right: 5px;

  }
}

#modify-cart:hover {
  background: var(--GoGreen);
  color: var(--color-white);
  border: 1px solid #ccc;
}

/* --- Inactive & Out of Stock --- */
.product-card.inactive {
  pointer-events: none;
  opacity: 0.5;

  .product-bag-price {
    font-size: var(--font-size-xl);
  }
}

.product-card.inactive .product-name {
  color: var(--color-gray);
}

.product-card.inactive .product-img {
  filter: grayscale(100%);
}

.product-card.inactive .product-img:hover {
  filter: grayscale(100%);
}

.product-card.inactive .product-name:hover {
  color: var(--color-gray);
}

.product-card.inactive .price-info {
  color: var(--color-gray);
}

.product-card.inactive .price,
.product-card.inactive .price-per-kg {
  color: var(--color-gray);
}

.product-card.inactive .add-to-cart {
  background-color: var(--color-gray);
  color: var(--color-white);
  cursor: not-allowed;
}

.product-card.inactive .add-to-cart:hover {
  background-color: var(--color-gray);
  color: var(--color-white);
  box-shadow: none;
}

.product-card.inactive .add-to-cart:focus {
  outline: none;
  box-shadow: none;
}

.product-card.inactive:hover {
  transform: none;
}

.product-card.inactive .add-to-cart {
  background-color: var(--Soft-Shadow);
  cursor: not-allowed;
}

.product-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin: 10px 0 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* Limit to 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.product-type {
  font-size: 0.80rem;
  color: #777;
  margin-bottom: 10px;
  text-transform: capitalize;
}

.product-bag-price {
  font-size: var(--font-size-l);
  color: var(--Primary-Text);
  font-weight: var(--font-weight-m);
  margin: 0px;
}

/* --- Search & Filter --- */
#search-filter-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin: 2rem 0;
  justify-content: center;
  padding: 0 1rem; /* Added padding for better spacing on smaller screens */
}

.search-box,
.filter-box {
  position: relative;
  display: flex;
  align-items: center;
  width: auto; /* Ensure boxes don't stretch unnecessarily */
}

.search-box i,
.filter-box i {
  position: absolute;
  left: 12px;
  color: #6b7280; /* Updated to a modern gray for better contrast */
  font-size: 1.1rem; /* Slightly larger icon for visibility */
  pointer-events: none; /* Prevent icons from interfering with input */
}

#search-input,
#type-filter {
  padding: 12px 16px 12px 40px; /* Adjusted padding for larger icons */
  border: 1.5px solid var(--GoGreen, #22c55e); /* Fallback color if variable undefined */
  border-radius: 10px; /* Slightly larger radius for smoother look */
  font-size: 1rem;
  outline: none;
  min-width: 240px; /* Slightly wider for better usability */
  transition: all 0.3s ease; /* Smooth transition for all changes */
  background-color: #f9fafb; /* Light background for input fields */
  color: #111827; /* Dark text for readability */
}
#type-filter{
   padding: 12px 16px 12px 16px;
   min-width: 150px;
   background-color: #e0ede5;
}
@media (min-width: 556px) {
#search-input{
  border-right: none;
}
#type-filter {
  position: relative;
  right:15px; /* Adjusted to align with search input */
  width: auto; /* Allow width to adjust based on content */
  border-radius: var(--padding-s); /* Rounded corners for right side */
}
}
#search-input:focus,
#type-filter:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15); /* Softer, larger shadow */
  background-color: #fff; /* White background on focus */
}

/* Ensure dropdown has consistent styling */
#type-filter {
  appearance: none; /* Remove default dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); /* Custom arrow */
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 1.2rem;
  padding-right: 40px; /* Space for custom arrow */
}

/* Hover effects for interactivity */
#search-input:hover,
#type-filter:hover {
  border-color: #16a34a; /* Darker green on hover */
  background-color: #fff;
}

@media (max-width: 600px) {
  #search-filter-container {
    flex-direction: column;
    gap: 1rem; /* Consistent gap in mobile view */
    padding: 0 0.5rem;
  }

  #search-input,
  #type-filter {/* Full width for mobile */
    min-width: 0; /* Override min-width for mobile */
    font-size: 0.95rem; /* Slightly smaller font for mobile */
  }

  .search-box,
  .filter-box {
    width: 100%; /* Ensure boxes take full width */
  }
}

.actions.action-visible {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);

  @media (max-width: 445px) {
    justify-content: start;
  }
}


.actions button.decrease,
.actions button.increase {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--primary-color);
  border-radius: 4px;
  background-color: #ffffff;
  color: var(--primary-color);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.actions button.decrease:hover,
.actions button.increase:hover {
  transform: scale(1.05);
}

.actions button.decrease:active,
.actions button.increase:active {
  transform: scale(0.95);
}

.actions button.decrease:disabled,
.actions button.increase:disabled {
  background-color: #e0e0e0;
  color: #999;
  cursor: not-allowed;
  transform: none;
}

.actions .qty {
  width: 32px;
  height: 32px;
  text-align: center;
  align-content: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--Primary-Text);
  border: 1px solid var(--GoGreen);
}

th {
  padding: 0px 5px;
}

td:not(:nth-child(1)) {
  text-align: center;
}

.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  /* Add subtle scaling for depth */
  filter: blur(2px);
  /* Slight blur for a soft entry */
  transition:
    opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    /* Smooth ease for opacity */
    transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    /* Smooth ease for transform */
    filter 0.8s ease-out;
  /* Blur fades out smoothly */
  will-change: opacity, transform, filter;
  /* Optimize for performance */
}

.fade-in-on-scroll.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  /* Scale back to normal */
  filter: blur(0);
  /* Remove blur */
}

/* Optional: Staggered animation for multiple elements */
.fade-in-on-scroll {
  transition-delay: 0s;
  /* Default delay */
}

.fade-in-on-scroll:nth-child(2n) {
  transition-delay: 0.1s;
  /* Slight stagger for every other element */
}

.fade-in-on-scroll:nth-child(3n) {
  transition-delay: 0.2s;
  /* Further stagger for every third element */
}

/* Ensure smooth animation on mobile */
@media (prefers-reduced-motion: reduce) {
  .fade-in-on-scroll {
    transition: none;
    /* Respect user preference for reduced motion */
  }

  .fade-in-on-scroll.visible {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

#filtered-count {
  text-align: right;
  padding: 0px 10px;
  font-size: var(--font-size-l);
  color: var(--Primary-Text);
  font-weight: var(--font-weight-s);
  margin-top: 20px;
  margin-bottom: 10px;
}

/* Error Message */
.Error {
  grid-column: 1 / -1;
  /* Span all columns in the grid */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  color: #e74c3c;
  /* Red for error */
  font-weight: 500;
  text-align: center;
  padding: 20px;
  background-color: #fff;
  border: 1px solid #e74c3c;
  border-radius: 8px;
  margin: 20px auto;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.Error .fa-face-sad-tear {
  font-size: 24px;
  color: #e74c3c;
}

/* Responsive Design */
@media (max-width: 768px) {
  .Error {
    font-size: 16px;
    padding: 15px;
    margin: 15px auto;
    max-width: 300px;
  }

  .Error .fa-face-sad-tear {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .Error {
    font-size: 14px;
    padding: 10px;
    margin: 10px auto;
    max-width: 250px;
  }

  .Error .fa-face-sad-tear {
    font-size: 18px;
  }
}