/**
 * PeptixHouse — búsqueda global de productos (estilos aislados .ph-*)
 * No modifica el layout del header: solo el botón añadido usa clases existentes + .ph-search-trigger
 */

/* ---------- Trigger (compacto, alineado con .icon-btn del sitio) ---------- */
button.icon-btn.ph-search-trigger {
  flex-shrink: 0;
  cursor: pointer;
  font: inherit;
  margin: 0;
}

/* ---------- Capa raíz (portal) ---------- */
#ph-search-root {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
}

#ph-search-root.ph-search--open {
  pointer-events: auto;
}

/* ---------- Desktop: panel bajo el header ---------- */
.ph-search__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 18, 0.35);
  z-index: 10049;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ph-search--desktop.ph-search--open .ph-search__backdrop {
  display: block;
  opacity: 1;
}

.ph-search__panel {
  display: none;
  position: fixed;
  left: 50%;
  transform: translate(-50%, -8px);
  width: min(720px, calc(100vw - 24px));
  max-height: min(82vh, 640px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 10051;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.22s ease;
}

.ph-search--desktop.ph-search--open .ph-search__panel {
  display: flex;
  opacity: 1;
  transform: translate(-50%, 0);
}

.ph-search__panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(180deg, #fafcfb 0%, #fff 100%);
}

.ph-search__input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ph-search__input:focus {
  border-color: #4dbfb6;
  box-shadow: 0 0 0 3px rgba(77, 191, 182, 0.22);
}

.ph-search__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: #2a3331;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.ph-search__close:hover {
  background: rgba(0, 0, 0, 0.09);
}

.ph-search__list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: min(62vh, 520px);
  padding: 6px 0 10px;
}

.ph-search__catalog {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 12px 10px 16px;
}

.ph-search__col {
  width: 100%;
  min-width: 0;
}

.ph-search__col-title {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5f726d;
}

.ph-search__col-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ph-search__hint {
  padding: 10px 14px 6px;
  font-size: 12px;
  color: #5a6a66;
}

.ph-search__empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 14px;
  color: #4a5552;
  line-height: 1.45;
}

.ph-search__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  margin: 0;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}

.ph-search__item:hover,
.ph-search__item:focus-visible {
  background: rgba(77, 191, 182, 0.12);
  outline: none;
}

.ph-search__item img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: #f4f8f7;
  flex-shrink: 0;
}

.product-variant-links {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #5a6a66;
}

.product-variant-links a {
  color: var(--primary-teal, #4dbfb6);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.product-variant-links a:hover {
  color: var(--primary-teal-dark, #3a948d);
}

.ph-search__meta {
  min-width: 0;
  flex: 1;
}

.ph-search__name {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  color: #1d2422;
}

.ph-search__sub {
  font-size: 12px;
  color: #5f726d;
  margin-top: 2px;
}

/* ---------- Móvil: overlay pantalla completa ---------- */
.ph-search__overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10052;
  background: #f6faf9;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.ph-search--mobile.ph-search--open .ph-search__overlay {
  display: flex;
  opacity: 1;
}

.ph-search__overlay-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(37, 42, 42, 0.95);
  border-bottom: 2px solid #94e1d4;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.ph-search__overlay-top .ph-search__input {
  background: #fff;
}

.ph-search__overlay-top .ph-search__close {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.ph-search__overlay-top .ph-search__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ph-search__overlay-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 max(12px, env(safe-area-inset-bottom));
}

.ph-search--mobile .ph-search__item {
  margin: 0 10px;
  padding: 12px;
}

.ph-search--mobile .ph-search__item img {
  width: 52px;
  height: 52px;
}

@media (min-width: 768px) {
  .ph-search--mobile .ph-search__overlay {
    display: none !important;
  }
}

@media (max-width: 767.98px) {
  .ph-search--desktop .ph-search__panel,
  .ph-search--desktop .ph-search__backdrop {
    display: none !important;
  }

  .ph-search--mobile .ph-search__item {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ph-search__backdrop,
  .ph-search__panel,
  .ph-search__overlay,
  .ph-search__item {
    transition: none;
  }
}

/* Layout header móvil en fichas de producto (.site-header): ver bloque dedicado en styles.css */
