/**
 * Mercado Mayor / Bazarial — catalogue toolbar
 * ---------------------------------------------------------------------------
 * The search / category / sort bar above the product grid on the shop and
 * category pages, and the two empty states it can lead to. Printed by
 * inc/catalog-toolbar.php; js/mm-catalog-toolbar.js applies the drop-downs on
 * change.
 *
 * versioneco.com's layout: a wide search field, then two drop-downs of equal
 * weight, all the same height and radius, each with its icon; the result
 * count and "Quitar filtros" on a line of their own underneath.
 *
 * The controls are reached through three classes: b2b-marketplace.css §6
 * styles every input and select through `body:not(.woocommerce-account) …`,
 * (0,2,2), and the Customizer's typography layer puts its own face on every
 * p and a (`body.ctypo p`, (0,1,2)).
 */

/* The listing's title just above the bar. b2b-marketplace.css gives page
   titles the display face, but the Customizer's `body.ctypo h1` outranks it,
   so on these pages it fell back to a system serif next to the bar. */
.woocommerce-products-header .woocommerce-products-header__title{
  font-family: var(--mm-font-display);
  font-weight: 600;
  letter-spacing: -.01em;
}

.mm-ctb{
  margin: 0 0 clamp(18px, 2.2vw, 28px);
  font-family: var(--mm-font-ui);
}

.mm-ctb__row{
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px) minmax(200px, 250px);
  gap: 12px;
}

.mm-ctb__field{
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.mm-ctb__icon{
  position: absolute;
  top: 50%;
  width: 17px;
  height: 17px;
  color: var(--mm-ink-subtle);
  transform: translateY(-50%);
  pointer-events: none;
}

.mm-ctb__icon--search,
.mm-ctb__icon--filter,
.mm-ctb__icon--sort{
  left: 16px;
}

.mm-ctb__icon--chevron{
  right: 16px;
  width: 16px;
  height: 16px;
  color: var(--mm-ink);
}

/* -- Controls ------------------------------------------------------------ */
.mm-ctb .mm-ctb__field .mm-ctb__input,
.mm-ctb .mm-ctb__field .mm-ctb__select{
  display: block;
  width: 100%;
  height: 50px;
  margin: 0;
  padding: 0 16px 0 44px;
  font-family: var(--mm-font-ui);
  font-size: var(--mm-text-md);
  font-weight: 500;
  line-height: 1.3;
  color: var(--mm-ink);
  background: var(--mm-surface);
  border: 1px solid var(--mm-border-strong);
  border-radius: 12px;
  box-shadow: none;
  -webkit-appearance: none;
          appearance: none;
  transition: border-color var(--mm-dur) var(--mm-ease),
              box-shadow var(--mm-dur) var(--mm-ease);
}

.mm-ctb .mm-ctb__field .mm-ctb__select{
  padding-right: 42px;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}

.mm-ctb .mm-ctb__field .mm-ctb__input{
  padding-right: 42px;
}

.mm-ctb .mm-ctb__field .mm-ctb__input::placeholder{
  color: var(--mm-ink-subtle);
  font-weight: 400;
  opacity: 1;
}

/* The browser's own clear button; the bar has its own once a search is on. */
.mm-ctb .mm-ctb__input::-webkit-search-cancel-button{
  -webkit-appearance: none;
}

.mm-ctb .mm-ctb__field .mm-ctb__input:hover,
.mm-ctb .mm-ctb__field .mm-ctb__select:hover{
  border-color: #BDBCB7;
}

.mm-ctb .mm-ctb__field .mm-ctb__input:focus,
.mm-ctb .mm-ctb__field .mm-ctb__select:focus{
  outline: none;
  border-color: var(--mm-ink);
  box-shadow: 0 0 0 4px rgba(30, 30, 30, .07);
}

.mm-ctb__field:focus-within .mm-ctb__icon--search{
  color: var(--mm-ink);
}

/* A category is chosen: the drop-down says so in the brand's colour, like
   the active filter on the reference. */
.mm-ctb .mm-ctb__field.is-active .mm-ctb__select{
  border-color: var(--mm-accent);
  box-shadow: 0 0 0 1px var(--mm-accent);
}

.mm-ctb__field.is-active .mm-ctb__icon--filter{
  color: var(--mm-accent);
}

/* Clear the search: a small round button inside the field's right edge. */
.mm-ctb .mm-ctb__clear{
  position: absolute;
  top: 50%;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--mm-ink-subtle);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: background-color var(--mm-dur) var(--mm-ease), color var(--mm-dur) var(--mm-ease);
}

.mm-ctb .mm-ctb__clear .mm-ctb__icon{
  position: static;
  width: 15px;
  height: 15px;
  color: currentColor;
  transform: none;
}

.mm-ctb .mm-ctb__clear:hover,
.mm-ctb .mm-ctb__clear:focus-visible{
  color: var(--mm-ink);
  background: var(--mm-surface-sunken);
}

/* Without the script, a button applies the drop-downs; with it they apply
   on change and the button goes. */
.mm-ctb__apply{
  display: none;
}

.mm-ctb:not(.is-enhanced) .mm-ctb__apply{
  display: block;
  grid-column: 1 / -1;
  justify-self: end;
  padding: 10px 22px;
  font-family: var(--mm-font-ui);
  font-size: var(--mm-text-sm);
  font-weight: 600;
  color: #fff;
  background: var(--mm-ink);
  border: 0;
  border-radius: var(--mm-radius);
  cursor: pointer;
}

/* While a change is loading the next page. */
.mm-ctb.is-loading .mm-ctb__row{
  opacity: .6;
  pointer-events: none;
}

/* -- Count and reset ----------------------------------------------------- */
.mm-ctb__meta{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  margin-top: 14px;
}

.mm-ctb .mm-ctb__count{
  margin: 0;
  font-family: var(--mm-font-ui);
  font-size: var(--mm-text-sm);
  color: var(--mm-ink-muted);
}

.mm-ctb .mm-ctb__count strong{
  font-weight: 700;
  color: var(--mm-ink);
}

.mm-ctb .mm-ctb__reset{
  font-family: var(--mm-font-ui);
  font-size: var(--mm-text-sm);
  font-weight: 600;
  color: var(--mm-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mm-ctb .mm-ctb__reset:hover{
  color: var(--mm-accent);
}

/* -- Empty states -------------------------------------------------------- */
/* Same frame as the empty shop page (.mm-shop-empty in shop.css), which is
   only loaded on the shop itself. */
.mm-ctb-empty{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 36rem;
  margin: clamp(12px, 2vw, 24px) auto var(--mm-section-y);
  padding: clamp(36px, 5vw, 56px) clamp(22px, 5vw, 44px);
  text-align: center;
  background: var(--mm-surface-alt);
  border: 1px dashed var(--mm-border-strong);
  border-radius: var(--mm-radius-lg);
}

.mm-ctb-empty .mm-ctb-empty__title{
  margin: 0;
  font-family: var(--mm-font-display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--mm-ink);
}

.mm-ctb-empty .mm-ctb-empty__text{
  max-width: 40ch;
  margin: 0;
  font-family: var(--mm-font-ui);
  font-size: var(--mm-text-base);
  line-height: 1.6;
  color: var(--mm-ink-muted);
}

.mm-ctb-empty__actions{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.mm-ctb-empty > .mm-btn{
  margin-top: 6px;
}

/* -- Smaller screens ----------------------------------------------------- */
/* The search takes a line of its own; the two drop-downs share the next. */
@media (max-width: 767px){
  .mm-ctb__row{
    grid-template-columns: 1fr 1fr;
  }

  .mm-ctb__field--search{
    grid-column: 1 / -1;
  }

  .mm-ctb .mm-ctb__field .mm-ctb__select{
    padding-left: 38px;
    font-size: var(--mm-text-sm);
  }

  .mm-ctb__icon--filter,
  .mm-ctb__icon--sort{
    left: 13px;
  }

  /* 16px keeps iOS from zooming the page in when the search is tapped. */
  .mm-ctb .mm-ctb__field .mm-ctb__input{
    font-size: 16px;
  }
}

@media (max-width: 380px){
  .mm-ctb__row{
    grid-template-columns: 1fr;
  }
}
