/* Säkerställ global box-sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Body fix för overflow */
body {
  font-family: 'Poppins', sans-serif;
  overflow-x: hidden;
  padding: 0 0.75rem; /* Slightly reduce padding for very small screens */
  box-sizing: border-box;
}

/* Container för produktlistan */
#product-list {
  display: grid;
  gap: 1.5rem;
  padding: 1rem 0; /* Only top/bottom padding, let body handle sides */
  margin: 120px auto 0 auto;
  max-width: 1400px;
  width: 100%;
  /* Use auto-fit to prevent overflow, with reasonable minimum size */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent any overflow */
}

/* Force specific breakpoints to prevent overflow */
@media (min-width: 640px) and (max-width: 999px) {
  #product-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) and (max-width: 1299px) {
  #product-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1300px) {
  #product-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Produktkort - exakt som index.css */
.product-card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  width: 100%; /* Use full width by default, max-width will control it */
  max-width: 300px; /* Prevent cards from getting too wide */
  height: 420px; /* fast höjd */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center; /* Centrera texten */
  margin: 0 auto;

  /* Hover-effekt */
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.product-card:hover {
  box-shadow: 0 8px 16px rgba(0, 51, 102, 0.25); /* djupare skugga med blå nyans */
  transform: translateY(-6px);
}

.product-card img {
  width: 100%;
  height: 200px; /* fast bildhöjd */
  object-fit: contain; /* behåll hela bilden inom boxen */
  border-radius: 4px;
  margin-bottom: 0.8rem;

  /* Mjuk övergång för zoom */
  transition: transform 0.3s ease;
}

.product-card:hover img {
  transform: scale(1.05);
}

.product-card h3 {
  margin: 0.5rem 0;
  font-weight: 700; /* gör titeln tjockare */
}

.hero-content p {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

.add-to-cart-btn {
  background-color: #003366;
  color: white;
  border: none;
  padding: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 400; /* tunnare font enligt din önskan */
  text-align: center;

  /* Hover-effekt på knapp */
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.add-to-cart-btn:hover,
.add-to-cart-btn:focus {
  background-color: #002244;
  box-shadow: 0 0 8px rgba(0, 34, 68, 0.7);
  outline: none;
}

/* Liten rundning på knappens text vid hover */
.add-to-cart-btn:hover {
  letter-spacing: 0.05em;
}

/* Mobilanpassning - expanded to cover iPhone 12 mini and similar small devices */
@media (max-width: 767px) {
  body {
    padding: 0 0.5rem; /* Even tighter padding on very small screens */
  }
  
  #product-list {
    gap: 0.6rem; /* Tighter gap */
    margin-top: 0; /* Remove top margin since header is static */
    padding: 0.5rem 0; /* Minimal padding, let body handle sides */
    grid-template-columns: repeat(2, 1fr); /* Force exactly 2 columns */
    max-width: 100%;
  }
  
  .product-card {
    width: 100%;
    max-width: none; /* Remove max-width constraint on mobile */
    height: auto;
    min-height: 200px;
    padding: 0.6rem;
  }
  
  .product-card img {
    height: 80px;
    margin-bottom: 0.3rem;
  }
  
  .product-card h3 {
    font-size: 0.8rem;
    margin: 0.2rem 0;
    line-height: 1.1;
  }
  
  .product-card p {
    font-size: 0.75rem;
    margin: 0.2rem 0;
  }
  
  .add-to-cart-btn {
    font-size: 0.7rem;
    padding: 0.4rem 0.2rem;
    margin-top: 0.3rem;
  }
}

/* Ultra-small screens like iPhone 12 mini (375px width) */
@media (max-width: 390px) {
  body {
    padding: 0 0.25rem; /* Minimal side padding */
  }
  
  #product-list {
    gap: 0.4rem; /* Even tighter gap */
    padding: 0.25rem 0;
  }
  
  .product-card {
    padding: 0.4rem;
    min-height: 180px;
  }
  
  .product-card img {
    height: 70px;
  }
  
  .product-card h3 {
    font-size: 0.75rem;
  }
  
  .product-card p {
    font-size: 0.7rem;
  }
  
  .add-to-cart-btn {
    font-size: 0.65rem;
    padding: 0.3rem 0.1rem;
  }
}

#products-page-title {
  text-align: center;
}