/**
 * ToQueen - Filter by (Mobile chip bar)
 * ------------------------------------
 * فوق 767px (ديسكتوب/تابلت): ما نغيّر شي — سايدبار Woodmart الأصلي زي ما هو،
 * زي المخطط المعتمد.
 *
 * تحت 767px: نخفي أقسام الفلتر الأصلية (.tqfb-facet) عن مكانها الطبيعي،
 * ونعرض بدالها شريط شرائح أفقي قابل للسحب + لوحة سفلية (bottom sheet) مشتركة
 * تفتح بمحتوى الشريحة المضغوطة (نفس عناصر Woodmart الأصلية، منقولة بـ JS
 * مو منسوخة — فتحافظ على كل روابطها/سلوك الـ AJAX الأصلي كما هو).
 */

:root {
  --tqfb-chip-bg: #f5efe9;
  --tqfb-chip-bg-active: #2f2320;
  --tqfb-chip-text: #2f2320;
  --tqfb-chip-text-active: #ffffff;
  --tqfb-chip-border: #e4d9cf;
  --tqfb-sheet-bg: #ffffff;
  --tqfb-overlay-bg: rgba(20, 14, 12, 0.45);
  --tqfb-radius: 999px;
}

/* الشريط يظهر فقط بالموبايل */
.tqfb-chip-bar {
  display: none;
}

@media (max-width: 767px) {
  /* نخفي الودجتات الأصلية من مكانها بالسايدبار العادي */
  .tqfb-facet {
    display: none !important;
  }

  .tqfb-chip-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 16px;
    margin: 0 -16px 12px;
    background: transparent;
  }

  .tqfb-chip-bar::-webkit-scrollbar {
    display: none;
  }

  .tqfb-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--tqfb-radius);
    border: 1px solid var(--tqfb-chip-border);
    background: var(--tqfb-chip-bg);
    color: var(--tqfb-chip-text);
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
  }

  .tqfb-chip.tqfb-chip-active {
    background: var(--tqfb-chip-bg-active);
    color: var(--tqfb-chip-text-active);
    border-color: var(--tqfb-chip-bg-active);
  }

  .tqfb-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    font-size: 11px;
  }

  .tqfb-chip:not(.tqfb-chip-active) .tqfb-chip-count {
    background: rgba(0, 0, 0, 0.1);
  }

  .tqfb-chip-clear {
    color: #a33b3b;
    border-color: transparent;
    background: transparent;
    text-decoration: underline;
  }

  /* اللوحة السفلية المشتركة */
  .tqfb-overlay {
    position: fixed;
    inset: 0;
    background: var(--tqfb-overlay-bg);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .tqfb-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .tqfb-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 75vh;
    background: var(--tqfb-sheet-bg);
    border-radius: 16px 16px 0 0;
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  }

  .tqfb-sheet.is-open {
    transform: translateY(0);
  }

  .tqfb-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    margin: 10px auto 0;
  }

  .tqfb-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
  }

  .tqfb-sheet-header strong {
    font-size: 15px;
  }

  .tqfb-sheet-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
  }

  .tqfb-sheet-body {
    overflow-y: auto;
    padding: 8px 16px 16px;
    flex: 1;
  }

  /* الودجت الأصلي بعد ما ينتقل داخل اللوحة السفلية، يظهر عادي بدون تنسيق
     السايدبار (بدون عنوان مكرر لأنه صايرة اللوحة نفسها هي العنوان) */
  .tqfb-sheet-body .tqfb-facet {
    display: block !important;
    margin: 0;
  }

  .tqfb-sheet-body .tqfb-facet-title {
    display: none;
  }

  .tqfb-sheet-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: var(--tqfb-sheet-bg);
  }

  .tqfb-sheet-apply {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: var(--tqfb-radius);
    border: none;
    background: var(--tqfb-chip-bg-active);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
  }
}
