/* ============================================================
   SHOP / BOUTIQUE — PhoneHS
   Filtres latéraux, accordéons, toolbar, UX
   ============================================================ */

/* ====== HERO ====== */
.phs-shop-hero {
  background: var(--color-gray-bg);
  padding: 20px 0 28px;
}
.phs-shop-hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}
.phs-shop-title {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0 0;
}
.phs-shop-desc {
  font-size: var(--font-size-sm);
  color: var(--color-gray);
  margin-top: 6px;
  max-width: 600px;
}

/* ====== LAYOUT 2 colonnes ====== */
.phs-shop-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px var(--space-lg) 80px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  align-items: start;
}

/* ====== SIDEBAR ====== */
.phs-shop-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
}

.phs-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
}
.phs-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-dark);
  margin: 0;
}
.phs-sidebar-close {
  display: none; /* Only visible on mobile */
  background: none;
  border: none;
  color: var(--color-gray);
  cursor: pointer;
  padding: 4px;
}

.phs-sidebar-content {
  padding: 8px 0;
  max-height: calc(100vh - var(--nav-height) - 140px);
  overflow-y: auto;
  overflow-x: hidden; /* jamais de scroll horizontal dans la sidebar filtres */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.phs-sidebar-content::-webkit-scrollbar { width: 4px; }
.phs-sidebar-content::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }

/* Recherche sidebar */
.phs-filter-search {
  padding: 8px 16px 12px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.phs-filter-search .phs-filter-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0; /* autorise le champ à rétrécir pour ne pas pousser le bouton hors du cadre */
}
.phs-search-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  border: none;
  border-radius: 10px;
  background: var(--color-blue);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}
.phs-search-btn:hover { opacity: 0.88; }
.phs-filter-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--color-gray-bg);
}
.phs-filter-input:focus {
  border-color: var(--color-blue);
  background: white;
}

/* ====== ACCORDÉON FILTRES ====== */
.phs-filter-group {
  border-top: 1px solid var(--color-border);
}
.phs-filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--color-dark);
  cursor: pointer;
  transition: background 0.15s;
}
.phs-filter-toggle:hover { background: var(--color-gray-bg); }
.phs-filter-toggle svg {
  transition: transform 0.25s ease;
  color: var(--color-gray-light);
  flex-shrink: 0;
}
.phs-filter-toggle.active svg { transform: rotate(180deg); }

.phs-filter-body {
  display: none;
  padding: 0 18px 14px;
}
.phs-filter-body.open { display: block; }

/* ====== LIENS CATÉGORIES ====== */
.phs-cat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--color-dark);
  text-decoration: none;
  transition: all 0.15s;
}

/* Catégories de 1er niveau (incl. "Tout voir") : texte en gras, fond neutre. */
.phs-cat-link:not(.phs-cat-child) {
  font-weight: 600;
}
.phs-cat-link:not(.phs-cat-child):hover {
  background: var(--color-gray-bg);
  color: var(--color-blue);
}

/* Bordure basse grise légère ENTRE les catégories principales. */
#filter-categories > .phs-cat-link,
#filter-categories > .phs-cat-item {
  border-bottom: 1px solid #e8e8ea;
  padding-bottom: 6px;
  margin-bottom: 6px;
}
#filter-categories > :last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* Catégorie ACTIVE : fond bleu, texte + icône en blanc. */
.phs-cat-link.active {
  background: var(--color-blue);
  color: #fff;
  font-weight: 600;
}
.phs-cat-link.active:hover {
  background: var(--color-blue);
  color: #fff;
}
.phs-cat-count {
  font-size: 0.72rem;
  color: var(--color-gray-light);
  background: var(--color-gray-bg);
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.phs-cat-link.active .phs-cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}
/* Flèche d'expansion (injectée en JS) blanche quand la catégorie est active. */
.phs-cat-link.active ~ .phs-cat-expand { color: #fff !important; }

/* Sous-catégories : fond gris léger pour les distinguer des catégories. */
.phs-cat-children {
  display: none;
  padding-left: 14px;
  margin-top: 2px;
}
.phs-cat-children.open { display: block; }
.phs-cat-child {
  font-size: 0.8rem;
  padding: 6px 10px;
  background: var(--color-gray-bg);
  margin-bottom: 2px;
}
.phs-cat-child:hover { background: #ececef; color: var(--color-blue); }
.phs-cat-child .phs-cat-count { background: #fff; }
.phs-cat-item { position: relative; }

/* ====== CHECKBOXES FILTRES ====== */
.phs-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--color-dark);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.phs-filter-checkbox:hover { background: var(--color-gray-bg); }
.phs-filter-checkbox input { display: none; }
.phs-checkbox-mark {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.phs-filter-checkbox input:checked + .phs-checkbox-mark {
  background: var(--color-blue);
  border-color: var(--color-blue);
}
.phs-filter-checkbox input:checked + .phs-checkbox-mark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}
.phs-filter-label { flex: 1; }

/* ====== PRIX ====== */
.phs-price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.phs-price-input {
  flex: 1 1 0;
  width: auto;
  min-width: 0; /* permet aux inputs number de rétrécir sans déborder à droite */
  text-align: center;
  padding: 9px 10px !important;
  font-size: 0.82rem !important;
}
.phs-price-sep { color: var(--color-gray-light); font-size: 0.8rem; }
.phs-price-apply {
  width: 100%;
  padding: 9px;
  background: var(--color-dark);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.phs-price-apply:hover { background: var(--color-black); }

/* Sidebar footer */
.phs-sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.phs-apply-filters {
  width: 100%;
  padding: 10px;
  background: var(--color-blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.phs-apply-filters:hover { background: var(--color-blue-hover); }
.phs-apply-filters.has-changes {
  animation: phs-pulse 0.3s ease;
}
@keyframes phs-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.phs-reset-filters {
  font-size: 0.78rem;
  color: var(--color-gray);
  text-decoration: none;
  text-align: center;
}
.phs-reset-filters:hover { color: var(--color-red); }

/* ====== TOOLBAR ====== */
.phs-shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.phs-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.phs-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Filter mobile button - hidden on desktop */
.phs-filter-mobile-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: white;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-dark);
  cursor: pointer;
  transition: all 0.2s;
}
.phs-filter-mobile-btn:hover { border-color: var(--color-dark); }

/* View toggle */
.phs-view-toggle {
  display: flex;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}
.phs-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  background: white;
  border: none;
  color: var(--color-gray-light);
  cursor: pointer;
  transition: all 0.15s;
}
.phs-view-btn:not(:last-child) { border-right: 1px solid var(--color-border); }
.phs-view-btn.active { color: var(--color-blue); background: rgba(0,113,227,0.06); }
.phs-view-btn:hover { color: var(--color-dark); }

/* Result count inside toolbar */
.phs-shop-toolbar .woocommerce-result-count {
  font-size: 0.82rem;
  color: var(--color-gray);
  margin: 0;
}

/* Ordering select inside toolbar */
.phs-shop-toolbar .woocommerce-ordering { margin: 0; }
.phs-shop-toolbar .woocommerce-ordering select {
  padding: 9px 36px 9px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.82rem;
  background: white;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ====== PRODUCT GRID (default = 3 colonnes avec sidebar) ====== */
.phs-shop-content ul.products {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Kill WooCommerce clearfix pseudo-elements that take grid cells */
.phs-shop-content ul.products::before,
.phs-shop-content ul.products::after {
  content: none !important;
  display: none !important;
}

/* Kill WooCommerce float-based grid (clear:both on .first, float on li) */
.phs-shop-content ul.products li.product,
.phs-shop-content ul.products li.product.first,
.phs-shop-content ul.products li.product.last {
  clear: none !important;
  float: none !important;
  margin-right: 0 !important;
  margin-left: 0 !important;
  width: auto !important;
}

/* Cartes produit — hauteur uniforme */
.phs-shop-content ul.products li.product {
  display: flex;
  flex-direction: column;
  background: var(--color-gray-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

/* Images — taille fixe identique sur toutes les cartes produit
 * On cible UNIQUEMENT les balises <img>, pas leur wrapper, pour ne pas
 * casser l'affichage du titre / prix / bouton.
 */
.phs-shop-content ul.products li.product img.wp-post-image,
.phs-shop-content ul.products li.product img.attachment-woocommerce_thumbnail,
.phs-shop-content ul.products li.product a img {
  width: 100% !important;
  height: 240px !important;
  max-height: 240px !important;
  object-fit: contain !important;
  padding: 16px !important;
  background: #ffffff !important;
  border-radius: 0 !important;
  margin: 0 !important;
  display: block;
  box-sizing: border-box;
}

/* Responsive : un peu plus petit en mobile */
@media (max-width: 640px) {
  .phs-shop-content ul.products li.product img.wp-post-image,
  .phs-shop-content ul.products li.product img.attachment-woocommerce_thumbnail,
  .phs-shop-content ul.products li.product a img {
    height: 180px !important;
    max-height: 180px !important;
    padding: 12px !important;
  }
}

/* Titre produit */
.phs-shop-content ul.products li.product .woocommerce-loop-product__title,
.phs-shop-content ul.products li.product h2 {
  font-size: 0.88rem !important;
  font-weight: 600;
  padding: 12px 14px 4px !important;
  margin: 0;
  color: var(--color-black);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 50px;
}

/* Prix */
.phs-shop-content ul.products li.product .price {
  padding: 2px 14px 12px;
  font-size: 0.95rem !important;
  font-weight: 700;
  color: var(--color-black);
  flex: 1;
  text-align: center;
}

/* Bouton ajout panier — collé en bas */
.phs-shop-content ul.products li.product .button,
.phs-shop-content ul.products li.product a.add_to_cart_button,
.phs-shop-content ul.products li.product a.product_type_variable,
.phs-shop-content ul.products li.product a.product_type_simple {
  display: block;
  text-align: center;
  padding: 11px 14px;
  background: var(--color-blue);
  color: white !important;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  border-radius: 0;
  width: 100%;
  margin: auto 0 0 0;
  text-decoration: none;
  transition: background 0.2s;
}
.phs-shop-content ul.products li.product .button:hover {
  background: var(--color-blue-hover);
}

/* Lien "Voir le panier" affiché par WooCommerce après ajout AJAX */
.phs-shop-content ul.products li.product a.added_to_cart {
  display: block;
  width: 100%;
  text-align: center;
  padding: 9px 14px;
  margin: 0;
  background: #f2f2f4;
  color: var(--color-black) !important;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border-top: 1px solid #e5e5e7;
  transition: background 0.2s;
}
.phs-shop-content ul.products li.product a.added_to_cart:hover {
  background: #e8e8eb;
}

/* État "ajouté" du bouton principal */
.phs-shop-content ul.products li.product a.add_to_cart_button.added {
  background: var(--color-blue);
}

/* Bouton "Non disponible" — rupture de stock */
.phs-shop-content ul.products li.product .button.product-unavailable,
ul.products li.product .button.product-unavailable,
.button.product-unavailable {
  background: #e5e5e7 !important;
  color: #86868b !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  opacity: 0.95;
}
.phs-shop-content ul.products li.product .button.product-unavailable:hover,
ul.products li.product .button.product-unavailable:hover {
  background: #e5e5e7 !important;
  color: #86868b !important;
}

/* 4 col variant (toggle JS) */
.phs-shop-content ul.products.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ====== PASTILLES COULEUR ====== */
.phs-color-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 14px 10px;
}

.phs-color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  outline: 1.5px solid rgba(0,0,0,0.15);
  outline-offset: 0px;
  cursor: default;
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-bottom: 5px !important;
}

.phs-color-dot:hover {
  transform: scale(1.35);
  z-index: 1;
  outline-color: rgba(0,0,0,0.35);
}

/* Blanc / couleurs claires → contour plus marqué */
.phs-color-dot.phs-dot--light {
  outline-color: #b0b0b0;
}

/* Badge "+N" couleurs supplémentaires */
.phs-dot--more {
  background: #f3f4f6 !important;
  outline: 1.5px solid #d1d5db !important;
  color: #6b7280;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  width: auto;
  min-width: 18px;
  padding: 0 3px;
  border-radius: 7px;
}

/* ====== PAGINATION ====== */
.phs-pagination {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
}

.phs-pagination .woocommerce-pagination,
.woocommerce-pagination {
  text-align: center;
}

/* Conteneur — pas de fond, pas de bordure */
.phs-pagination .woocommerce-pagination ul,
.woocommerce-pagination ul {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.phs-pagination .woocommerce-pagination ul li,
.woocommerce-pagination ul li {
  margin: 0 3px !important;
  padding: 0 !important;
  border: none !important;
  background: none !important;
  display: flex !important;
  align-items: center !important;
}

/* Chaque item — cercle parfait */
.phs-pagination .woocommerce-pagination ul li a,
.phs-pagination .woocommerce-pagination ul li span,
.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  line-height: 36px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  color: var(--color-gray) !important;
  background: #efefef !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  transition: background 0.18s, color 0.18s;
}

/* Hover */
.phs-pagination .woocommerce-pagination ul li a:hover,
.woocommerce-pagination ul li a:hover {
  background: #e0e0e0;
  color: var(--color-dark);
}

/* Page actuelle */
.phs-pagination .woocommerce-pagination ul li span.current,
.woocommerce-pagination ul li span.current {
  background: var(--color-blue) !important;
  color: white !important;
  box-shadow: 0 2px 10px rgba(0,113,227,0.3);
}

/* Flèches précédent/suivant */
.phs-pagination .woocommerce-pagination ul li a.prev,
.phs-pagination .woocommerce-pagination ul li a.next,
.woocommerce-pagination ul li a.prev,
.woocommerce-pagination ul li a.next {
  font-size: 1rem;
  background: #f0f0f0;
  color: var(--color-dark);
}
.phs-pagination .woocommerce-pagination ul li a.prev:hover,
.phs-pagination .woocommerce-pagination ul li a.next:hover,
.woocommerce-pagination ul li a.prev:hover,
.woocommerce-pagination ul li a.next:hover {
  background: var(--color-dark);
  color: white;
}

/* Dots (...) — pas de fond */
.phs-pagination .woocommerce-pagination ul li span.dots,
.woocommerce-pagination ul li span.dots {
  background: none !important;
  color: var(--color-gray-light) !important;
  font-size: 0.9rem !important;
  width: auto !important;
  min-width: 20px !important;
  box-shadow: none !important;
  cursor: default;
}

/* ====== SIDEBAR OVERLAY (mobile) ====== */
.phs-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1099;
  opacity: 0;
  transition: opacity 0.3s;
}
.phs-sidebar-overlay.active { display: block; opacity: 1; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .phs-shop-layout { grid-template-columns: 240px 1fr; gap: 24px; }
  .phs-shop-content ul.products { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 768px) {
  .phs-shop-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Sidebar = slide-in drawer */
  .phs-shop-sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 290px;
    height: 100vh;
    height: 100dvh; /* dynamic viewport — barres mobile masquées/affichées */
    z-index: 1100;
    border-radius: 0;
    border: none;
    transition: left 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .phs-shop-sidebar.open { left: 0; }

  .phs-sidebar-close { display: flex; }
  .phs-filter-mobile-btn { display: flex; }

  .phs-sidebar-header { flex: 0 0 auto; }
  .phs-sidebar-footer {
    flex: 0 0 auto;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    background: white;
  }
  .phs-sidebar-content {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }

  .phs-shop-content ul.products { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }

  .phs-shop-hero { padding: 14px 0 20px; }
  .phs-shop-title { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .phs-toolbar-right .phs-view-toggle { display: none; }
  .phs-shop-toolbar { gap: 8px; }
}
