/* --- STYLE (CSS) --- */
:root {
  --color-primary: #ebc0bf; /* Rouge/Orange vif, inspiré du logo */
  --color-secondary: #f2b705; /* Jaune/Or, inspiré du logo */
  --color-background: #eeeeee;
  --color-text-dark: #333;
  --color-text-light: #666;
  --grid-gap: 20px;
  --cards-per-row: 5; /* PARAMÈTRE : Nombre de cartes par ligne (3 par défaut) */
  --topbar-height: 60px;
  --search-height: 60px;
}

body {
  font-family: 'Tenor Sans', sans-serif;
  background-color: var(--color-background);
  color: var(--color-text-dark);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar styles */
.topbar {
  height: var(--topbar-height);
  background: var(--color-primary);
  color: white;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0; /* Prevents the topbar from shrinking */
  font-family: 'Tenor Sans', sans-serif;
}

.topbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Search wrapper in topbar */
.topbar .search-wrapper {
  max-width: 400px;
  display: flex;
  align-items: center;
  width: 100%;
  margin-left: 20px;
  padding: 5px 0; /* Add some vertical padding instead of fixed height */
}

.topbar .search-input {
  flex-grow: 1;
  padding: 8px 15px;
  border: 2px solid white;
  border-radius: 30px;
  font-size: 0.9em;
  outline: none;
  background-color: white;
  color: var(--color-text-dark);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.subtitle {
  font-size: 0.7em;
}

.topbar nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 20px;
}

.topbar nav a {
  color: white;
  text-decoration: none;
  font-weight: bold;
  transition: opacity 0.2s;
}

.topbar nav a:hover {
  opacity: 0.8;
}

/* Main content area with scroll */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  font-family: 'Tenor Sans', sans-serif;
  margin-top: 0;
  padding-bottom: 80px; /* Add space for bottom bar */
}

/* Adjust padding for mobile devices */
@media (max-width: 768px) {
  .main-content {
    padding-bottom: 160px; /* Increase space for bottom bar on mobile with column layout */
  }
}

/* Bottom bar styles */
.bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background: var(--color-primary);
  color: white;
  z-index: 1000;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  font-family: 'Tenor Sans', sans-serif;
}

.bottombar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.filter-buttons {
  display: flex;
  gap: 5px;
}

.filter-btn {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  gap: 3px;
  opacity: 0.6;
}

.filter-btn:hover {
  background-color: #e9e9e9;
  border-color: var(--color-primary);
}

.filter-btn.active {
  border-color: var(--color-primary);
  opacity: 1;
  transform: scale(1.05);
}

.filter-btn .material-icons {
  font-size: 18px;
}

.filter-btn span:last-child {
  font-size: 0.65rem;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ff6b6b;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  display: none; /* Caché par défaut, affiché quand il y a des articles */
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 22px;
  font-weight: bold;
  z-index: 10; /* S'assurer que la pastille est au-dessus des autres éléments */
}

/* Ajustement pour le bouton du panier dans la bottom bar */
.filter-btn {
  position: relative; /* Permettre le positionnement absolu de la pastille */
}

.sort-select {
  display: flex;
  align-items: center;
}

#bottom-sort-select {
  padding: 8px 15px;
  border: 2px solid white;
  border-radius: 30px;
  font-size: 0.9em;
  outline: none;
  background-color: white;
  color: var(--color-text-dark);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  min-width: 180px;
}

/* --- Zone de Contrôle (Filtres et Paramètres) --- */

#controls {
  font-size: 0.7rem;
  background-color: #fff;
  border: 2px solid var(--color-secondary);
  padding: 15px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  gap: 15px;
  flex-shrink: 0; /* Prevents controls from shrinking */
}

#controls > div {
  display: flex;
  gap: 10px;
  align-items: center;
}

.filter-btn {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
  opacity: 0.6;
}

.sort-btn {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
  opacity: 0.6;
}

.filter-btn:hover,
.sort-btn:hover {
  background-color: #e9e9e9;
  border-color: var(--color-primary);
}

.filter-btn.active,
.sort-btn.active {
  border-color: var(--color-primary);
  opacity: 1;
  transform: scale(1.05);
}

#items-per-row-container {
  display: flex;
  align-items: center;
  gap: 10px;
}
#items-per-row {
  width: 60px;
  padding: 5px;
  border: 1px solid var(--color-primary);
  border-radius: 5px;
  text-align: center;
}

/* --- Grille des Produits --- */
#product-grid {
  display: grid;
  grid-template-columns: repeat(var(--cards-per-row), 1fr);
  gap: var(--grid-gap);
}

.product-card {
  background-color: white;
  border: 1px solid #eee;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  text-align: center;
  min-width: 160px;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.card-image-container {
  height: 180px; /* Hauteur fixe pour les images */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  overflow: hidden;
  position: relative;
}

.card-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain; /* Assure que l'image rentre sans être coupée */
  border-radius: 5px;
}

.product-number {
  position: absolute;
  top: 15px;
  left: 15px;
  background-color: rgba(217, 55, 28, 0.8); /* var(--color-primary) avec transparence */
  color: white;
  font-size: 0.9em;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 10px;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.add-to-cart-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background-color: var(--color-secondary);
  color: var(--color-text-dark);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, background-color 0.2s;
}

.add-to-cart-btn:hover {
  transform: scale(1.1);
  background-color: #e6a705;
}

.add-to-cart-btn .material-icons {
  font-size: 20px;
}

/* Style pour les cartes ajoutées au panier */
.product-card.in-cart {
  border: 3px solid #ff6b6b; /* Bordure rouge pour les articles dans le panier */
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
}

.product-number.Homme {
  background-color: #003366; /* Bleu ciel */
  color: white;
}

.product-number.Femme {
  background-color: #b56576; /* Rose */
  color: white;
}

.product-number.Mixte {
  background-color: #355e3b; /* Violet */
  color: white;
}

.product-number.Enfant {
  background-color: #808080; /* Gris */
  color: white;
}

.card-content {
  padding: 15px;
  flex-grow: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.card-content .product-brand {
  font-size: 0.7rem;
  color: var(--color-text-light);
  letter-spacing: 1px;
}

.card-content .product-info {
  font-size: 0.6rem;
  color: var(--color-text-light);
  margin-bottom: 8px;
}

.card-content h3 {
  font-size: 1.2em;
  color: var(--color-text-dark);
  margin-top: 0;
  margin-bottom: 5px;
}

.card-content p {
  margin: 3px 0;
  font-size: 0.95em;
}

/* Container for the main content except price */
.card-content-main {
  flex-grow: 1;
}

.card-footer {
  padding: 15px;
  border-top: 1px dashed #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.price-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  margin-top: 10px;
}

.price-circle {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-weight: 800;
  font-size: 1.4em;
  position: relative;
}

.price-label {
  font-size: 0.6rem;
  opacity: 0.5;
  margin-bottom: 2px;
}

.price-value {
  font-size: 1.2rem;
  font-weight: 800;
}

.price-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.price-circle-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.public-price-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  margin-right: 15px;
}

.public-price-label {
  font-size: 0.4rem;
  opacity: 0.7;
  margin-bottom: 2px;
}

.public-price-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
}

.link-button {
  display: inline-block;
  background-color: var(--color-secondary);
  color: var(--color-text-dark);
  padding: 8px 15px;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
  transition: background-color 0.2s;
}

.link-button:hover {
  background-color: #e6a705;
}

/* Popup styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.cart-modal {
  display: none;
}

.popup-overlay.show,
.popup-overlay.cart-modal.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.popup-overlay.show .popup-content {
  transform: none;
}

.popup-body {
  text-align: left;
}

.popup-body .checkout-btn {
  display: inline-block;
  text-decoration: none;
}

.popup-overlay .cart-modal-content {
  height: 90vh;
}

.popup-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.popup-footer .checkout-btn {
  width: auto;
  min-width: 200px;
  max-width: 240px;
  text-align: center;
  padding: 10px 20px;
  display: inline-flex;
  justify-content: center;
}

.popup-body p {
  margin: 10px 0;
  line-height: 1.25;
  color: var(--color-text-dark);
}

.popup-body ul {
  text-align: left;
  padding-left: 20px;
  margin: 15px 0;
}

.popup-body li {
  margin-bottom: 8px;
  line-height: 1.25;
}

.cta-button {
  display: inline-block;
  background-color: var(--color-secondary);
  color: var(--color-text-dark);
  padding: 12px 25px;
  text-decoration: none;
  border-radius: 30px;
  font-weight: bold;
  transition: background-color 0.2s, transform 0.2s;
  margin-top: 15px;
  border: none;
  cursor: pointer;
  font-size: 1em;
}

.cta-button:hover {
  background-color: #e6a705;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.product-type-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.85em;
  font-weight: bold;
  color: white;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.product-type-tag.Homme {
  background-color: #3498db; /* Bleu */
}

.product-type-tag.Femme {
  background-color: #e91e63; /* Rose */
}

.product-type-tag.Mixte,
.product-type-tag.Enfant {
  background-color: #9b59b6; /* Violet */
}

/* Nouveau design pour les alternatives de contenance */
.size-selector {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
}

.size-option {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.6;
}

.size-option:hover {
  background-color: #e9e9e9;
  border-color: var(--color-primary);
}

.size-option.selected {
  border-color: var(--color-primary);
  opacity: 1;
}

.size-option .size-value {
  font-weight: bold;
}

/* Styles for search in topbar on different screen sizes */
@media (min-width: 769px) {
  .topbar .search-wrapper {
    max-width: 400px;
    margin-left: 20px;
  }
}

@media (max-width: 768px) {
  .topbar {
    height: auto; /* Allow topbar to grow with content */
    padding-bottom: 10px;
  }

  .topbar-content {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    align-items: stretch;
  }

  .topbar .search-wrapper {
    max-width: 100%;
    margin-left: 0;
    order: 2; /* Put search after the title */
    padding: 0;
  }

  .topbar-content > div:first-child {
    order: 1;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .topbar .search-input {
    font-size: 0.8em;
    padding: 6px 10px;
  }
}

/* Styles pour les écrans larges */
@media (min-width: 1200px) {
  :root {
    --cards-per-row: 6;
  }
}

/* Responsive styles for bottom bar */
@media (max-width: 768px) {
  .bottombar {
    height: auto;
    padding: 10px 0;
  }

  .bottombar-content {
    flex-direction: column;
    gap: 10px;
    padding: 0 10px;
    height: auto;
  }

  .filter-buttons {
    order: 2;
    justify-content: center;
  }

  .sort-select {
    order: 1;
    width: 100%;
    max-width: 300px;
  }

  .filter-btn {
    min-width: 50px;
    padding: 6px 8px;
  }

  .filter-btn .material-icons {
    font-size: 16px;
  }

  .filter-btn span:last-child {
    font-size: 0.55rem;
  }

  #bottom-sort-select {
    min-width: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .filter-buttons {
    gap: 3px;
  }

  .filter-btn {
    min-width: 45px;
    padding: 5px 6px;
  }

  .filter-btn .material-icons {
    font-size: 14px;
  }

  .filter-btn span:last-child {
    font-size: 0.5rem;
  }
}

/* Styles pour les tablettes */
@media (max-width: 1024px) {
  :root {
    --cards-per-row: 4;
  }
  /* Original h1 from the page content - hidden */
}

@media (max-width: 768px) {
  :root {
    --cards-per-row: 3;
  }

  /* Responsive styles for topbar and search */
  .topbar-content {
    padding: 0 10px;
  }

  .topbar nav ul {
    gap: 10px;
  }

  .search-wrapper {
    padding: 5px 10px;
  }

  .search-input {
    padding: 8px 10px;
    font-size: 0.9em;
  }

  .search-button {
    padding: 8px 15px;
    font-size: 0.9em;
  }
}

@media (max-width: 480px) {
  :root {
    --topbar-height: 50px;
    --search-height: 50px;
    --cards-per-row: 2;
  }

  .topbar nav ul {
    justify-content: center;
  }

  .search-input {
    border-radius: 30px;
    width: 100%;
  }

  .search-button {
    border-radius: 30px;
    margin-top: 5px;
  }

  .main-content {
    padding: 10px 10px 140px 10px; /* Keep bottom padding for bottom bar */
  }

  #controls {
    margin-bottom: 10px;
  }

  .price-value {
    font-size: 1rem;
  }
}
