/* Globala inställningar */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  margin: 0;
  padding: 0;
}

/* Mobile-specific fix for header gap */
@media (max-width: 768px) {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
  }
}

body {
  font-family: 'Poppins', sans-serif;
  overflow-x: hidden;
  background-color: #f9f9f9;
  margin: 0;
  padding: 0;
  padding-top: 120px; /* Back to original desktop spacing */
}

/* Remove top padding in mobile since header is static */
@media (max-width: 768px) {
  body {
    padding-top: 0 !important;
  }
  
  .main-content {
    margin-top: 1rem;
  }
}

/* Container för huvudinnehåll */
.main-content {
  max-width: 1200px;
  margin: 20px auto 2rem auto; /* Adjusted since body now has padding-top */
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
  min-height: calc(100vh - 250px); /* Increased minimum height to prevent collapse */
  position: relative; /* Ensure proper positioning context */
}

/* Produkttitel */
#product-title {
  width: 100%;
  font-weight: 700;
  font-size: 2.5rem;
  color: #003366;
  margin-bottom: 1rem;
  text-align: center;
}

/* Bildgalleri - thumbnails */
.image-gallery {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.thumbnail {
  width: 70px; /* Samma storlek överallt */
  height: 70px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 5px;
  transition: border-color 0.3s ease;
}

.thumbnail.selected {
  border-color: #007bff;
}

/* Produktåtgärder (pris, köpknapp etc) */
.product-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 20px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

@media (max-width: 480px) {
  .product-actions {
    flex-wrap: wrap;
    gap: 20px;
  }
}

/* Pris */
.product-price {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  position: relative;
  top: 15px; /* Justera för snygg placering */
}

/* Huvudbild */
.main-image {
  flex: 1 1 400px;
  max-width: 600px;
  min-height: 400px; /* Ensure consistent container height */
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: zoom-in;
  background-color: #f8f9fa; /* Light background for the container */
  border-radius: 8px;
}

/* Produktbeskrivning */
#product-description {
  flex-basis: 100%;
  max-width: 900px;
  min-height: 120px; /* Ensure minimum height for consistency */
  font-size: 1.1rem;
  line-height: 1.6;
  color: #444;
  margin-top: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  text-align: left;
  display: flex;
  align-items: flex-start; /* Align content to top */
}

/* Lightbox */
#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.85);
  display: none;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
  z-index: 9999;
}

#lightbox.show {
  display: flex;
}

/* Produkt-wrapper (höger/vänster layout) */
.product-wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  flex-wrap: nowrap;
  margin: 40px auto;
  max-width: 1200px;
  padding: 0 20px;
  box-sizing: border-box;
  min-height: 500px; /* Force minimum height to prevent layout shifts */
  width: 100%; /* Ensure full width usage */
}

/* Bild- och textkolumn */
.product-left,
.product-right {
  flex: 1;
  max-width: 50%;
}

.product-right {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Anpassning av bild i produkt */
.main-image img,
#main-image {
  width: 100%;
  height: 400px; /* Consistent fixed height */
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
  cursor: pointer;
  object-fit: contain;
  object-position: center;
  background-color: #ffffff;
}

/* Köpknapp */
.add-to-cart-btn {
  margin-top: 20px;
  background-color: #007bff;
  color: white;
  font-weight: 600;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.add-to-cart-btn:hover {
  background-color: #0056b3;
}

/* Responsiv design */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
    align-items: center;
  }

  .image-gallery {
    flex-direction: row;
    max-width: 100%;
    overflow-x: auto;
  }

  .main-image {
    max-width: 100%;
    flex-basis: auto;
  }

  #product-description {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 140px; /* Increased from 100px for more mobile spacing */
  }
  
  .main-content {
    margin-top: 20px; /* Consistent mobile spacing */
  }
  
  .product-wrapper {
    flex-wrap: wrap;
    margin: 20px auto; /* Reduced margin since body has more padding */
  }

  .product-left,
  .product-right {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

/* Extra spacing for smaller phones */
@media (max-width: 480px) {
  body {
    padding-top: 160px; /* Increased from 120px for very small screens */
  }
  
  .main-content {
    padding: 0 0.5rem; /* Reduce side padding on small screens */
  }
  
  .product-wrapper {
    margin: 10px auto;
    padding: 0 10px;
  }
}

/* Main image styling - consolidated */
.main-image img {
  width: 100%;
  height: 400px; /* Fixed height instead of max-height */
  border-radius: 8px;
  object-fit: contain;
  object-position: center; /* Center the image within the container */
  box-shadow: 0 2px 8px rgba(0, 51, 102, 0.15);
  transition: transform 0.3s ease, opacity 0.3s ease;
  background-color: #ffffff; /* White background for consistency */
  opacity: 1;
}

.main-image img:hover {
  transform: scale(1.05);
}

.main-image img.fade-out {
  opacity: 0;
}

/* Klass som appliceras för fade-out */
.fade-out {
  opacity: 0;
}

/* Lightbox image styling - consolidated */
#lightbox-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255,255,255,0.6);
  transition: transform 0.3s ease;
}

