/* Mobile full-width overlay for Header Builder "Search" when display=form */
@media (max-width: 1024px) {
  /* Ensure the search occupies the whole header width and overlays other tools */
  .wd-header-search-form-mobile.wd-display-form {
    position: relative;
  }

  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active {
    position: fixed; /* take out of header flow */
    top: 0;
    left: 0;
    right: 0;
    z-index: 500; /* above header rows and tools */
    padding: 0; /* no spacing around the form */
    background: var(--bgcolor-white, #fff);
  }

  /* Remove inline padding applied by parent theme for header search forms */
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active[class*="wd-header-search-form"] {
    padding-inline: 0 !important;
  }

  /* Stretch the form to full width */
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .searchform {
    max-width: none;
    width: 100% !important;
    position: relative;
    margin: 0; /* flush */
    padding: 0; /* sin padding */
    background: var(--bgcolor-white, #fff); /* mismo fondo que el overlay */
    height: 40px; /* altura máxima del overlay */
  }

  /* Increase touch target and visual prominence on mobile overlay */
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .searchform input[type="text"] {
    min-width: 100%;
    padding-inline-start: 36px; /* room for back icon */
    padding-inline-end: 50px; /* espacio para el botón de búsqueda */
    margin: 0;
    border-radius: 0; /* square edges flush to screen */
    height: 40px; /* altura reducida del campo */
    border-top: 0; /* sin borde superior */
    border-left: 0; /* sin borde izquierdo */
    border-right: 0; /* sin borde derecho */
    font-size: 14px; /* tamaño de fuente proporcional */
  }

  /* Back/close icon button */
  .wd-header-search-form-mobile.wd-display-form .wd-mobile-search-back {
    --wd-action-icon-size: 18px;
    position: absolute;
    top: 50%;
    inset-inline-start: 8px; /* hugs the edge */
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--wd-form-color, currentColor);
    opacity: .9;
    z-index: 1;
  }

  .wd-header-search-form-mobile.wd-display-form .wd-mobile-search-back .wd-icon-svg {
    display: block;
    width: var(--wd-action-icon-size);
    height: var(--wd-action-icon-size);
  }

  /* Botón de búsqueda (lupa) - moverlo hacia la izquierda */
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .searchform .searchsubmit,
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .searchform button[type="submit"] {
    right: 15px !important; /* mover hacia la izquierda */
    inset-inline-end: 15px !important;
  }

  /* Dim page content slightly when overlay is open */
  body.wd-mobile-search-overlay-open .website-wrapper,
  body.wd-mobile-search-overlay-open .page-wrapper {
    filter: brightness(0.98);
  }

  /* Keep dropdown results and any extra content flush within the overlay */
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .wd-search-results-wrapper,
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .wd-dropdown-results,
  .wd-header-search-form-mobile.wd-display-form.wd-overlay-active .wd-scroll-content {
    margin: 0 !important;
    inset: auto; /* rely on default positioning within overlay */
  }
}
