/* Best CSS for the Products Section - Optimized, Modern, and Responsive */

/* Base styles for the products section */
#products {
  padding: 3rem 0;
  background-image: url('img/bg/6.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  color: #fff; /* Ensure text is visible on background */
}

/* Overlay for better readability on busy backgrounds */
#products::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /*background: rgba(0, 0, 0, 0.5);*/
  z-index: 1;
}

/* Ensure content is above overlay */
#products .container,
#products h2,
#products .alert,
#products #category-nav,
#products .tab-content {
  position: relative;
  z-index: 2;
}

#products .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

#products h2 {
  text-align: center;
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 3rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7); /* Text shadow for visibility */
}

#products .alert {
  text-align: center;
  margin-bottom: 1rem;
  border-radius: 0.375rem;
  padding: 0.75rem;
}

#products .alert-info {
  background-color: rgba(209, 236, 241, 0.9);
  color: #0c5460;
  border: 1px solid #bee5eb;
}

#products .alert-warning {
  background-color: rgba(255, 243, 205, 0.9);
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* Navigation for categories (horizontal scroll if needed) */
#category-nav {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255, 255, 255, 0.5) rgba(255, 255, 255, 0.1); /* Firefox */
}

#category-nav::-webkit-scrollbar {
  height: 4px; /* Webkit scrollbar */
}

#category-nav::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

#category-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
}

#category-nav .nav-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin: 0 0.25rem;
  text-decoration: none;
  color: #007bff;
  background-color: rgba(248, 249, 250, 0.9);
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0; /* Prevent shrinking */
}

#category-nav .nav-link.active {
    margin-top: 50px;
  background-color: #007bff;
  color: white;
  transform: scale(1.05); /* Slight scale for active state */
}

#category-nav .nav-link:hover {
  background-color: #e9ecef;
  transform: translateY(-0.125rem); /* Lift effect */
}

/* Tab content */
.tab-content {
  display: block;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.5s ease-in-out; /* Smooth transition */
}

.tab-pane.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Row and column layout using Flexbox */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.col-md-4, .col-sm-6 {
  flex: 0 0 33.333333%;
  max-width: 33.333333%;
  padding: 0 15px;
  margin-bottom: 1.5rem;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .col-md-4, .col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

@media (max-width: 576px) {
  .col-md-4, .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Card styles */
.card {
  /*border: 1px solid #dee2e6;*/
  border-radius: 0.5rem;
  overflow: hidden;
  /*box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);*/
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.95); /* Semi-transparent for overlay compatibility */
  color: #333;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-img-top {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover .card-img-top {
  transform: scale(1.05);
}

.card-body {
  text-align: center;
  padding:0 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #495057;
}

.card-text {
  flex-grow: 1;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #6c757d;
  line-height: 1.5;
}

.text-muted {
  color: #868e96;
  font-size: 0.875rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  align-self: flex-start;
  margin-top: auto;
  cursor: pointer;
}

.btn-primary {
  background-color: #007bff;
  border-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
  border-color: #004085;
  transform: translateY(-0.125rem);
}

.btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
  border-color: #4e555b;
  transform: translateY(-0.125rem);
}

.text-center {
  text-align: center;
}

/* Print-specific styles to force 3 columns and optimize for printing */
@media print {
  body {
    font-size: 12px;
    line-height: 1.4;
    color: #000;
  }

  #products {
    background: none; /* Remove background image */
    padding: 1rem 0;
    color: #000;
  }

  #products::before {
    display: none; /* Remove overlay */
  }

  #products h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #000;
  }

  #category-nav {
    display: none; /* Hide navigation */
  }

  .tab-content .tab-pane {
    display: block !important; /* Show all tabs */
  }

  .row {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Force 3 columns */
    gap: 1rem;
    margin: 0;
  }

  .col-md-4, .col-sm-6 {
    flex: none;
    max-width: none;
    padding: 0;
    margin-bottom: 1rem;
  }

  .card {
    box-shadow: none;
    border: 1px solid #000;
    page-break-inside: avoid; /* Avoid breaking cards */
    background-color: #fff;
    color: #000;
  }

  .card-img-top {
    height: 150px; /* Smaller images */
    filter: grayscale(100%); /* Optional: make images grayscale for print */
  }

  .card-body {
    padding: 0.5rem;
  }

  .card-title {
    font-size: 1rem;
    color: #000;
  }

  .card-text {
    font-size: 0.75rem;
    color: #000;
  }

  .btn {
    display: none; /* Hide buttons */
  }

  .alert {
    border: none;
    background: none;
    color: #000;
    font-weight: bold;
  }

  #products .container {
    padding: 0;
  }
}
