/* ===== CATEGORIES SECTION AMÉLIORÉE ===== */
.categories-section {
  padding: 20px 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;
  position: relative;
  z-index: 5;
}

.categories-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 15px;
  overflow: visible !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
}

.categories-container::-webkit-scrollbar {
  display: none;
}

.category-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 14px 24px;
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  color: #333;
  text-decoration: none;
  border-radius: 30px;
  font-weight: 600;
  font-size: 14px;
  border: 2px solid transparent;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
  min-width: auto;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  transform: translateY(0);
}

.category-pill:hover {
  background: linear-gradient(135deg, #c77f7f 0%, #a66666 100%);
  color: white;
  text-decoration: none;
  border-color: #c77f7f;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(199, 127, 127, 0.3);
}

.category-pill .cat-name {
  transition: color 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ===== MEGA MENU SUPERPOSÉ SUR LES CATÉGORIES ===== */
.category-mega-menu {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%, 0) scale(0.95);
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,249,250,0.98) 100%);
  border: none;
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(0,0,0,0.12), 
    0 8px 24px rgba(0,0,0,0.08),
    0 2px 8px rgba(0,0,0,0.05);
  padding: 0;
  width: 850px;
  max-width: 95vw;
  max-height: 70vh;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
  backdrop-filter: blur(15px);
  border: 1px solid rgba(199, 127, 127, 0.15);
}

/* Flèche pointant vers la catégorie active */
.category-mega-menu::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 12px solid rgba(255,255,255,0.98);
  filter: drop-shadow(0 -2px 4px rgba(0,0,0,0.1));
  z-index: 1;
}

.category-mega-menu.adjust-left::after {
  left: 60px;
  transform: translateX(0);
}

.category-mega-menu.adjust-right::after {
  left: auto;
  right: 60px;
  transform: translateX(0);
}

/* Overlay subtil pour effet de profondeur */
.category-mega-menu::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.2);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.category-pill:hover .category-mega-menu::before {
  opacity: 1;
}
.category-mega-menu.adjust-left {
  left: 20px;
  transform: translate(0, 0) scale(0.95);
}

.category-mega-menu.adjust-right {
  left: auto;
  right: 20px;
  transform: translate(0, 0) scale(0.95);
}

.category-pill:hover .category-mega-menu {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: all !important;
  transform: translate(-50%, 0) scale(1) !important;
}

.category-pill:hover .category-mega-menu.adjust-left {
  transform: translate(0, 0) scale(1) !important;
}

.category-pill:hover .category-mega-menu.adjust-right {
  transform: translate(0, 0) scale(1) !important;
}

/* Indicateur visuel pour les positions ajustées */
.category-mega-menu.adjust-left::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -15px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-right: 15px solid rgba(199, 127, 127, 0.8);
  z-index: 1;
}

.category-mega-menu.adjust-right::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -15px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 15px solid rgba(199, 127, 127, 0.8);
  z-index: 1;
}

/* Overlay sombre derrière le mega menu */
.category-mega-menu::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.category-pill:hover .category-mega-menu {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: all !important;
  transform: translate(-50%, -50%) scale(1) !important;
}

.category-pill:hover .category-mega-menu::before {
  opacity: 1;
}

.mega-menu-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 400px;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
}

/* En-tête optimisé */
.mega-menu-header {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #c77f7f 0%, #a66666 100%);
  color: white;
  padding: 20px 35px;
  text-align: center;
  position: relative;
}

.mega-menu-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.mega-menu-left {
  padding: 30px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  position: relative;
}

.mega-menu-right {
  padding: 30px;
  background: white;
}

.mega-menu-left h4,
.mega-menu-right h4 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  position: relative;
  padding-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mega-menu-left h4::after,
.mega-menu-right h4::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 3px;
  background: linear-gradient(135deg, #c77f7f 0%, #a66666 100%);
  border-radius: 2px;
}

.mega-menu-brands {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  max-height: 180px;
  overflow-y: auto;
}

.mega-menu-brands::-webkit-scrollbar {
  width: 3px;
}

.mega-menu-brands::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.mega-menu-brands::-webkit-scrollbar-thumb {
  background: #c77f7f;
  border-radius: 2px;
}

.mega-menu-brands li {
  padding: 0;
  margin: 0 0 4px 0;
}

.mega-menu-brands a {
  color: #555;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  position: relative;
  background: rgba(255,255,255,0.6);
  border: 1px solid transparent;
}

.mega-menu-brands a::after {
  content: '→';
  opacity: 0;
  transition: all 0.15s ease;
  color: #c77f7f;
  font-weight: bold;
  transform: translateX(-5px);
}

.mega-menu-brands a:hover {
  color: #c77f7f;
  text-decoration: none;
  background: white;
  border-color: #c77f7f;
  box-shadow: 0 2px 8px rgba(199, 127, 127, 0.15);
  transform: translateX(3px);
}

.mega-menu-brands a:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.mega-menu-products {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 8px;
}

.mega-menu-products::-webkit-scrollbar {
  width: 6px;
}

.mega-menu-products::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.mega-menu-products::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #c77f7f 0%, #a66666 100%);
  border-radius: 3px;
}

.mega-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #f1f3f4;
  border-radius: 10px;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  background: #fafbfc;
}

.mega-product-item:hover {
  border-color: #c77f7f;
  box-shadow: 0 3px 12px rgba(199, 127, 127, 0.15);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
  background: white;
}

.mega-product-image {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
  flex-shrink: 0;
  border: 1px solid #e9ecef;
  transition: all 0.15s ease;
}

.mega-product-item:hover .mega-product-image {
  border-color: #c77f7f;
}

.mega-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease;
}

.mega-product-info {
  flex: 1;
  min-width: 0;
}

.mega-product-name {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.mega-product-item:hover .mega-product-name {
  color: #c77f7f;
}

.mega-product-price {
  font-size: 12px;
  color: #c77f7f;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.view-all-category {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #c77f7f;
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
  padding: 10px 18px;
  border: 2px solid #c77f7f;
  border-radius: 20px;
  transition: all 0.2s ease;
  background: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

.view-all-category:hover {
  background: #c77f7f;
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(199, 127, 127, 0.25);
}

.view-all-category i {
  transition: transform 0.2s ease;
  font-size: 12px;
}

.view-all-category:hover i {
  transform: translateX(2px);
}

/* Bouton de fermeture optimisé */
.mega-menu-close {
  position: absolute;
  top: 15px;
  right: 20px;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(199, 127, 127, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.mega-menu-close:hover {
  background: #c77f7f;
  border-color: #c77f7f;
  transform: scale(1.1);
}

.mega-menu-close::before,
.mega-menu-close::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 2px;
  background: #c77f7f;
  border-radius: 1px;
  transition: all 0.2s ease;
}

.mega-menu-close::before {
  transform: rotate(45deg);
}

.mega-menu-close::after {
  transform: rotate(-45deg);
}

.mega-menu-close:hover::before,
.mega-menu-close:hover::after {
  background: white;
}

/* Responsive - Version améliorée */
@media (max-width: 768px) {
  .categories-section {
    padding: 15px 0;
  }

  .categories-container {
    padding: 0 15px;
    gap: 8px;
  }

  .category-pill {
    padding: 10px 16px;
    font-size: 13px;
  }

  .category-mega-menu {
    display: none !important; /* Masquer le mega menu sur mobile */
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .category-mega-menu {
    width: 650px;
  }
  
  .mega-menu-container {
    min-height: 320px;
  }
  
  .mega-menu-left,
  .mega-menu-right {
    padding: 25px;
  }
}

/* Animation d'entrée pour le mega menu au centre */
@keyframes megaMenuCenterIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7) rotateY(-10deg);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotateY(0deg);
    filter: blur(0px);
  }
}

@keyframes megaMenuLeftIn {
  from {
    opacity: 0;
    transform: translate(0, -50%) scale(0.7) rotateY(-10deg);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%) scale(1) rotateY(0deg);
    filter: blur(0px);
  }
}

@keyframes megaMenuRightIn {
  from {
    opacity: 0;
    transform: translate(0, -50%) scale(0.7) rotateY(10deg);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translate(0, -50%) scale(1) rotateY(0deg);
    filter: blur(0px);
  }
}

/* Responsive optimisé */
@media (max-width: 768px) {
  .categories-section {
    padding: 15px 0;
  }

  .categories-container {
    padding: 0 15px;
    gap: 8px;
  }

  .category-pill {
    padding: 10px 16px;
    font-size: 13px;
  }

  .category-mega-menu {
    display: none !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .category-mega-menu {
    width: 650px;
  }
  
  .mega-menu-container {
    min-height: 350px;
  }
  
  .mega-menu-left,
  .mega-menu-right {
    padding: 25px;
  }
}
