/* ═══════════════════════════════════════════════════════════════════
   prooptixsearch — galleries, autocomplete, mega menu, SEO sections.
   Relies on the prooptix theme tokens (--po-*, --font-*, .po-btn, .po-tag,
   .po-product-card base styles). Loaded after the theme (priority 210).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Gallery layout ── */
.po-gallery-wrap { max-width: var(--container-max, 1280px); margin: 0 auto; padding: 24px 16px 64px; }
.po-gallery-header { margin: 8px 0 20px; }
.po-gallery-intro { font-family: var(--font-support); color: var(--text-secondary); max-width: 720px; margin-top: 8px; }
.po-gallery-status { font-family: var(--font-support); font-size: var(--fs-body-sm); color: var(--text-muted); margin: 10px 2px; }
.po-gallery-grid { display: grid; gap: 20px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1199px) { .po-gallery-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 899px)  { .po-gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575px)  { .po-gallery-grid { grid-template-columns: 1fr; } }
.po-gallery-more { display: flex; justify-content: center; margin-top: 28px; }
.po-gallery-empty, .po-gallery-error {
  grid-column: 1 / -1; text-align: center; padding: 56px 16px;
  font-family: var(--font-support); color: var(--text-secondary);
}
.po-gallery-empty .po-btn { margin-top: 12px; }
.po-card-noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--po-grey-300); }
.po-product-card__variants { margin-left: auto; font-size: var(--fs-caption); color: var(--text-muted); }

/* ── Filter bar ── */
.po-filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px; margin: 4px 0 10px;
  background: var(--surface-subtle); border-radius: var(--radius-lg);
}
.po-filterbar__search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 200px;
  background: var(--po-white); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill); padding: 8px 14px; color: var(--text-muted);
}
.po-filterbar__search input {
  border: 0; outline: 0; width: 100%; font-family: var(--font-support);
  font-size: var(--fs-body-sm); background: transparent; color: var(--text-primary);
}
.po-facet { position: relative; font-family: var(--font-support); font-size: var(--fs-body-sm); }
.po-facet__toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--po-white); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill); padding: 8px 14px; cursor: pointer;
  font-family: inherit; font-size: inherit; color: var(--text-primary);
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.po-facet__toggle:hover { border-color: var(--border-strong); }
.po-facet__count {
  background: var(--po-gradient-red); color: var(--po-white);
  border-radius: var(--radius-pill); font-size: 11px; min-width: 18px;
  height: 18px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.po-facet__panel {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0;
  min-width: 230px; max-height: 320px; overflow-y: auto;
  background: var(--po-white); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 8px;
}
.po-facet__option {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: var(--radius-sm); cursor: pointer; margin: 0;
}
.po-facet__option:hover { background: var(--surface-subtle); }
.po-facet__option input { accent-color: var(--po-red); }
.po-facet__option span:nth-child(2) { flex: 1; }
.po-facet__n { color: var(--text-muted); font-size: var(--fs-caption); }
.po-facet--stock { display: inline-flex; align-items: center; gap: 8px; padding: 8px 6px; cursor: pointer; }
.po-facet--stock input { accent-color: var(--po-red); }
.po-filterbar__clear { margin-left: auto; }

/* ── Autocomplete dropdown ── */
.search-widget form, #search_widget form { position: relative; }
.po-ac {
  position: absolute; z-index: 900; top: calc(100% + 6px); left: 0; right: 0;
  min-width: 320px; max-height: 480px; overflow-y: auto;
  background: var(--po-white); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
}
.po-ac__group {
  font-family: var(--font-support); font-size: var(--fs-caption);
  letter-spacing: var(--ls-caps); text-transform: uppercase;
  color: var(--text-muted); padding: 10px 14px 4px;
}
.po-ac__row {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  text-decoration: none; color: var(--text-primary);
}
.po-ac__row:hover, .po-ac__row.is-active { background: var(--surface-subtle); text-decoration: none; }
.po-ac__row img, .po-ac__noimg {
  width: 42px; height: 42px; object-fit: contain; flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center; color: var(--po-grey-300);
}
.po-ac__text { display: flex; flex-direction: column; min-width: 0; }
.po-ac__title {
  font-family: var(--font-sans); font-weight: var(--fw-medium);
  font-size: var(--fs-body-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.po-ac__sub { font-family: var(--font-support); font-size: var(--fs-caption); color: var(--text-muted); }
.po-ac__all {
  display: block; text-align: center; padding: 10px;
  font-family: var(--font-support); font-size: var(--fs-body-sm);
  color: var(--text-accent); border-top: 1px solid var(--border-subtle);
}
.po-ac__all:hover, .po-ac__all.is-active { background: var(--surface-subtle); }

/* ── Mega menu ── */
.po-megamenu {
  position: relative; font-family: var(--font-sans);
  display: flex; align-items: center; gap: 6px;
}
.po-megamenu__static {
  display: flex; align-items: center; gap: 4px;
  list-style: none; margin: 0; padding: 0;
}
.po-megamenu__static a {
  display: inline-block; padding: 10px 14px;
  color: var(--text-primary); font-weight: var(--fw-medium);
  font-size: var(--fs-body); text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-standard);
}
.po-megamenu__static a:hover { background: var(--surface-subtle); color: var(--text-accent); }
@media (max-width: 768px) { .po-megamenu__static { display: none; } }
.po-megamenu__static-mobile { display: none; }
@media (max-width: 768px) {
  .po-megamenu__static-mobile {
    display: block; list-style: none; margin: 0; padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .po-megamenu__static-mobile a {
    display: block; padding: 11px 18px; color: var(--text-primary);
    font-weight: var(--fw-medium); font-size: var(--fs-body-sm);
    text-decoration: none;
  }
}
.po-megamenu__trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--po-gradient-red); color: var(--po-white); border: 0;
  border-radius: var(--radius-md); padding: 10px 18px; cursor: pointer;
  font-family: inherit; font-weight: var(--fw-medium); font-size: var(--fs-body);
}
.po-megamenu__panel {
  position: absolute; z-index: 500; top: calc(100% + 8px); left: 0;
  display: flex; width: min(960px, 92vw); min-height: 380px;
  background: var(--po-white); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card-hover); overflow: hidden;
}
.po-megamenu__roots {
  flex: 0 0 220px; margin: 0; padding: 10px 0; list-style: none;
  background: var(--surface-subtle); border-right: 1px solid var(--border-subtle);
}
.po-megamenu__root a, .po-megamenu__root span {
  display: block; padding: 11px 18px; color: var(--text-primary);
  font-weight: var(--fw-medium); font-size: var(--fs-body-sm);
  text-decoration: none; cursor: pointer;
}
.po-megamenu__root.is-active a, .po-megamenu__root.is-active span {
  background: var(--po-white); color: var(--text-accent);
  box-shadow: inset 3px 0 0 var(--po-red);
}
.po-megamenu__flyout { flex: 1; position: relative; }
.po-megamenu__sheet {
  display: none; padding: 20px 24px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 20px 24px;
}
.po-megamenu__sheet.is-active { display: grid; }
.po-megamenu__group-title {
  display: block; font-weight: var(--fw-bold); font-size: var(--fs-body-sm);
  color: var(--text-primary); margin-bottom: 8px; text-decoration: none;
}
a.po-megamenu__group-title:hover { color: var(--text-accent); }
.po-megamenu__links { list-style: none; margin: 0; padding: 0; }
.po-megamenu__links a {
  display: block; padding: 4px 0; font-family: var(--font-support);
  font-size: var(--fs-body-sm); color: var(--text-secondary); text-decoration: none;
}
.po-megamenu__links a:hover { color: var(--text-accent); }

/* drawer chrome (title / back / close): mobile only */
.po-megamenu__bar { display: none; }
.po-no-scroll, .po-no-scroll body { overflow: hidden; height: 100%; }

/* filter bar collapse: desktop renders the body inline as if unwrapped */
.po-filterbar__toggle { display: none; }
.po-filterbar__body { display: contents; }

@media (max-width: 768px) {
  /* burger owns the menu; the Products button and the legacy empty
     ps_mainmenu wrapper disappear */
  .po-megamenu__trigger { display: none; }
  #mobile_top_menu_wrapper { display: none !important; }

  /* full-width search row under the top bar */
  #header .header-top-right { display: block; padding: 0 8px 10px; }
  #header #search_widget, #header .search-widget {
    float: none; width: 100%; min-width: 0; padding: 0; margin: 0;
  }
  #header #search_widget form input[type="text"] { width: 100%; }

  /* ── full-screen menu drawer ── */
  .po-megamenu__panel {
    position: fixed; inset: 0; width: 100%; min-height: 0; border: 0;
    border-radius: 0; box-shadow: none; z-index: 1000;
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--po-white);
  }
  .po-megamenu__bar {
    display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
    padding: 12px 14px; border-bottom: 1px solid var(--border-subtle);
  }
  .po-megamenu__bar-title {
    flex: 1; text-align: center; font-weight: var(--fw-bold);
    font-size: var(--fs-body); color: var(--text-primary);
  }
  .po-megamenu__back, .po-megamenu__close {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: 0; padding: 8px; cursor: pointer;
    color: var(--text-primary); font-family: var(--font-support);
    font-size: var(--fs-body-sm);
  }
  .po-megamenu__back { visibility: hidden; } /* shown on the sub-screen */
  .po-megamenu__panel.is-sub .po-megamenu__back { visibility: visible; }

  /* screen 1: category list + static links */
  .po-megamenu__roots {
    flex: 1 1 auto; overflow-y: auto; border-right: 0;
    background: var(--po-white); padding: 6px 0 0;
  }
  .po-megamenu__root a, .po-megamenu__root span {
    padding: 15px 18px; font-size: var(--fs-body);
    border-bottom: 1px solid var(--po-grey-100);
    position: relative;
  }
  .po-megamenu__root a::after, .po-megamenu__root span::after {
    content: '›'; position: absolute; right: 18px;
    color: var(--text-muted); font-size: 20px; line-height: 1;
  }
  .po-megamenu__root.is-active a, .po-megamenu__root.is-active span {
    box-shadow: none; background: var(--po-white); color: var(--text-primary);
  }
  .po-megamenu__static-mobile { flex: 0 0 auto; border-top: 1px solid var(--border-subtle); border-bottom: 0; }
  .po-megamenu__flyout { display: none; }

  /* screen 2: the selected category */
  .po-megamenu__panel.is-sub .po-megamenu__roots,
  .po-megamenu__panel.is-sub .po-megamenu__static-mobile { display: none; }
  .po-megamenu__panel.is-sub .po-megamenu__flyout {
    display: block; flex: 1 1 auto; overflow-y: auto;
  }
  .po-megamenu__sheet.is-active { display: block; padding: 14px 18px; }
  .po-megamenu__group { margin-bottom: 18px; }
  .po-megamenu__group-title { font-size: var(--fs-body); margin-bottom: 6px; }
  .po-megamenu__links a { padding: 8px 0; font-size: var(--fs-body); }

  /* ── collapsible filter bar ── */
  .po-filterbar { position: static; flex-wrap: wrap; padding: 10px; }
  .po-filterbar__search { flex: 1 1 auto; min-width: 0; }
  .po-filterbar__toggle {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
    background: var(--po-white); border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill); padding: 8px 14px; cursor: pointer;
    font-family: var(--font-support); font-size: var(--fs-body-sm);
    color: var(--text-primary);
  }
  .po-filterbar__body {
    display: none; width: 100%;
    flex-wrap: wrap; gap: 8px; padding-top: 10px;
  }
  .po-filterbar__body.is-open { display: flex; }
  /* facet options expand inline (accordion) instead of floating popovers */
  .po-facet { width: 100%; }
  .po-facet__toggle { width: 100%; justify-content: space-between; border-radius: var(--radius-md); }
  .po-facet__panel { position: static; min-width: 0; width: 100%; max-height: 260px; box-shadow: none; margin-top: 4px; }
  .po-facet--stock { width: 100%; }
  .po-filterbar__clear { margin-left: 0; }
}

/* ── SEO sections ── */
.po-seo-sections { margin: 40px 0; }
.po-seo-section { margin-bottom: 28px; }
.po-seo-section__title {
  font-family: var(--font-sans); font-weight: var(--fw-bold);
  font-size: var(--fs-h4); margin-bottom: 10px;
}
.po-seo-section__body {
  font-family: var(--font-support); font-size: var(--fs-body);
  color: var(--text-secondary); line-height: var(--lh-body); max-width: 820px;
}

/* ── Buttons used here that the theme may not define ── */
.po-btn--secondary {
  background: var(--po-white); border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.po-btn--ghost { background: transparent; border: 0; color: var(--text-accent); cursor: pointer; }
