/* ============================================
   CATEGORY EXPLORER — Styles isolés
   Vue pleine page style Alibaba
   ============================================ */

/* --- Variables locales pour cohérence --- */
:root {
  --ce-bg-primary: var(--home-bg-primary, #ffffff);
  --ce-bg-secondary: var(--home-bg-secondary, #f8f9fa);
  --ce-border: var(--home-border-color, #e5e7eb);
  --ce-text-primary: var(--home-text-primary, #1f2937);
  --ce-text-secondary: var(--home-text-secondary, #6b7280);
  --ce-text-tertiary: var(--home-text-tertiary, #9ca3af);
  --ce-accent: var(--primary-orange, #ff6a00);
  --ce-accent-light: var(--primary-light, #fff7f0);
}

/* --- Conteneur principal --- */
.category-explorer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ce-bg-primary);
  z-index: 2000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.category-explorer.open {
  display: flex;
}

/* --- Header --- */
.category-explorer-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ce-border);
  background: var(--ce-bg-primary);
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.92);
}

.category-explorer-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ce-bg-secondary);
  border: 1px solid var(--ce-border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--ce-text-primary);
  flex-shrink: 0;
}

.category-explorer-back:hover {
  background: var(--ce-border);
  transform: scale(1.05);
}

.category-explorer-back:active {
  transform: scale(0.97);
}

.category-explorer-back svg {
  width: 20px;
  height: 20px;
}

.category-explorer-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ce-text-primary);
  flex: 1;
}

/* --- Barre de recherche dans le header --- */
.category-explorer-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 240px;
  max-width: 40%;
}

.ce-search-input {
  width: 100%;
  height: 32px;
  padding: 6px 12px 6px 36px;
  border: 1px solid var(--ce-border);
  border-radius: 16px;
  background: var(--ce-bg-secondary);
  color: var(--ce-text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px;
}

.ce-search-input:focus {
  border-color: var(--ce-accent);
  background: var(--ce-bg-primary);
  box-shadow: 0 0 0 2px var(--ce-accent-light);
}

.ce-search-input::placeholder {
  color: var(--ce-text-tertiary);
}

/* Bouton clear */
.ce-search-clear {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ce-text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ce-search-clear:hover {
  background: var(--ce-border);
  color: var(--ce-text-primary);
}

/* --- État vide dans la liste des catégories --- */
.category-explorer-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--ce-text-tertiary);
}

.category-explorer-empty-state svg {
  opacity: 0.35;
  margin-bottom: 12px;
}

.category-explorer-empty-state span {
  font-size: 13px;
}

/* --- Body (panneaux) --- */
.category-explorer-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--ce-bg-primary);
}

/* =====================
   PANNEAU GAUCHE
   ===================== */

.category-explorer-left {
  width: 280px;
  background: var(--ce-bg-secondary);
  border-right: 1px solid var(--ce-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.category-explorer-left-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ce-border);
  background: var(--ce-bg-secondary);
  position: sticky;
  top: 0;
  z-index: 5;
}

.category-explorer-left-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ce-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-explorer-left-count {
  font-size: 11px;
  color: var(--ce-text-tertiary);
  background: var(--ce-border);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 600;
}

.category-explorer-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* --- Scrollbar --- */
.category-explorer-list::-webkit-scrollbar,
.category-explorer-right::-webkit-scrollbar {
  width: 6px;
}

.category-explorer-list::-webkit-scrollbar-track,
.category-explorer-right::-webkit-scrollbar-track {
  background: transparent;
}

.category-explorer-list::-webkit-scrollbar-thumb {
  background: var(--ce-border);
  border-radius: 3px;
}

.category-explorer-list::-webkit-scrollbar-thumb:hover {
  background: var(--ce-text-tertiary);
}

/* --- Item catégorie (panneau gauche) --- */
.category-explorer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.category-explorer-item:hover {
  background: var(--ce-bg-primary);
}

.category-explorer-item.active {
  background: var(--ce-bg-primary);
  border-left-color: var(--ce-accent);
}

.category-explorer-item.active .category-explorer-item-name {
  color: var(--ce-accent);
  font-weight: 600;
}

.category-explorer-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ce-bg-primary);
  flex-shrink: 0;
  color: var(--ce-text-secondary);
  transition: all 0.15s ease;
}

.category-explorer-item.active .category-explorer-item-icon {
  color: var(--ce-accent);
  background: var(--ce-accent-light);
}

.category-explorer-item-info {
  flex: 1;
  min-width: 0;
}

.category-explorer-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ce-text-primary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-explorer-item-desc {
  font-size: 11px;
  color: var(--ce-text-tertiary);
  display: block;
  margin-top: 1px;
}

.category-explorer-item-arrow {
  color: var(--ce-text-tertiary);
  flex-shrink: 0;
  opacity: 0.5;
  transition: all 0.15s ease;
}

.category-explorer-item.active .category-explorer-item-arrow {
  opacity: 1;
  color: var(--ce-accent);
}

/* =====================
   PANNEAU DROIT
   ===================== */

.category-explorer-right {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--ce-bg-primary);
}

.category-explorer-right::-webkit-scrollbar {
  width: 6px;
}

.category-explorer-right::-webkit-scrollbar-track {
  background: transparent;
}

.category-explorer-right::-webkit-scrollbar-thumb {
  background: var(--ce-border);
  border-radius: 3px;
}

.category-explorer-right::-webkit-scrollbar-thumb:hover {
  background: var(--ce-text-tertiary);
}

.category-explorer-right-header {
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--ce-bg-primary);
  padding-bottom: 12px;
}

.category-explorer-right-header h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--ce-text-primary);
}

.category-explorer-right-count {
  font-size: 13px;
  color: var(--ce-text-tertiary);
  font-weight: 500;
}

/* --- Grille de sous-catégories --- */
.category-explorer-subcategories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

/* --- Card sous-catégorie --- */
.category-explorer-subcard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--ce-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--ce-bg-primary);
  position: relative;
  overflow: hidden;
}

.category-explorer-subcard::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ce-accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.2s ease;
}

.category-explorer-subcard:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

.category-explorer-subcard:hover {
  border-color: var(--ce-accent);
  box-shadow: 0 4px 16px rgba(255, 106, 0, 0.08);
  transform: translateY(-2px);
}

.category-explorer-subcard:active {
  transform: translateY(0);
}

.category-explorer-subcard-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--ce-accent-light);
  flex-shrink: 0;
  color: var(--ce-accent);
}

.category-explorer-subcard-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--ce-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-explorer-subcard-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-explorer-subcard-info {
  flex: 1;
  min-width: 0;
}

.category-explorer-subcard-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ce-text-primary);
  display: block;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-explorer-subcard-category {
  font-size: 11px;
  color: var(--ce-text-tertiary);
  display: block;
  margin-bottom: 2px;
}

.category-explorer-subcard-count {
  font-size: 11px;
  color: var(--ce-text-tertiary);
  background: var(--ce-bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  font-weight: 600;
}

/* --- Fallback produits --- */
.category-explorer-product-fallback {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.category-explorer-product-fallback .product-card {
  border: 1px solid var(--ce-border);
  border-radius: 12px;
  transition: all 0.2s ease;
  background: var(--ce-bg-primary);
}

.category-explorer-product-fallback .product-card:hover {
  border-color: var(--ce-accent);
  box-shadow: 0 4px 16px rgba(255, 106, 0, 0.08);
  transform: translateY(-2px);
}

.category-explorer-product-fallback .product-card .product-image {
  border-radius: 12px 12px 0 0;
}

.category-explorer-product-fallback .product-card .product-info {
  padding: 12px;
}

.category-explorer-product-fallback .product-card .product-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.category-explorer-product-fallback .product-card .product-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--ce-accent);
}

/* --- État vide --- */
.category-explorer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.category-explorer-empty svg {
  opacity: 0.35;
  margin-bottom: 16px;
}

.category-explorer-empty p {
  font-size: 14px;
  color: var(--ce-text-tertiary);
  max-width: 280px;
  line-height: 1.5;
}

/* =====================
   RESPONSIVE
   ===================== */

@media (max-width: 768px) {
  .category-explorer-left {
    width: 200px;
  }

  .category-explorer-right {
    padding: 16px;
  }

  .category-explorer-subcategories {
    grid-template-columns: 1fr;
  }

  .category-explorer-header {
    padding: 10px 12px;
  }

  .category-explorer-product-fallback {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 480px) {
  /* Garder le même layout que PC : panneaux côte à côte */
  .category-explorer-body {
    flex-direction: row;
  }

  .category-explorer-left {
    width: 150px;
    border-right: 1px solid var(--ce-border);
    border-bottom: none;
    max-height: none;
  }

  .category-explorer-right {
    flex: 1;
    padding: 12px;
  }

  .category-explorer-subcategories {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .category-explorer-subcard {
    padding: 12px 14px;
  }

  .category-explorer-right-header h3 {
    font-size: 18px;
  }

  .category-explorer-product-fallback {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }

  /* Réduire la largeur de la recherche sur mobile */
  .category-explorer-search {
    width: 140px;
    max-width: 30%;
  }
}