/* ================================================================
   SHOP PAGE – herboristerie-ambre
   ================================================================ */

/* ── Shop Header ─────────────────────────────────────────────── */
.shop-page { background: var(--beige-light); min-height: 80vh; padding-bottom: 80px; }

.shop-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 32px 0 0;
  margin-bottom: 32px;
}

.shop-header-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.shop-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--green-dark);
  margin-bottom: 4px;
}

.shop-desc {
  font-size: .88rem;
  color: var(--text-muted);
  max-width: 480px;
}

.shop-count {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--beige-light);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 50px;
}

/* Category tabs */
.shop-cats-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1px;
  -webkit-overflow-scrolling: touch;
}
.shop-cats-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.cat-tab:hover  { color: var(--green-primary); }
.cat-tab.active {
  color: var(--green-primary);
  border-bottom-color: var(--green-primary);
  font-weight: 700;
}

/* ── Layout ──────────────────────────────────────────────────── */
.shop-layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 32px;
  align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.shop-sidebar {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  position: sticky;
  top: 90px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  color: var(--green-dark);
  margin: 0;
}

.sidebar-reset {
  font-size: .75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'DM Sans', sans-serif;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sidebar-reset:hover { color: #e74c3c; }

/* Filter groups */
.filter-group { border-bottom: 1px solid var(--border); }
.filter-group:last-of-type { border-bottom: none; }

.filter-group-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 700;
  color: var(--green-dark);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}
.filter-group-title:hover { color: var(--green-primary); }

.fg-arrow { transition: transform .25s ease; flex-shrink: 0; }
.filter-group.collapsed .fg-arrow { transform: rotate(-90deg); }

.filter-group-body { padding: 4px 20px 16px; }
.filter-group.collapsed .filter-group-body { display: none; }

/* Checkboxes */
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  font-size: .84rem;
  color: var(--text);
  transition: var(--transition);
}
.filter-checkbox:hover { color: var(--green-primary); }
.filter-checkbox input { display: none; }

.checkbox-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  background: var(--white);
}
.filter-checkbox input:checked ~ .checkbox-box {
  background: var(--green-primary);
  border-color: var(--green-primary);
}
.filter-checkbox input:checked ~ .checkbox-box::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

.radio-box { border-radius: 50%; }
.filter-checkbox input:checked ~ .radio-box::after {
  content: '';
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  display: block;
  border: none;
  transform: none;
}

.checkbox-label { flex: 1; }
.checkbox-count {
  font-size: .72rem;
  color: var(--text-muted);
  background: var(--beige-light);
  border-radius: 50px;
  padding: 1px 7px;
}

/* Star filter */
.star-row {
  color: #f0a500;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.star-label { font-size: .78rem; color: var(--text-muted); }

/* Price range slider */
.price-range-wrap { padding: 8px 0; }

.price-slider-track {
  position: relative;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 24px 0 16px;
}

.price-slider-fill {
  position: absolute;
  height: 100%;
  background: var(--green-primary);
  border-radius: 2px;
  pointer-events: none;
}

.price-range {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
  outline: none;
}
.price-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--white);
  border: 2px solid var(--green-primary);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 2px 6px rgba(74,103,65,.25);
  transition: transform .15s ease;
}
.price-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.price-range::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--white);
  border: 2px solid var(--green-primary);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
}

.price-inputs {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.price-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  color: var(--text-muted);
}
.price-val {
  font-weight: 700;
  color: var(--green-dark);
  font-size: .85rem;
}

/* Apply button */
.sidebar-apply { padding: 16px 20px; }
.btn-apply-filters {
  width: 100%;
  padding: 12px;
  background: var(--green-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-apply-filters:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(74,103,65,.1);
  color: var(--green-primary);
  border-radius: 50px;
  padding: 5px 12px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid rgba(74,103,65,.2);
  transition: var(--transition);
}
.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--green-primary);
  padding: 0;
  font-size: .85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.chip-remove:hover { color: #e74c3c; }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: .82rem; color: var(--text-muted); white-space: nowrap; }

.sort-select {
  padding: 8px 32px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white) 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='%236b7c6b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  color: var(--green-dark);
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.sort-select:focus { border-color: var(--green-primary); }

.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-btn {
  padding: 8px 11px;
  background: var(--white);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.view-btn:first-child { border-right: 1px solid var(--border); }
.view-btn:hover,
.view-btn.active { background: var(--green-primary); color: #fff; }

/* ── Product Grid ────────────────────────────────────────────── */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  transition: opacity .25s ease;
}

.shop-grid.loading { opacity: .4; pointer-events: none; }

/* List view */
.shop-grid.list-view {
  grid-template-columns: 1fr;
}
.shop-grid.list-view .shop-card {
  flex-direction: row;
  display: flex;
}
.shop-grid.list-view .shop-card-img-wrap {
  flex-shrink: 0;
  width: 220px;
}
.shop-grid.list-view .shop-card-img-wrap img { height: 180px; }
.shop-grid.list-view .shop-card-body { padding: 20px 24px; display: flex; flex-direction: column; justify-content: center; }
.shop-grid.list-view .card-desc { display: block; }

/* ── Product Card ────────────────────────────────────────────── */
.shop-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}
.shop-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.shop-card-img-wrap {
  position: relative;
  overflow: hidden;
}
.shop-card-img-wrap img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}
.shop-card:hover .shop-card-img-wrap img { transform: scale(1.04); }

/* Badge */
.card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 50px;
  z-index: 2;
}
.badge-hot  { background: var(--green-primary); color: #fff; }
.badge-sale { background: #e74c3c; color: #fff; }
.badge-new  { background: #2980b9; color: #fff; }

.card-stock-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(183,89,0,.88);
  color: #fff;
  font-size: .65rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 50px;
  backdrop-filter: blur(4px);
  z-index: 2;
}

/* Hover action buttons */
.card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
  opacity: 0;
  transform: translateX(8px);
  transition: var(--transition);
}
.shop-card:hover .card-actions { opacity: 1; transform: translateX(0); }

.card-action-btn {
  width: 34px;
  height: 34px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  text-decoration: none;
}
.card-action-btn:hover {
  background: var(--green-primary);
  color: #fff;
  border-color: var(--green-primary);
}
.card-action-btn.wishlist-btn.wishlisted {
  color: #e74c3c;
  border-color: #e74c3c;
}

/* Card body */
.shop-card-body { padding: 16px; }

.card-category {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green-light);
  margin-bottom: 6px;
}

.card-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  margin-bottom: 5px;
  line-height: 1.3;
}
.card-name a { color: var(--green-dark); transition: var(--transition); }
.card-name a:hover { color: var(--green-primary); }

.card-desc {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Stars — clip trick for partial fill */
.card-stars {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 12px;
}
.stars-filled {
  position: relative;
  display: inline-block;
  color: #ddd;
  font-size: .9rem;
  letter-spacing: .05em;
}
.stars-filled::before {
  content: '★★★★★';
  position: absolute;
  inset: 0;
  color: #f0a500;
  width: var(--pct, 80%);
  overflow: hidden;
  white-space: nowrap;
}
.card-rev-count { font-size: .72rem; color: var(--text-muted); }

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-price-wrap { display: flex; align-items: baseline; gap: 6px; }
.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
}
.card-price .woocommerce-Price-amount { font-size: 1.1rem; color: var(--green-dark); }
.card-price ins { text-decoration: none; }
.card-price-old {
  font-size: .78rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.card-cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--green-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.card-cart-btn:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}
.card-cart-btn.added { background: var(--green-dark); }

/* ── Empty state ─────────────────────────────────────────────── */
.shop-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}
.shop-empty h3 { font-size: 1.2rem; margin: 16px 0 8px; color: var(--text); }
.shop-empty p  { font-size: .9rem; }
.shop-empty button { color: var(--green-primary); text-decoration: underline; background: none; border: none; cursor: pointer; font: inherit; }

/* ── Pagination ──────────────────────────────────────────────── */
.shop-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid var(--border);
  background: var(--white);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--green-primary); color: var(--green-primary); }
.page-btn.active {
  background: var(--green-primary);
  border-color: var(--green-primary);
  color: #fff;
  font-weight: 700;
}
.page-dots { color: var(--text-muted); padding: 0 4px; }
.page-next { gap: 6px; }

/* WooCommerce pagination override */
.woocommerce-pagination ul {
  display: flex;
  gap: 6px;
  list-style: none;
  align-items: center;
  justify-content: center;
}
.woocommerce-pagination li a,
.woocommerce-pagination li span {
  min-width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  background: var(--white); border-radius: 8px;
  font-size: .85rem; font-weight: 500; color: var(--text);
  transition: var(--transition); padding: 0 12px;
}
.woocommerce-pagination li a:hover { border-color: var(--green-primary); color: var(--green-primary); }
.woocommerce-pagination li span.current { background: var(--green-primary); border-color: var(--green-primary); color: #fff; font-weight: 700; }

/* ── Mobile Filter Button ────────────────────────────────────── */
.mobile-filter-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 980;
  padding: 13px 28px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(47,62,47,.35);
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.mobile-filter-btn:hover { background: var(--green-primary); transform: translateX(-50%) translateY(-2px); }

.mobile-filter-count {
  background: #e74c3c;
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Filter overlay backdrop */
.filter-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 985;
  backdrop-filter: blur(2px);
}
.filter-backdrop.visible { display: block; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .shop-layout { grid-template-columns: 220px 1fr; gap: 24px; }
  .shop-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .shop-layout { grid-template-columns: 1fr; }

  .shop-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 990;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    top: auto;
    border: none;
    box-shadow: 0 -8px 40px rgba(47,62,47,.18);
  }
  .shop-sidebar.open { transform: translateY(0); }

  .sidebar-header::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
  }
  .sidebar-header { position: relative; padding-top: 24px; }

  .mobile-filter-btn { display: inline-flex; }

  .shop-grid { grid-template-columns: repeat(2, 1fr); }
  .sort-label { display: none; }
}

@media (max-width: 540px) {
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .shop-card-img-wrap img { height: 160px; }
  .card-cart-btn span { display: none; }
  .shop-cats-tabs { gap: 2px; }
  .cat-tab { padding: 8px 14px; font-size: .8rem; }
  .toolbar-right { gap: 8px; }
  .view-toggle { display: none; }
}

/* ── Filter link active states ───────────────────────────────── */
.filter-cat-link {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text-muted, #6b7280);
  text-decoration: none;
  transition: background .18s, color .18s;
}
.filter-cat-link:hover {
  background: var(--beige, #f5f5f0);
  color: var(--green-dark, #2f3e2f);
}
.filter-cat-link.active,
.filter-cat-link[aria-current="page"] {
  background: var(--green-light, #e8f0e7);
  color: var(--green-dark, #2f3e2f);
  font-weight: 600;
}

.cat-tab.active {
  background: var(--green-dark, #2f3e2f);
  color: #fff;
  border-color: var(--green-dark, #2f3e2f);
}

/* ── Out-of-stock badge ──────────────────────────────────────── */
.card-out-of-stock {
  display: inline-block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted, #6b7280);
  background: var(--beige, #f5f5f0);
  border: 1px solid var(--border, #e8e8e3);
  padding: 5px 12px;
  border-radius: 20px;
  margin-top: 4px;
}

/* ── WC add-to-cart button states ────────────────────────────── */
.card-cart-btn.loading {
  opacity: .7;
  pointer-events: none;
  position: relative;
}
.card-cart-btn.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  animation: cc-spin .6s linear infinite;
}
@keyframes cc-spin { to { transform: translateY(-50%) rotate(360deg); } }

.card-cart-btn.added {
  background: var(--green-primary, #4a6741) !important;
}
.card-cart-btn.added::before {
  content: '✓ ';
}

/* ================================================================
   SHOP PAGE – Responsive Enhancements v2
   Fills remaining gaps for all mobile breakpoints.
   ================================================================ */

/* ── 1. Page padding: reduce on mobile ──────────────────────── */
@media (max-width: 768px) {
  .shop-page { padding-bottom: 56px; }
}

/* ── 2. Shop header: compact on mobile ──────────────────────── */
@media (max-width: 768px) {
  .shop-header        { padding: 20px 0 0; margin-bottom: 20px; }
  .shop-header-inner  { margin-bottom: 12px; gap: 10px; }
  .shop-count         { display: none; }
  .shop-title         { font-size: 1.5rem; }
  .shop-desc          { font-size: .84rem; }
}

/* ── 3. Category tabs: smaller on phones ─────────────────────── */
@media (max-width: 480px) {
  .cat-tab { padding: 8px 12px; font-size: .78rem; }
}

/* ── 4. Shop toolbar: simplified on small screens ───────────── */
@media (max-width: 540px) {
  .shop-toolbar   { gap: 10px; margin-bottom: 14px; }
  .active-filters { gap: 6px; }
  .filter-chip    { font-size: .7rem; padding: 4px 10px; }
  .sort-label     { display: none; }
  .sort-select    { padding: 8px 28px 8px 10px; font-size: .82rem; }
  .toolbar-right  { gap: 8px; }
  .view-toggle    { display: none; }
}

/* ── 5. Shop grid cards: touch-friendly on mobile ───────────── */
@media (max-width: 540px) {
  .shop-card-body   { padding: 12px; }
  .card-name        { font-size: .9rem; }
  .card-desc        { font-size: .74rem; -webkit-line-clamp: 2; }
  .card-price,
  .card-price .woocommerce-Price-amount { font-size: 1rem; }
  .card-footer      { gap: 6px; flex-wrap: wrap; }
  .card-cart-btn    {
    padding: 9px 12px;
    font-size: .76rem;
    min-height: 38px;
    flex-shrink: 0;
  }
  /* Keep 2-column grid but tighten cards */
  .shop-grid        { gap: 10px; }
  .shop-card-img-wrap img { height: 150px; }
}

/* ── 6. Shop grid: 1-column on very small phones ─────────────── */
@media (max-width: 360px) {
  .shop-grid { grid-template-columns: 1fr; }
  .shop-card-img-wrap img { height: 180px; }
}

/* ── 7. Mobile filter button: better positioning ─────────────── */
@media (max-width: 540px) {
  .mobile-filter-btn {
    bottom: 20px;
    padding: 11px 20px;
    font-size: .85rem;
  }
}

/* ── 8. Shop sidebar drawer: safe area + sticky apply btn ────── */
@media (max-width: 900px) {
  .shop-sidebar  { max-height: 90vh; padding-bottom: env(safe-area-inset-bottom, 20px); }
  .sidebar-apply {
    padding: 14px 16px;
    position: sticky;
    bottom: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 2;
  }
}

/* ── 9. iOS zoom prevention on sort select ───────────────────── */
.sort-select { font-size: 16px; }
@media (min-width: 769px) {
  .sort-select { font-size: .85rem; }
}

/* ── 10. List view: disable on mobile (too cramped) ──────────── */
@media (max-width: 540px) {
  .shop-grid.list-view {
    grid-template-columns: 1fr;
  }
  .shop-grid.list-view .shop-card {
    flex-direction: column;
  }
  .shop-grid.list-view .shop-card-img-wrap {
    width: 100%;
  }
  .shop-grid.list-view .shop-card-img-wrap img { height: 180px; }
}

/* ── 11. Pagination: compact on mobile ──────────────────────── */
@media (max-width: 480px) {
  .shop-pagination { gap: 4px; margin-top: 28px; padding-top: 24px; }
  .page-btn        { min-width: 36px; height: 36px; padding: 0 10px; font-size: .8rem; }
  .woocommerce-pagination li a,
  .woocommerce-pagination li span { min-width: 36px; height: 36px; padding: 0 8px; font-size: .8rem; }
}

/* ================================================================
   SHOP PAGE — RTL v3 (architecture complète refondée)
   ----------------------------------------------------------------
   Stratégie :
   1. `direction: rtl` est appliqué sur tous les conteneurs grid/flex
      racines du shop. Avec CSS Grid, ça inverse automatiquement
      l'ordre visuel des colonnes (sidebar passe à droite, main à
      gauche) sans avoir besoin de `order`.
   2. Les anciennes règles `order: 1/2` sur sidebar/products étaient
      mortes (mauvais sélecteur `.shop-products`) — supprimées.
   3. Les éléments positionnés en absolu (badges, actions sur card)
      utilisent `inset-inline-*` (logical) où possible, sinon
      `right: auto; left: X` explicite en RTL.
   4. Tous les sélecteurs ont 4 niveaux de scope défensif :
      html[dir="rtl"], html[data-dir="rtl"], body.lang-ar, body.dir-rtl
      pour résister aux resets de Polylang/WC/3rd-party.
   5. Aucun !important — la spécificité des sélecteurs combinés
      suffit toujours.
   ================================================================ */

/* ─── Scope principal : tout le .shop-page reçoit direction RTL ── */
html[dir="rtl"] .shop-page,
html[data-dir="rtl"] .shop-page,
body.lang-ar    .shop-page,
body.dir-rtl    .shop-page              {
  direction: rtl;
}

/* ─── 1. BREADCRUMB ──────────────────────────────────────────── */
html[dir="rtl"] .product-breadcrumb-bar .breadcrumb,
html[data-dir="rtl"] .product-breadcrumb-bar .breadcrumb,
body.lang-ar    .product-breadcrumb-bar .breadcrumb,
body.dir-rtl    .product-breadcrumb-bar .breadcrumb {
  direction: rtl;
  justify-content: flex-start;
  text-align: right;
}

/* ─── 2. SHOP HEADER (titre + meta) ──────────────────────────── */
html[dir="rtl"] .shop-header-inner,
html[data-dir="rtl"] .shop-header-inner,
body.lang-ar    .shop-header-inner,
body.dir-rtl    .shop-header-inner      { direction: rtl; }

html[dir="rtl"] .shop-title,
html[dir="rtl"] .shop-desc,
html[data-dir="rtl"] .shop-title,
html[data-dir="rtl"] .shop-desc,
body.lang-ar    .shop-title,
body.lang-ar    .shop-desc,
body.dir-rtl    .shop-title,
body.dir-rtl    .shop-desc              {
  text-align: right;
  direction: rtl;
}

html[dir="rtl"] .shop-count,
html[data-dir="rtl"] .shop-count,
body.lang-ar    .shop-count,
body.dir-rtl    .shop-count             {
  direction: rtl;
  text-align: center;
  white-space: nowrap;
}

/* ─── 3. CATEGORY TABS ──────────────────────────────────────── */
html[dir="rtl"] .shop-cats-tabs,
html[data-dir="rtl"] .shop-cats-tabs,
body.lang-ar    .shop-cats-tabs,
body.dir-rtl    .shop-cats-tabs         { direction: rtl; }

/* ─── 4. SHOP LAYOUT (grid 2 colonnes) ───────────────────────────
   Le grid template reste 256px 1fr ; `direction: rtl` posé sur
   .shop-layout fait que CSS Grid place :
   - 1ère colonne (256px) à DROITE (= sidebar)
   - 2ème colonne (1fr) à GAUCHE (= main avec produits)
   Pas besoin de réordonner les colonnes du grid-template. */
html[dir="rtl"] .shop-layout,
html[data-dir="rtl"] .shop-layout,
body.lang-ar    .shop-layout,
body.dir-rtl    .shop-layout            {
  direction: rtl;
}

/* Le main (produits) garde sa direction RTL héritée pour que
   les cards et leur contenu soient lus dans le bon sens. */
html[dir="rtl"] .shop-main,
html[data-dir="rtl"] .shop-main,
body.lang-ar    .shop-main,
body.dir-rtl    .shop-main              { direction: rtl; }

/* ─── 5. SIDEBAR FILTRES ────────────────────────────────────── */
html[dir="rtl"] .shop-sidebar,
html[data-dir="rtl"] .shop-sidebar,
body.lang-ar    .shop-sidebar,
body.dir-rtl    .shop-sidebar           { direction: rtl; }

html[dir="rtl"] .sidebar-header,
html[data-dir="rtl"] .sidebar-header,
body.lang-ar    .sidebar-header,
body.dir-rtl    .sidebar-header         { direction: rtl; }

html[dir="rtl"] .sidebar-title,
html[data-dir="rtl"] .sidebar-title,
body.lang-ar    .sidebar-title,
body.dir-rtl    .sidebar-title          {
  flex-direction: row-reverse;
  text-align: right;
}

html[dir="rtl"] .filter-group-title,
html[data-dir="rtl"] .filter-group-title,
body.lang-ar    .filter-group-title,
body.dir-rtl    .filter-group-title     {
  flex-direction: row-reverse;
  text-align: right;
  direction: rtl;
}

html[dir="rtl"] .filter-group-body,
html[data-dir="rtl"] .filter-group-body,
body.lang-ar    .filter-group-body,
body.dir-rtl    .filter-group-body      { direction: rtl; }

html[dir="rtl"] .filter-checkbox,
html[data-dir="rtl"] .filter-checkbox,
body.lang-ar    .filter-checkbox,
body.dir-rtl    .filter-checkbox        {
  flex-direction: row-reverse;
  text-align: right;
}

html[dir="rtl"] .checkbox-label,
html[data-dir="rtl"] .checkbox-label,
body.lang-ar    .checkbox-label,
body.dir-rtl    .checkbox-label         { text-align: right; }

html[dir="rtl"] .checkbox-count,
html[data-dir="rtl"] .checkbox-count,
body.lang-ar    .checkbox-count,
body.dir-rtl    .checkbox-count         {
  margin-inline-start: 0;
  margin-inline-end: auto;
}

html[dir="rtl"] .price-inputs,
html[data-dir="rtl"] .price-inputs,
body.lang-ar    .price-inputs,
body.dir-rtl    .price-inputs           { direction: rtl; }

html[dir="rtl"] .price-input-group,
html[data-dir="rtl"] .price-input-group,
body.lang-ar    .price-input-group,
body.dir-rtl    .price-input-group      { direction: rtl; }

/* ─── 6. TOOLBAR (active filters + tri + view-toggle) ───────── */
html[dir="rtl"] .shop-toolbar,
html[data-dir="rtl"] .shop-toolbar,
body.lang-ar    .shop-toolbar,
body.dir-rtl    .shop-toolbar           {
  direction: rtl;
  flex-direction: row-reverse;
}

html[dir="rtl"] .active-filters,
html[data-dir="rtl"] .active-filters,
body.lang-ar    .active-filters,
body.dir-rtl    .active-filters         { direction: rtl; }

html[dir="rtl"] .toolbar-right,
html[data-dir="rtl"] .toolbar-right,
body.lang-ar    .toolbar-right,
body.dir-rtl    .toolbar-right          {
  direction: rtl;
  flex-direction: row-reverse;
}

html[dir="rtl"] .sort-wrap,
html[data-dir="rtl"] .sort-wrap,
body.lang-ar    .sort-wrap,
body.dir-rtl    .sort-wrap              { flex-direction: row-reverse; }

html[dir="rtl"] .sort-label,
html[data-dir="rtl"] .sort-label,
body.lang-ar    .sort-label,
body.dir-rtl    .sort-label             {
  margin-inline-start: 8px;
  margin-inline-end: 0;
}

html[dir="rtl"] .view-toggle,
html[data-dir="rtl"] .view-toggle,
body.lang-ar    .view-toggle,
body.dir-rtl    .view-toggle            { flex-direction: row-reverse; }

html[dir="rtl"] .active-filter-tag,
html[data-dir="rtl"] .active-filter-tag,
body.lang-ar    .active-filter-tag,
body.dir-rtl    .active-filter-tag      { flex-direction: row-reverse; }

html[dir="rtl"] .af-remove,
html[data-dir="rtl"] .af-remove,
body.lang-ar    .af-remove,
body.dir-rtl    .af-remove              {
  margin-inline-start: 0;
  margin-inline-end: 6px;
}

/* ─── 7. PRODUCT GRID ───────────────────────────────────────── */
html[dir="rtl"] .shop-grid,
html[data-dir="rtl"] .shop-grid,
body.lang-ar    .shop-grid,
body.dir-rtl    .shop-grid              {
  direction: rtl;
}

/* ─── 8. PRODUCT CARD ───────────────────────────────────────── */
html[dir="rtl"] .shop-card,
html[data-dir="rtl"] .shop-card,
body.lang-ar    .shop-card,
body.dir-rtl    .shop-card              { direction: rtl; }

html[dir="rtl"] .shop-card-body,
html[data-dir="rtl"] .shop-card-body,
body.lang-ar    .shop-card-body,
body.dir-rtl    .shop-card-body         {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .card-category,
html[dir="rtl"] .card-name,
html[dir="rtl"] .card-desc,
html[dir="rtl"] .card-price,
html[data-dir="rtl"] .card-category,
html[data-dir="rtl"] .card-name,
html[data-dir="rtl"] .card-desc,
html[data-dir="rtl"] .card-price,
body.lang-ar    .card-category,
body.lang-ar    .card-name,
body.lang-ar    .card-desc,
body.lang-ar    .card-price,
body.dir-rtl    .card-category,
body.dir-rtl    .card-name,
body.dir-rtl    .card-desc,
body.dir-rtl    .card-price             { text-align: right; }

/* Card badge (PROMO/NOUVEAU/BESTSELLER) : passe de gauche à droite */
html[dir="rtl"] .card-badge,
html[data-dir="rtl"] .card-badge,
body.lang-ar    .card-badge,
body.dir-rtl    .card-badge             {
  left: auto;
  right: 12px;
}

/* Stock badge (Plus que X) : passe de gauche à droite */
html[dir="rtl"] .card-stock-badge,
html[data-dir="rtl"] .card-stock-badge,
body.lang-ar    .card-stock-badge,
body.dir-rtl    .card-stock-badge       {
  left: auto;
  right: 10px;
}

/* Card actions (wishlist heart) : passe de droite à gauche */
html[dir="rtl"] .card-actions,
html[data-dir="rtl"] .card-actions,
body.lang-ar    .card-actions,
body.dir-rtl    .card-actions           {
  right: auto;
  left: 10px;
}

/* Stars : ordre inversé pour que les étoiles brillent en RTL aussi */
html[dir="rtl"] .card-stars,
html[data-dir="rtl"] .card-stars,
body.lang-ar    .card-stars,
body.dir-rtl    .card-stars             {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

html[dir="rtl"] .card-footer,
html[data-dir="rtl"] .card-footer,
body.lang-ar    .card-footer,
body.dir-rtl    .card-footer            { flex-direction: row-reverse; }

html[dir="rtl"] .card-cart-btn,
html[data-dir="rtl"] .card-cart-btn,
body.lang-ar    .card-cart-btn,
body.dir-rtl    .card-cart-btn          { flex-direction: row-reverse; }

html[dir="rtl"] .card-cart-btn svg,
html[data-dir="rtl"] .card-cart-btn svg,
body.lang-ar    .card-cart-btn svg,
body.dir-rtl    .card-cart-btn svg      {
  margin-inline-start: 4px;
  margin-inline-end: 0;
}

/* ─── 9. PAGINATION ─────────────────────────────────────────── */
html[dir="rtl"] .shop-pagination,
html[data-dir="rtl"] .shop-pagination,
body.lang-ar    .shop-pagination,
body.dir-rtl    .shop-pagination        { direction: rtl; }

html[dir="rtl"] .woocommerce-pagination ul,
html[data-dir="rtl"] .woocommerce-pagination ul,
body.lang-ar    .woocommerce-pagination ul,
body.dir-rtl    .woocommerce-pagination ul {
  direction: rtl;
  flex-direction: row-reverse;
}

/* ─── 10. EMPTY STATE ───────────────────────────────────────── */
html[dir="rtl"] .shop-empty,
html[data-dir="rtl"] .shop-empty,
body.lang-ar    .shop-empty,
body.dir-rtl    .shop-empty             {
  direction: rtl;
  text-align: center;
}

/* ─── 11. MOBILE FILTER BUTTON ──────────────────────────────── */
html[dir="rtl"] .mobile-filter-btn,
html[data-dir="rtl"] .mobile-filter-btn,
body.lang-ar    .mobile-filter-btn,
body.dir-rtl    .mobile-filter-btn      { flex-direction: row-reverse; }

/* ─── 12. RESPONSIVE RTL ────────────────────────────────────── */

/* ≤ 900px : sidebar passe en drawer bottom plein écran.
   Reset des positions inset pour éviter qu'elle reste cachée
   d'un côté en RTL. */
@media (max-width: 900px) {
  html[dir="rtl"] .shop-sidebar,
  html[data-dir="rtl"] .shop-sidebar,
  body.lang-ar    .shop-sidebar,
  body.dir-rtl    .shop-sidebar         {
    left: 0;
    right: 0;
    transform: translateY(100%);
  }
  html[dir="rtl"] .shop-sidebar.open,
  html[data-dir="rtl"] .shop-sidebar.open,
  body.lang-ar    .shop-sidebar.open,
  body.dir-rtl    .shop-sidebar.open    { transform: translateY(0); }

  /* La sidebar-header drag-handle reste centrée */
  html[dir="rtl"] .sidebar-header::before,
  html[data-dir="rtl"] .sidebar-header::before,
  body.lang-ar    .sidebar-header::before,
  body.dir-rtl    .sidebar-header::before {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

/* ≤ 540px : ajuster la toolbar pour qu'elle ne déborde pas en RTL */
@media (max-width: 540px) {
  html[dir="rtl"] .shop-toolbar,
  html[data-dir="rtl"] .shop-toolbar,
  body.lang-ar    .shop-toolbar,
  body.dir-rtl    .shop-toolbar         {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* ─── 13. PRÉVENTION OVERFLOW HORIZONTAL RTL ────────────────── */
/* Quelques 3rd-party plugins (Polylang/WC) injectent inline-style
   avec direction: ltr qui peuvent forcer un overflow. On clamp
   le shop-page pour éviter tout débordement horizontal sur mobile. */
html[dir="rtl"] .shop-page,
html[data-dir="rtl"] .shop-page,
body.lang-ar    .shop-page,
body.dir-rtl    .shop-page              {
  overflow-x: clip;
}
