:root {
  --primary-color: #4361ee;
  --secondary-color: #3f37c9;
  --accent-color: #4cc9f0;
  --dark-color: #1a1a2e;
  --light-color: #f8f9fa;
  --success-color: #4bb543;
  --warning-color: #f9a826;
  --danger-color: #f72585;
  --border-radius: 12px;
  --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f5f7ff;
  color: var(--dark-color);
  padding: 2rem;
  padding-top: 20px; /* Reduced padding to reduce space between header and top */
  min-height: 100vh;
}

/* Fix layout for product pages with Bootstrap carousel */
body.product-page {
  padding: 0 !important;
}

body.product-page .container {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}

.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  background: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
}

.view-toggle button {
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.view-toggle button.active {
  background: var(--primary-color);
  color: white;
}

.view-toggle button:first-child {
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.view-toggle button:last-child {
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.filter-sort {
  display: flex;
  gap: 1rem;
}

select,
.search-input {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  min-width: 150px;
}

.search-input {
  padding-left: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%231a1a2e' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
  background-size: 1rem;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.products-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.product-card {
  background: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.products-list .product-card {
  flex-direction: row;
  height: auto;
}

.products-list .product-image {
  width: 200px;
  height: auto;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.product-image,
.card-img-top {
  width: 100%;
  height: 200px;
  object-fit: cover;
  aspect-ratio: 4 / 3;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.product-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.product-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.product-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark-color);
}

.product-price {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-color);
}

.product-category {
  display: inline-block;
  background: var(--accent-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.product-description {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.product-rating .stars {
  color: var(--warning-color);
}

.product-rating .reviews {
  font-size: 0.8rem;
  color: #666;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.product-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--secondary-color);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background: rgba(67, 97, 238, 0.1);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(67, 97, 238, 0.1);
  color: var(--primary-color);
}

.btn-icon:hover {
  background: var(--primary-color);
  color: white;
}

.wishlist-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--box-shadow);
  cursor: pointer;
  transition: var(--transition);
  z-index: 1;
}

.wishlist-btn.active {
  color: var(--danger-color);
}

.wishlist-btn:hover {
  transform: scale(1.1);
}

.product-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--danger-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
}

.image-container {
  position: relative;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #666;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.pagination button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: white;
  box-shadow: var(--box-shadow);
  cursor: pointer;
  transition: var(--transition);
}

.pagination button.active {
  background: var(--primary-color);
  color: white;
}

.pagination button:hover:not(.active) {
  background: rgba(67, 97, 238, 0.1);
}

@media (max-width: 768px) {
  .products-list .product-card {
    flex-direction: column;
  }

  .products-list .product-image {
    width: 100%;
    height: 200px;
  }

  .controls {
    flex-direction: column;
  }

  .filter-sort {
    flex-direction: column;
  }
}

/* Responsive grid columns for products-grid */
@media (min-width: 1200px) {
  /* Default 3 columns */
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1500px) {
  /* At 150% screen width, show 2 products per row */
  .products-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 768px) {
  /* At 50% screen width (small screens), show 5 products per row */
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  /* At 50% screen width (small screens), show 5 products per row */
  .products-grid {
    grid-template-columns: repeat(1, 1fr);
  }
}

/* Remove underline from product card links and nested elements */
.product-card a,
.product-card a *,
.product-card a::before,
.product-card a::after,
.product-card .card-title a,
.product-card .card-title a *,
.product-card .card-title a::before,
.product-card .card-title a::after {
  text-decoration: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
}

.product-card a:hover,
.product-card .card-title a:hover {
  text-decoration: none !important;
  color: #0d6efd; /* Bootstrap primary hover color */
}

/* Header logo and nav alignment fix */
header .container.d-flex {
  align-items: center !important;
}
header .container.d-flex > a > div {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Footer layout and spacing fix */
footer.footer .container .row,
.custom-footer .container .row {
  align-items: flex-start;
}
footer.footer .container .row > div,
.custom-footer .container .row > div {
  margin-bottom: 1rem;
}
footer.footer .container .row > div img,
.custom-footer .container .row > div img {
  max-width: 100%;
  height: auto;
  margin-bottom: 0.5rem;
}

/* Fix footer text alignment and spacing */
footer.footer .container .row > div p,
.custom-footer .container .row > div p {
  margin: 0;
  padding: 0;
  line-height: 1.4;
  text-align: left;
  font-size: 0.9rem;
}

/* Footer links */
.custom-footer a {
  color: #fff;
  text-decoration: none;
}

.custom-footer a:hover {
  text-decoration: underline;
}

/* Footer bottom */
.custom-footer .text-center {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.custom-footer .text-center a {
  color: #fff;
  text-decoration: none;
}

.custom-footer .text-center a:hover {
  text-decoration: underline;
}

/* Responsive footer columns */
@media (max-width: 767.98px) {
  .custom-footer .container .row {
    text-align: center;
  }
  .custom-footer .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .custom-footer .container .row > div {
    margin-bottom: 2rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  .custom-footer .text-center.mt-4 {
    margin-bottom: 1.5rem;
  }
}

/* Fix Bootstrap row negative margins in footer */
.custom-footer .container .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  gap: 1rem;
  display: flex;
  flex-wrap: wrap;
}

.custom-footer .container .row > div {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Fix Bootstrap column padding in footer */
.custom-footer .container .row > div {
  padding-left: 15px !important;
  padding-right: 15px !important;
}

/* Add bottom padding to footer to avoid overlap with floating buttons */
.custom-footer {
  padding-bottom: 20px;
}

/* Add bottom margin to container inside footer */
.custom-footer .container {
  margin-bottom: 0px;
  max-width: 1600px;
  padding-left: 1rem;
  padding-right: 1rem;
}

.custom-footer .container .row > div {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

/* Fix footer positioning and remove extra spacing */
.custom-footer {
  margin: 0 !important;
  width: 100% !important;
}

.custom-footer .container {
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Remove extra padding from footer sections on mobile */
@media (max-width: 767.98px) {
  .custom-footer .container .row > div {
    margin-bottom: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}
