/* Rosaifa 4.12.16 — P5 Category UX & Smart Filters */
body.rf-p5-filter-open { overflow: hidden; }

.rf-p5-discovery {
  background: linear-gradient(180deg,#fff 0%,#fcfaf8 100%);
  border: 1px solid var(--rf-line);
  border-radius: 22px;
  clear: both;
  margin: 6px 0 24px;
  padding: 20px;
  position: relative;
  width: 100%;
}
.rf-p5-discovery-head { align-items: end; display: flex; gap: 20px; justify-content: space-between; }
.rf-p5-discovery-head > div:first-child { display: grid; gap: 4px; min-width: 0; }
.rf-p5-discovery-head strong { font-family: var(--rf-serif); font-size: 28px; font-weight: 400; letter-spacing: -.02em; line-height: 1.05; }
.rf-p5-discovery-head small { color: var(--rf-ink-soft); font-size: 11px; line-height: 1.45; max-width: 720px; }
.rf-p5-head-actions { align-items: center; display: flex; flex: 0 0 auto; gap: 10px; }
.rf-p5-clear-all { color: var(--rf-ink-soft); font-size: 10px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; text-transform: uppercase; }
.rf-p5-filter-open { display: none; }

.rf-p5-active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.rf-p5-active-filters a { align-items: center; background: #f5efea; border: 1px solid rgba(116,74,78,.14); border-radius: 999px; color: var(--rf-ink); display: inline-flex; font-size: 10px; gap: 6px; min-height: 30px; padding: 5px 9px 5px 11px; }
.rf-p5-active-filters a small { color: var(--rf-ink-soft); font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.rf-p5-active-filters a span { align-items: center; display: inline-flex; font-size: 15px; height: 18px; justify-content: center; line-height: 1; width: 18px; }

.rf-p5-filter-panel { border-top: 1px solid var(--rf-line-soft); margin-top: 18px; padding-top: 18px; }
.rf-p5-mobile-head { display: none; }
.rf-p5-filter-form { align-items: end; display: grid; gap: 12px; grid-template-columns: repeat(4,minmax(0,1fr)); }
.rf-p5-field { display: grid; gap: 6px; min-width: 0; }
.rf-p5-field > span:first-child { color: var(--rf-ink-soft); font-size: 8px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.rf-p5-field select,
.rf-p5-field input { background: #fff; border: 1px solid var(--rf-line); border-radius: 12px; color: var(--rf-ink); font-size: 11px; height: 44px; min-width: 0; outline: none; padding: 0 12px; width: 100%; }
.rf-p5-field select:focus,
.rf-p5-field input:focus { border-color: rgba(116,74,78,.62); box-shadow: 0 0 0 3px rgba(116,74,78,.08); }
.rf-p5-price-inputs { align-items: center; display: grid; gap: 6px; grid-template-columns: 1fr auto 1fr; }
.rf-p5-price-inputs i { color: var(--rf-ink-soft); font-size: 10px; font-style: normal; }
.rf-p5-form-actions { align-items: center; display: flex; gap: 10px; grid-column: 1 / -1; justify-content: flex-end; margin-top: 2px; }
.rf-p5-form-actions > a { color: var(--rf-ink-soft); font-size: 10px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; text-transform: uppercase; }
.rf-p5-apply { background: var(--rf-ink); border: 1px solid var(--rf-ink); border-radius: 999px; color: #fff; cursor: pointer; font-size: 10px; font-weight: 850; min-height: 42px; padding: 0 20px; text-transform: uppercase; }
.rf-p5-apply:hover { background: var(--rf-rose-dark); border-color: var(--rf-rose-dark); }
.rf-p5-filter-backdrop { display: none; }

/* P5 owns archive filters; avoid duplicate widget-filter UI. */
.rf-shop-layout.no-sidebar { display: block; }
.rf-shop-layout.no-sidebar .rf-shop-content { width: 100%; }

/* Hide empty or invalid subcategory cards if legacy term counts surface unexpectedly. */
.rf-archive-subcat[data-rf-count="0"] { display: none !important; }

@media (max-width: 980px) and (min-width: 821px) {
  .rf-p5-filter-form { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .rf-p5-discovery { border-radius: 18px; margin: 4px 0 18px; padding: 15px; }
  .rf-p5-discovery-head { align-items: center; }
  .rf-p5-discovery-head strong { font-size: 24px; }
  .rf-p5-discovery-head small { font-size: 10px; }
  .rf-p5-clear-all { display: none; }
  .rf-p5-filter-open { align-items: center; background: var(--rf-ink); border: 1px solid var(--rf-ink); border-radius: 999px; color: #fff; display: inline-flex; font-size: 10px; font-weight: 850; gap: 7px; min-height: 40px; padding: 0 14px; text-transform: uppercase; }
  .rf-p5-filter-open span { align-items: center; background: #fff; border-radius: 999px; color: var(--rf-ink); display: inline-flex; font-size: 9px; height: 18px; justify-content: center; min-width: 18px; padding: 0 5px; }
  .rf-p5-active-filters { flex-wrap: nowrap; margin-inline: -15px; overflow-x: auto; padding: 0 15px 2px; scrollbar-width: none; }
  .rf-p5-active-filters::-webkit-scrollbar { display: none; }
  .rf-p5-active-filters a { flex: 0 0 auto; }

  .rf-p5-filter-panel {
    background: var(--rf-paper);
    border: 0;
    border-radius: 24px 24px 0 0;
    bottom: 0;
    box-shadow: 0 -18px 60px rgba(28,21,17,.2);
    left: 0;
    margin: 0;
    max-height: min(84dvh,760px);
    overflow-y: auto;
    padding: 18px 16px max(20px,env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    pointer-events: none;
    transform: translateY(105%);
    transition: transform .24s ease, visibility 0s linear .24s;
    visibility: hidden;
    z-index: 1104;
  }
  body.rf-p5-filter-open .rf-p5-filter-panel { pointer-events: auto; transform: translateY(0); transition-delay: 0s; visibility: visible; }
  .rf-p5-mobile-head { align-items: center; border-bottom: 1px solid var(--rf-line); display: flex; justify-content: space-between; margin-bottom: 16px; padding: 0 2px 14px; }
  .rf-p5-mobile-head > div { display: grid; gap: 2px; }
  .rf-p5-mobile-head span { font-family: var(--rf-serif); font-size: 25px; line-height: 1; }
  .rf-p5-mobile-head small { color: var(--rf-ink-soft); font-size: 9px; }
  .rf-p5-mobile-head button { align-items: center; background: #fff; border: 1px solid var(--rf-line); border-radius: 50%; display: flex; font-size: 24px; height: 38px; justify-content: center; line-height: 1; width: 38px; }
  .rf-p5-filter-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .rf-p5-price-field { grid-column: 1 / -1; }
  .rf-p5-field select,
  .rf-p5-field input { font-size: 12px; height: 46px; }
  .rf-p5-form-actions { background: linear-gradient(180deg,rgba(255,253,251,.76),var(--rf-paper) 30%); bottom: calc(-1 * max(20px,env(safe-area-inset-bottom))); grid-column: 1 / -1; margin: 3px -2px 0; padding: 15px 2px max(20px,env(safe-area-inset-bottom)); position: sticky; }
  .rf-p5-form-actions > a { margin-right: auto; }
  .rf-p5-apply { flex: 1; min-height: 46px; }
  .rf-p5-filter-backdrop { background: rgba(20,16,14,.48); border: 0; display: block; inset: 0; opacity: 0; pointer-events: none; position: fixed; transition: opacity .2s ease; z-index: 1103; }
  body.rf-p5-filter-open .rf-p5-filter-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 480px) {
  .rf-p5-discovery-head small { max-width: 230px; }
  .rf-p5-filter-form { gap: 10px; }
  .rf-p5-field > span:first-child { font-size: 7px; }
}
