/**
 * Estilos para el Buscador Emergente (Lupa Popup) - O2 Promo Store
 * Diseño de Alta Fidelidad en Terracotas
 */

#o2SearchPopupOverlay,
.o2-search-trigger,
.o2-embedded-search {
  --primary-color: #8B6347;
  --primary-light: #EDE4DC;
  --text-dark: #3E2723;
  --text-muted: #8E7A75;
  --bg-modal: #FAF7F5;
  --border-color: #E6DDD8;
}

/* 1. Botón del Trigger (Lupa) */
.o2-search-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 2px 8px rgba(139, 99, 71, 0.08);
}

.o2-search-trigger:hover {
  background: var(--primary-color);
  color: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 99, 71, 0.2);
}

.o2-search-trigger.o2-floating-search { position: fixed; z-index: 9998; bottom: 24px; left: 24px; width: 54px; height: 54px; border: 1px solid rgba(255,255,255,.85); background: #ea7c5b; color: #fff; box-shadow: 0 8px 24px rgba(234,124,91,.35); }
.o2-search-trigger.o2-floating-search:hover { background: #d96849; color: #fff; transform: translateY(-3px) scale(1.04); }
@media (max-width: 560px) { .o2-search-trigger.o2-floating-search { bottom: 18px; left: 18px; width: 50px; height: 50px; } }

/* 2. Capa de Fondo (Overlay) */
.o2-search-popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(62, 39, 35, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999999;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.o2-search-popup-overlay.open {
  display: flex;
  opacity: 1;
}

/* 3. Contenedor de la Modal */
.o2-search-popup-content {
  background: var(--bg-modal);
  width: 90%;
  max-width: 680px;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 1.75rem;
  transform: translateY(-20px);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.o2-search-popup-overlay.open .o2-search-popup-content {
  transform: translateY(0);
}

/* 4. Cabecera */
.o2-search-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.o2-search-popup-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
}

.o2-search-popup-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.o2-search-popup-close:hover {
  color: var(--primary-color);
}

/* 5. Input de Búsqueda */
.o2-search-popup-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #FFFFFF;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.o2-search-popup-input-wrap:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 99, 71, 0.15);
}

.o2-search-popup-icon {
  color: var(--primary-color);
  display: flex;
  align-items: center;
  margin-right: 0.75rem;
}

.o2-search-popup-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1.1rem;
  color: var(--text-dark);
  padding: 0.5rem 0;
  width: 100%;
}

.o2-search-popup-clear {
  background: var(--primary-light);
  color: var(--primary-color);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.o2-search-popup-clear:hover {
  background: var(--primary-color);
  color: #FFFFFF;
}

/* 6. Resultados y Autocompletado */
.o2-search-popup-results {
  margin-top: 1.25rem;
  max-height: 380px;
  overflow-y: auto;
}

.o2-search-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border: 1px solid transparent;
}

.o2-search-item:hover {
  background: #FFFFFF;
  border-color: var(--border-color);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(139, 99, 71, 0.05);
}

.o2-search-item-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
}

.o2-search-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.o2-search-item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.3;
}

.o2-search-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
}

.o2-search-item-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-color);
}

.o2-search-store-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .5rem;
  padding: .85rem 1rem;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}

.o2-search-store-link:hover { background: var(--primary-color); color: #fff; }

/* Scrollbar Personalizado */
.o2-search-popup-results::-webkit-scrollbar {
  width: 6px;
}
.o2-search-popup-results::-webkit-scrollbar-track {
  background: transparent;
}
.o2-search-popup-results::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.o2-search-popup-results::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Reusable embedded search, scoped so page builders cannot change other forms. */
.o2-embedded-search { max-width: 860px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem); border: 1px solid #e6ddd8; border-radius: 20px; background: #faf7f5; box-shadow: 0 12px 34px rgba(62,39,35,.08); }
.o2-embedded-search-copy { margin-bottom: 1.25rem; }
.o2-embedded-search-copy h2 { margin: 0; color: #3e2723; font-family: 'Cormorant Garamond', Georgia, serif; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.1; }
.o2-embedded-search-copy p { margin: .5rem 0 0; color: #8e7a75; }
.o2-embedded-search-form { display: flex; align-items: center; gap: .75rem; padding: .5rem .5rem .5rem 1rem; border: 1.5px solid #e6ddd8; border-radius: 999px; background: #fff; }
.o2-embedded-search-form:focus-within { border-color: #8b6347; box-shadow: 0 0 0 4px rgba(139,99,71,.12); }
.o2-embedded-search-icon { flex: 0 0 auto; color: #8b6347; }
.o2-embedded-search-input { flex: 1; min-width: 0; border: 0 !important; outline: 0; box-shadow: none !important; background: transparent !important; color: #3e2723; font-size: 1rem; }
.o2-embedded-search-submit { flex: 0 0 auto; min-height: 42px; padding: 0 1.2rem; border: 0; border-radius: 999px; background: #8b6347; color: #fff; font-weight: 700; cursor: pointer; }
.o2-embedded-search-results { display: grid; gap: .5rem; margin-top: .75rem; }
.o2-embedded-search-item { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #3e2723; text-align: left; cursor: pointer; }
.o2-embedded-search-item:hover { border-color: #e6ddd8; background: #fff; }
.o2-embedded-search-item img { width: 48px; height: 48px; border: 1px solid #e6ddd8; border-radius: 8px; object-fit: contain; background: #fff; }
.o2-embedded-search-item span { display: grid; flex: 1; min-width: 0; gap: .2rem; }
.o2-embedded-search-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o2-embedded-search-item small, .o2-embedded-search-status { color: #8e7a75; }
.o2-embedded-search-item b { color: #8b6347; font-size: .8rem; }
@media (max-width: 560px) { .o2-embedded-search-form { flex-wrap: wrap; border-radius: 16px; } .o2-embedded-search-input { min-height: 42px; } .o2-embedded-search-submit { width: 100%; } }

/* Protect the reusable homepage search from Elementor button defaults. */
.o2-embedded-search .o2-embedded-search-form { border-color: #f0c6b8 !important; }
.o2-embedded-search .o2-embedded-search-form:focus-within { border-color: #ea7c5b !important; box-shadow: 0 0 0 4px rgba(234,124,91,.14) !important; }
.o2-embedded-search .o2-embedded-search-icon,
.o2-embedded-search .o2-embedded-search-item b { color: #ea7c5b !important; }
.o2-embedded-search .o2-embedded-search-submit { border-radius: 999px !important; background: #ea7c5b !important; color: #fff !important; }
.o2-embedded-search .o2-embedded-search-submit:hover { background: #d96849 !important; }
.o2-embedded-search .o2-embedded-search-item { display: flex !important; align-items: center !important; justify-content: flex-start !important; min-height: 68px !important; margin: 0 !important; padding: .6rem .75rem !important; border: 1px solid transparent !important; border-radius: 12px !important; box-shadow: none !important; font: inherit !important; line-height: 1.2 !important; transform: none !important; }
.o2-embedded-search .o2-embedded-search-item:hover { border-color: #f0c6b8 !important; background: #fff !important; transform: none !important; }
.o2-embedded-search .o2-embedded-search-item span { justify-content: center; }
.o2-embedded-search .o2-embedded-search-item strong { color: #3e2723 !important; }

/* Overlay mode keeps the homepage flow intact; results float over nearby content. */
.o2-embedded-search-control { position: relative; }
.elementor-element:has(.o2-embedded-search--overlay) { position: relative; }
.o2-embedded-search--overlay { position: absolute; z-index: 40; bottom: -36px; left: 50%; width: min(860px, calc(100vw - 32px)); margin: 0; padding: 0; transform: translateX(-50%); border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.o2-embedded-search .o2-embedded-search-results { position: absolute; z-index: 2; top: calc(100% + .75rem); right: 0; left: 0; display: grid; gap: .5rem; max-height: min(460px, 55vh); margin: 0; padding: .5rem; overflow-y: auto; border: 1px solid #f0c6b8; border-radius: 16px; background: #fffdfa; box-shadow: 0 16px 32px rgba(62,39,35,.14); }
.o2-embedded-search .o2-embedded-search-results:empty { display: none; }
.o2-embedded-search .o2-embedded-search-item { display: grid !important; grid-template-columns: 48px minmax(0, 1fr) auto !important; grid-auto-flow: row !important; align-items: center !important; justify-content: stretch !important; column-gap: .75rem; width: 100%; }
.o2-embedded-search .o2-embedded-search-item img { grid-column: 1 !important; }
.o2-embedded-search .o2-embedded-search-item span { grid-column: 2 !important; width: auto !important; margin: 0 !important; text-align: left !important; }
.o2-embedded-search .o2-embedded-search-item b { grid-column: 3 !important; justify-self: end !important; }

@media (max-width: 560px) {
  .o2-embedded-search--overlay { bottom: -28px; width: calc(100vw - 24px); }
  .o2-embedded-search .o2-embedded-search-results { max-height: 48vh; }
}

/* Floating search is a compact, isolated popover so Elementor cannot restyle it. */
.o2-search-trigger.o2-floating-search {
  appearance: none !important;
  display: inline-flex !important;
  gap: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  width: 54px !important;
  min-width: 54px !important;
  height: 54px !important;
  min-height: 54px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, .88) !important;
  border-radius: 999px !important;
  outline: 0 !important;
  background: #ea7c5b !important;
  box-shadow: 0 10px 26px rgba(85, 43, 29, .24) !important;
  color: #fff !important;
  font: 700 14px/1 DM Sans, sans-serif !important;
  text-align: left !important;
  transition: width .28s ease, padding .28s ease, transform .2s ease, background .2s ease !important;
}

.o2-search-trigger.o2-floating-search svg { flex: 0 0 auto; }
.o2-search-trigger-label { display: inline-block; width: 0; overflow: hidden; white-space: nowrap; opacity: 0; transition: opacity .18s ease; }
.o2-search-trigger.o2-floating-search.o2-search-trigger--invite,
.o2-search-trigger.o2-floating-search:hover,
.o2-search-trigger.o2-floating-search:focus-visible {
  width: 194px !important;
  padding: 0 18px !important;
  gap: 10px !important;
  background: #d96849 !important;
  transform: translateY(-3px) !important;
}

.o2-search-trigger.o2-floating-search.o2-search-trigger--invite .o2-search-trigger-label,
.o2-search-trigger.o2-floating-search:hover .o2-search-trigger-label,
.o2-search-trigger.o2-floating-search:focus-visible .o2-search-trigger-label { width: auto; opacity: 1; }

#o2SearchPopupOverlay[data-floating="yes"] {
  position: fixed !important;
  inset: auto auto 90px 24px !important;
  display: block !important;
  width: min(420px, calc(100vw - 32px)) !important;
  height: auto !important;
  padding: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(.98);
  transition: opacity .18s ease, transform .18s ease !important;
}

#o2SearchPopupOverlay[data-floating="yes"].open { pointer-events: auto; opacity: 1; transform: translateY(0) scale(1); }
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-content {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 18px !important;
  border: 1px solid #eaded5 !important;
  border-radius: 16px !important;
  background: #fffdfa !important;
  box-shadow: 0 18px 44px rgba(51, 30, 23, .2) !important;
  transform: none !important;
}

#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-header { margin-bottom: 12px !important; }
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-title { font: 700 18px/1.2 DM Sans, sans-serif !important; }
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-close,
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-clear {
  appearance: none !important;
  min-width: 32px !important;
  width: 32px !important;
  height: 32px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #f3e9e3 !important;
  box-shadow: none !important;
  color: #8b6347 !important;
  font: 20px/1 Arial, sans-serif !important;
}

#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-input-wrap {
  gap: 10px !important;
  padding: 0 12px !important;
  border: 1px solid #d9c6bb !important;
  border-radius: 10px !important;
  background: #fff !important;
  box-shadow: none !important;
}

#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-input {
  min-width: 0 !important;
  min-height: 46px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  font: 400 16px/1.2 DM Sans, sans-serif !important;
}

#o2SearchPopupOverlay[data-floating="yes"] .o2-search-popup-results { max-height: min(340px, 45vh); margin-top: 10px !important; }
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-item { padding: 9px 6px !important; border-radius: 8px !important; }
#o2SearchPopupOverlay[data-floating="yes"] .o2-search-item:hover { transform: none !important; box-shadow: none !important; }

@media (max-width: 560px) {
  .o2-search-trigger.o2-floating-search { bottom: 16px !important; left: 16px !important; }
  #o2SearchPopupOverlay[data-floating="yes"] { right: 12px !important; bottom: 78px !important; left: 12px !important; width: auto !important; }
  .o2-search-trigger.o2-floating-search.o2-search-trigger--invite,
  .o2-search-trigger.o2-floating-search:hover,
  .o2-search-trigger.o2-floating-search:focus-visible { width: 174px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .o2-search-trigger.o2-floating-search,
  #o2SearchPopupOverlay[data-floating="yes"] { transition: none !important; }
}

/* Search result details must always start at the left edge. */
.o2-embedded-search .o2-embedded-search-item { justify-content: flex-start !important; text-align: left !important; }
.o2-embedded-search .o2-embedded-search-item img { justify-self: start !important; }
.o2-embedded-search .o2-embedded-search-item span { align-content: start !important; justify-content: start !important; justify-self: stretch !important; text-align: left !important; }
.o2-embedded-search .o2-embedded-search-item strong,
.o2-embedded-search .o2-embedded-search-item small { justify-self: start !important; text-align: left !important; }
