/**
 * Mundo Steam — Header search & categories
 * ------------------------------------------
 * Desktop  : inline search pill that expands over the categories row
 * Mobile   : slide-down full-width search overlay triggered from the header icon
 *
 * Depends on header.php adding `.ms-host` to `.main-nav` and `.ms-mobile-search`
 * to the document body.
 */

/* =====================================================
   HOST PILL — categories container (DESKTOP ONLY)
   Below 992px the offcanvas shows the same .main-nav.ms-host in a column
   drawer — the pill styling would look wrong there. Scope to desktop.
   ===================================================== */
@media (min-width: 992px) {
  .offcanvas-body .main-nav.ms-host {
    padding: 6px 6px 6px 16px !important;
    background: rgba(22, 31, 46, 0.9) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(148, 184, 255, 0.12) !important;
    border-radius: 9999px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
  }

  .offcanvas-body .ms-host #bootscore-navbar {
    margin: 0 !important;
    padding-right: 58px !important; /* reserve space for the circular end-cap */
    transition: opacity 0.3s ease !important;
  }

  .offcanvas-body .ms-host.is-searching #bootscore-navbar {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Keep the pill vertically centered when the sticky header shrinks on scroll */
  .site-header.to-fixed .main-nav.ms-host {
    top: 50% !important;
    transform: translateY(-50%) !important;
  }
}

/* =====================================================
   SEARCH OVERLAY (desktop pill)
   Anchored to the right, grows leftward by animating width only
   ===================================================== */
.ms-search-pill {
  --ms-accent: #22d3ee;
  --ms-accent-2: #0284c7;

  /* Collapsed: circular cyan end-cap flush inside the bar's right edge —
     reads as part of the bar, the "last cell" before the close. */
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  width: 46px;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ms-accent) 0%, var(--ms-accent-2) 100%);
  border: 0;
  border-radius: 9999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition:
    width 0.55s cubic-bezier(0.22, 0.8, 0.3, 1),
    background 0.35s ease,
    box-shadow 0.35s ease;
  z-index: 3;
  cursor: pointer;
}

.ms-search-pill:hover {
  background: linear-gradient(135deg, #67e8f9 0%, #0ea5e9 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 14px rgba(34, 211, 238, 0.35);
}

.ms-host.is-searching .ms-search-pill {
  /* Expanded: rectangle pill filling the bar.
     Using a solid color (instead of a 135° gradient between two very close
     dark-blue tones) avoids Firefox's gradient banding, which made the right
     half of the bar look like a slightly different color than the left. */
  width: calc(100% - 12px);
  background: rgba(10, 16, 28, 0.98);
  background-image: none;
  border: 1px solid rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12), 0 8px 30px rgba(0, 0, 0, 0.5);
  cursor: default;
}

/* Trigger (magnifying glass shown when collapsed). White icon on the cyan
   gradient for maximum contrast — reads immediately as a search button. */
.ms-search-trigger {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 1;
  transition: opacity 0.25s ease, color 0.25s ease;
  z-index: 2;
}

.ms-search-trigger i {
  font-size: 20px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ms-host.is-searching .ms-search-trigger {
  opacity: 0;
  pointer-events: none;
}

/* Expanded fields (input + link + close) */
/* 25/09/2026: top/right/bottom/left antes de inset. inset solo existe desde Safari 14.1 (iOS 14.5) y
   Chrome 87; sin el respaldo, en esos navegadores el buscador de la compu se abria chico y desalineado
   (el campo media 195x19 en vez de 417x48). En los de hoy manda el inset de abajo: mismo resultado. */
.ms-search-fields {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px 0 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease 0.15s;
}

.ms-host.is-searching .ms-search-fields {
  opacity: 1;
  pointer-events: auto;
}

.ms-field-icon {
  flex: 0 0 auto;
  color: var(--ms-accent);
  font-size: 15px;
  margin-right: 6px;
}

/* FiboSearch host (replaces the plain <input>) — flex-grow to fill the pill */
.ms-search-fields .ms-search-fibo {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
}

.ms-search-fields .ms-search-fibo .dgwt-wcas-search-wrapp {
  display: flex !important;
  align-items: center !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Hide FiboSearch's own icon trigger and submit button inside the pill —
   the ms-search-trigger / ms-search-close buttons handle the UI instead. */
.ms-search-fields .ms-search-fibo .dgwt-wcas-search-icon,
.ms-search-fields .ms-search-fibo .dgwt-wcas-search-submit,
.ms-search-fields .ms-search-fibo .dgwt-wcas-voice-search,
.ms-search-fields .ms-search-fibo .dgwt-wcas-preloader {
  display: none !important;
}

/* FiboSearch is configured in "icon flyout" mode — its <form> is display:none
   + position:absolute + min-width:500px + opacity:0 by default. Force it into
   an inline always-open layout so it fits our pill and stretches to full height. */
.ms-search-fields .ms-search-fibo .dgwt-wcas-search-form {
  display: flex !important;
  align-items: center !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.ms-search-fields .ms-search-fibo .dgwt-wcas-sf-wrapp {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Input (aggressive reset — theme + FiboSearch both force styles) */
.ms-search-fields .ms-search-fibo input.dgwt-wcas-search-input,
.ms-search-fields .ms-search-fibo input[type="search"].dgwt-wcas-search-input {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  color: #f8fafc !important;
  font-size: 0.98rem !important;
  padding: 0 8px !important;
  margin: 0 !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
}

/* 25/09/2026: en pantallas tactiles (iPad apaisado, donde se ve esta pildora) el campo va a 16 px:
   con .98rem (15,68 px) Safari agranda la pagina al tocarlo. FiboSearch ya ponia 16 px en iOS, pero
   el .98rem !important de arriba se lo pisaba. En la compu (mouse) queda como estaba. */
@media (hover: none) and (pointer: coarse) {
  .ms-search-fields .ms-search-fibo input.dgwt-wcas-search-input,
  .ms-search-fields .ms-search-fibo input[type="search"].dgwt-wcas-search-input {
    font-size: 16px !important;
  }
}

.ms-search-fields .ms-search-fibo input.dgwt-wcas-search-input::placeholder {
  color: rgba(248, 250, 252, 0.5) !important;
}

.ms-search-fields .ms-search-fibo input.dgwt-wcas-search-input::-webkit-search-cancel-button,
.ms-search-fields .ms-search-fibo input.dgwt-wcas-search-input::-webkit-search-decoration {
  -webkit-appearance: none !important;
  display: none !important;
}

/* "Búsqueda avanzada" link */
.ms-search-advanced {
  flex: 0 0 auto;
  color: rgba(248, 250, 252, 0.72);
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.ms-search-advanced:hover {
  color: var(--ms-accent);
  background: rgba(34, 211, 238, 0.08);
}

/* Close (X) button */
.ms-search-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(248, 250, 252, 0.25);
  border-radius: 50%;
  background: transparent;
  color: rgba(248, 250, 252, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  z-index: 3;
}

.ms-search-close:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(34, 211, 238, 0.6);
  color: var(--ms-accent);
  transform: scale(1.05);
}

.ms-search-close i {
  font-size: 14px;
  pointer-events: none; /* ensure clicks land on the button, not the icon */
}

/* =====================================================
   DESKTOP-ONLY (≥ 992px)
   Hide original FiboSearch toggler, enlarge user/cart buttons
   ===================================================== */
@media (min-width: 992px) {
  .header-actions .cont-search-toggler { display: none !important; }

  /* Shared button chrome (borders, hover, colors) */
  .header-actions .account-toggler,
  .header-actions .cart-toggler {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 14px !important;
    border: 1.5px solid rgba(148, 184, 255, 0.14) !important;
    background: rgba(148, 184, 255, 0.04) !important;
    color: #f8fafc !important;
    transition: background 0.2s, border-color 0.2s, transform 0.15s !important;
    min-height: 48px !important;
  }

  /* User: square 48x48 (icon only) */
  .header-actions .account-toggler {
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
  }

  /* Cart: auto width so it fits icon + cart total (e.g. "$ 13.200,00") inside the border */
  .header-actions .cart-toggler {
    height: 48px !important;
    padding: 0 14px !important;
    gap: 6px !important;
  }
  .header-actions .cart-toggler .cart-content {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .header-actions .cart-toggler .cart-total {
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    color: rgba(248, 250, 252, 0.9) !important;
    white-space: nowrap !important;
  }

  /* Hover (both) */
  .header-actions .account-toggler:hover,
  .header-actions .cart-toggler:hover {
    background: rgba(34, 211, 238, 0.12) !important;
    border-color: rgba(34, 211, 238, 0.45) !important;
    transform: translateY(-1px) !important;
  }

  /* Icons */
  .header-actions .account-toggler i,
  .header-actions .cart-toggler > i,
  .header-actions .cart-toggler .d-inline-flex > i {
    font-size: 19px !important;
  }

  .header-actions > * + * { margin-left: 10px !important; }
}

/* =====================================================
   MOBILE (< 992px)
   - Desktop pill hidden
   - Categories row centered + horizontal scroll fallback
   - Force Microsoft/Xbox icons visible (theme hides them)
   ===================================================== */
@media (max-width: 991.98px) {
  .ms-search-pill { display: none !important; }

  /* Show Microsoft in the mobile categories row (theme hides it) */
  .menu-mobile #bootscore-navbar-m li.fa-windows { display: list-item !important; }

  /* Icons for Microsoft/Xbox are display:none in the theme — force visible */
  .menu-mobile #bootscore-navbar-m li.fa-windows > a > i,
  .menu-mobile #bootscore-navbar-m li.fa-xbox > a > i {
    display: inline-block !important;
    margin-right: 6px !important;
  }
  .menu-mobile #bootscore-navbar-m > li > a > i { vertical-align: middle !important; }

  /* Center the categories row; fall back to horizontal scroll if it overflows */
  .menu-mobile {
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
  }
  .menu-mobile #bootscore-navbar-m {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    justify-content: center !important;
    margin: 0 auto !important;
    padding: 4px 12px !important;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .menu-mobile #bootscore-navbar-m::-webkit-scrollbar { display: none !important; }
  .menu-mobile #bootscore-navbar-m > li { flex: 0 0 auto !important; }
}

/* =====================================================
   MOBILE SEARCH OVERLAY (slides down from the top)
   ===================================================== */
.ms-mobile-search {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  transform: translateY(-100%);
  background: rgba(8, 12, 22, 0.97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(34, 211, 238, 0.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.35s cubic-bezier(0.22, 0.8, 0.3, 1);
  padding: 12px 14px;
}

.ms-mobile-search.is-open { transform: translateY(0); }

.ms-mobile-search-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ms-mobile-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.ms-mobile-close:active { background: rgba(255, 255, 255, 0.08); }
.ms-mobile-close i { font-size: 17px; }

/* FiboSearch inside the mobile overlay — visually matches the old .ms-mobile-form pill */
.ms-mobile-fibo {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  background: rgba(148, 184, 255, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  padding: 4px 4px 4px 14px;
  margin: 0;
  min-width: 0;
}

.ms-mobile-fibo .dgwt-wcas-search-wrapp {
  display: flex !important;
  align-items: center !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
}

/* Hide FiboSearch icon/submit — the overlay has its own close button + an accent dot */
.ms-mobile-fibo .dgwt-wcas-search-icon,
.ms-mobile-fibo .dgwt-wcas-search-submit,
.ms-mobile-fibo .dgwt-wcas-voice-search,
.ms-mobile-fibo .dgwt-wcas-preloader {
  display: none !important;
}

.ms-mobile-fibo .dgwt-wcas-search-form {
  display: flex !important;
  align-items: center !important;
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.ms-mobile-fibo .dgwt-wcas-sf-wrapp {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.ms-mobile-fibo input.dgwt-wcas-search-input,
.ms-mobile-fibo input[type="search"].dgwt-wcas-search-input {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: 100% !important;
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  color: #f8fafc !important;
  font-size: 1rem !important;
  padding: 10px 4px !important;
  margin: 0 !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
}

.ms-mobile-fibo input.dgwt-wcas-search-input::placeholder {
  color: rgba(248, 250, 252, 0.5) !important;
}

.ms-mobile-fibo input.dgwt-wcas-search-input::-webkit-search-cancel-button,
.ms-mobile-fibo input.dgwt-wcas-search-input::-webkit-search-decoration {
  -webkit-appearance: none !important;
  display: none !important;
}

/* FiboSearch autocomplete dropdown (portaled to body) — ensure it sits above the overlay/header */
.dgwt-wcas-suggestions-wrapp,
.dgwt-wcas-details-wrapp {
  z-index: 2100 !important;
}

/* Mobile overlay is only for mobile */
@media (min-width: 992px) { .ms-mobile-search { display: none !important; } }

/* =====================================================
   MENU CENTRADO EN LA PAGINA (24/09/2026)
   El logo y los botones de la derecha no miden lo mismo, asi que el menu del medio quedaba centrado
   entre ellos y no en la pagina (19 px corrido en la home, 43 px en el checkout, donde a la derecha
   hay un solo boton). Se nota con contenido angosto y centrado (paso 2 del checkout). Los dos
   costados pasan a medir lo mismo (flex 1 1 0) y el menu queda al centro. Desde 1200 px: por debajo
   no entra el menu centrado sin pisar el logo, y queda como antes. Medido 1200-2000 px arriba,
   scrolleado y con el buscador abierto: desvio 0 y todos los clics responden.
   ===================================================== */
@media (min-width: 1200px) {
  #nav-main > .container-fluid > .site-branding,
  #nav-main > .container-fluid > .header-actions { flex: 1 1 0; min-width: max-content; }
  #nav-main > .container-fluid > .site-branding { margin-right: 0 !important; }
  #nav-main > .container-fluid > .header-actions { justify-content: flex-end; }
  #nav-main > .container-fluid > #offcanvas-navbar { flex: 0 1 auto; }
}
