/* ==================================== */
/* === GÉNÉRAL & MISE EN PAGE DE BASE === */
/* ==================================== */

:root {
  --primary-color: #004d99; /* Bleu foncé pour les accents */
  --secondary-color: #f2f2f2; /* Gris clair pour les arrières-plans */
  --text-color: #333;
  --light-text-color: #fff;
  --border-color: #ccc;
  --transition-speed: 0.3s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  line-height: 1.6;
  background-color: var(--secondary-color);
  color: var(--text-color);
  /* FIXÉ: Règle pour pousser le footer vers le bas */
  display: flex;
  flex-direction: column;
  min-height: 100vh; 
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* ================== */
/* === HEADER & NAV === */
/* ================== */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--light-text-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-wrap: wrap;
}

header h1 a {
  display: flex;
  align-items: center;
}

.navbar {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.navbar button {
  font-size: 1.5rem;
  color: var(--text-color);
  padding: 0.5rem;
}

.navbar button:hover {
  color: var(--primary-color);
}

.hamburger {
  display: none;
}

nav#main-nav {
  display: flex;
  background-color: #444;
  color: var(--light-text-color);
  justify-content: center;
  padding: 0.5rem 2rem;
  flex-wrap: wrap;
  gap: 1.5rem;
  width: 100%;
}

nav#main-nav button {
  color: var(--light-text-color);
  padding: 0.5rem 1rem;
  position: relative;
}

nav#main-nav button:hover,
nav#main-nav button.active {
  background-color: var(--primary-color);
}

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--light-text-color);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 100;
  min-width: 200px;
}

.dropdown-content button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-color);
}

.dropdown-content button:hover {
  background-color: var(--secondary-color);
}

.dropdown.open .dropdown-content {
  display: flex;
  flex-direction: column;
}

/* ================================= */
/* === BARRE DE RECHERCHE DANS L'EN-TÊTE === */
/* ================================= */

.header-search-container {
  width: 100%;
  padding: 10px 20px;
  background-color: var(--light-text-color);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  display: none;
  opacity: 0;
  transform: translateY(-100%);
  transition: transform var(--transition-speed) ease-out, opacity var(--transition-speed) ease-out;
}

.header-search-container.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

#search-input-header {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
}

#search-results-header {
  margin-top: 10px;
  max-height: 250px;
  overflow-y: auto;
  background-color: var(--light-text-color);
  border: 1px solid #eee;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: #f8f8f8;
}

.search-result-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 10px;
}

.search-result-item .details {
  flex-grow: 1;
}

.search-result-item .details strong {
  display: block;
  font-size: 14px;
  color: #333;
}

.search-result-item .details span {
  font-size: 12px;
  color: #666;
}

.search-tip {
  padding: 10px;
  color: #888;
  text-align: center;
}

/* ====================== */
/* === modal === */
/* ====================== */

.modal {
  display: none; /* Cache la modale par défaut */
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: #fefefe;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 400px;
  text-align: center;
  border-radius: 8px;
  position: relative;
}

.close-button {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  position: absolute;
  top: 10px;
  right: 10px;
}

.close-button:hover,
.close-button:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

/* ====================== */
/* === SECTIONS PRODUIT === */
/* ====================== */

main {
  /* FIXÉ: flex-grow pour pousser le footer vers le bas */
  flex-grow: 1;
  padding: 2rem;
}

#random-products-container h2 {
  grid-column: 1 / -1;
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.8rem;
  color: var(--primary-color);
}

.section-container,
#random-products-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.product {
  background-color: var(--light-text-color);
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  padding: 1rem;
  transition: transform var(--transition-speed);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.product .image-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  margin-bottom: 1rem;
  cursor: pointer;
}

.product .image-wrapper img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  transition: transform var(--transition-speed);
}

.product .image-wrapper:hover img {
  transform: scale(1.05);
}

.survol-texte {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--light-text-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  opacity: 0;
  transition: opacity var(--transition-speed);
  pointer-events: none;
  font-size: 0.9rem;
}

.image-wrapper:hover .survol-texte {
  opacity: 1;
}

.product h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.product p {
  font-size: 0.9rem;
  color: #666;
}

.product button.add-to-cart-btn {
  background-color: var(--primary-color);
  color: var(--light-text-color);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  margin-top: 1rem;
  width: 100%;
  transition: background-color var(--transition-speed);
}

.product button.add-to-cart-btn:hover {
  background-color: #003366;
}

.qty-input {
  width: 60px;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
  margin: 0.5rem auto 0.5rem;
  display: block;
}

/* =========================== */
/* === SÉLECTEUR PERSONNALISÉ === */
/* =========================== */

.custom-select-wrapper {
  position: relative;
  width: 100%;
  text-align: left;
  margin-top: 0.5rem;
  user-select: none;
}

.custom-select-trigger {
  background-color: var(--secondary-color);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color var(--transition-speed);
}

.custom-select-trigger:focus,
.custom-select-wrapper.open .custom-select-trigger {
  outline: none;
  border-color: var(--primary-color);
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--light-text-color);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.custom-select-wrapper.open .custom-options {
  display: block;
}

.custom-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.custom-option:hover,
.custom-option.selected {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

/* ======================== */
/* === OVERLAYS & MODALES === */
/* ======================== */

#cp-quickview-modal,
#error-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

#cp-quickview-modal > div,
#error-modal .modal-content {
  background-color: var(--light-text-color);
  padding: 2rem;
  border-radius: 8px;
  position: relative;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#close-quick-view,
#error-modal .modal-content button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
}

#close-quick-view:hover {
  color: var(--primary-color);
}

#quickview-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  display: block;
  margin: 0 auto 1rem;
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 4px;
  background-color: white;
}

#quickview-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

#quickview-price {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary-color);
}

#error-modal .modal-content {
  text-align: center;
}

.modal-logo {
  max-width: 100px;
  margin-bottom: 1rem;
}

#error-modal p {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

#error-modal button {
  background-color: var(--primary-color);
  color: var(--light-text-color);
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
}

/* ============ */
/* === PANIER === */
/* ============ */

.cart {
  position: fixed;
  top: 0;
  right: -400px;
  width: 350px;
  max-width: 90%;
  height: 100%;
  background-color: var(--light-text-color);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  transition: right var(--transition-speed) ease-in-out;
  z-index: 1500;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart.open {
  right: 0;
}

.cart h4 {
  font-size: 1.5rem;
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 1rem;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--secondary-color);
}

.cart-item img {
  flex-shrink: 0;
}

.cart-item input[type="number"] {
  width: 60px;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.cart-total {
  font-size: 1.2rem;
  font-weight: bold;
  text-align: right;
  padding-top: 1rem;
  border-top: 2px solid var(--primary-color);
}

#checkout-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

#checkout-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

#checkout-form input {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

#checkout-form button {
  background-color: var(--primary-color);
  color: var(--light-text-color);
  font-size: 1rem;
  font-weight: bold;
}

#confirmation-commande {
  border-top: 1px dashed var(--border-color);
  padding-top: 1rem;
  margin-top: 1rem;
  color: green;
}

/* ============= */
/* === FOOTER === */
/* ============= */

.site-footer {
  /* Style professionnel unifié */
  background-color: var(--light-text-color);
  color: var(--text-color);
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

.footer-content {
  display: flex;
  justify-content: space-around;
  gap: 2rem;
  flex-wrap: wrap;
  padding-bottom: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.footer-left,
.footer-center {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.footer-left {
  text-align: left;
}

.footer-logo {
  max-width: 150px;
  margin-bottom: 1rem;
  display: block;
}

.footer-left p {
  margin: 0;
}

.footer-center h4 {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  text-align: left;
}

.footer-categories {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-categories li a {
  color: var(--text-color);
  transition: color var(--transition-speed);
}

.footer-categories li a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.copyright-bar {
  text-align: center;
  border-top: 1px solid #ddd;
  padding-top: 1rem;
  font-size: 0.9rem;
}


/* ==================== */
/* === BANDEAU COOKIES === */
/* ==================== */

#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--light-text-color);
  padding: 1rem;
  text-align: center;
  z-index: 2000;
  display: none;
}

#cookie-banner button {
  margin-left: 1rem;
  background-color: var(--primary-color);
  color: var(--light-text-color);
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

#cookie-banner button:last-child {
  background-color: #d9534f;
}

/* ======================= */
/* === MEDIA QUERIES MOBILE === */
/* ======================= */

@media (max-width: 768px) {
  /* --- EN-TÊTE & NAVIGATION --- */
  header {
    padding: 1rem;
    flex-wrap: wrap;
  }
  
  .hamburger {
    display: block;
    font-size: 1.5rem;
  }

  .navbar {
    flex-grow: 1;
    justify-content: flex-end;
  }
  
  .header-search-container {
    padding: 10px 10px;
    position: static;
    transform: translateY(0);
    transition: none;
  }

  nav#main-nav {
    flex-direction: column;
    align-items: flex-start;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: #333;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease-in-out, opacity var(--transition-speed) ease-in-out;
    z-index: 999;
    opacity: 0;
  }

  nav#main-nav.active {
    max-height: 500px;
    opacity: 1;
  }

  nav#main-nav button {
    width: 100%;
    text-align: left;
    padding-left: 1.5rem;
  }
  
  .dropdown-content {
    position: static;
    width: 100%;
    box-shadow: none;
    background-color: #2a2a2a;
  }

  .dropdown-content button {
    padding-left: 2.5rem;
    color: var(--light-text-color);
  }

  /* --- CONTENU PRINCIPAL & PRODUITS --- */
  main {
    padding: 1rem;
  }
  
  .section-container,
  #random-products-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .product {
    padding: 1rem;
  }

  .product h3 {
    font-size: 1.1rem;
  }
  
  .product p {
    font-size: 0.85rem;
  }

  /* --- MODALES & PANIER --- */
  #cp-quickview-modal > div,
  #error-modal .modal-content {
    width: 95%;
    max-width: none;
    padding: 1rem;
  }
  
  .cart {
    width: 100%;
    max-width: 100%;
    right: -100%;
  }
  
  .cart.open {
    right: 0;
  }

/* ============= */
/* === FOOTER (mobile) === */
/* ============= */

.site-footer {
    /* Style professionnel unifié */
    background-color: var(--light-text-color);
    color: var(--text-color);
    padding: 2rem 1rem;
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.footer-content {
    flex-direction: column; /* Les éléments s'empilent verticalement sur mobile */
    align-items: center;
    gap: 1.5rem; /* Réduit l'espace entre les éléments sur mobile */
    padding-bottom: 1.5rem;
}

.footer-left,
.footer-center {
    width: 100%;
    text-align: center; /* Centre le texte */
}

.footer-logo {
    margin: 0 auto 1rem; /* Centre le logo */
}

.footer-center h4 {
    text-align: center; /* Centre les titres de catégorie */
}

.footer-categories {
    align-items: center; /* Centre les liens de catégorie */
}

.copyright-bar {
    padding-top: 1rem;
}
}