/* =============================================================================
   MasterSupply – Brands  |  CSS autónomo, sin dependencias del tema
   ============================================================================= */

/* Forzar hidden en nuestros componentes por si el tema lo sobreescribe */
.msc-brands-directory [hidden],
.msc-brand-archive-header [hidden] {
  display: none !important;
}

/* =============================================================================
   CABECERA EN /brand/{slug}/
   ============================================================================= */

.msc-brand-archive-header {
  display: flex !important;
  align-items: center !important;
  gap: 28px;
  padding: 24px 28px;
  margin: 0 0 32px !important;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-sizing: border-box;
}

.msc-brand-archive-header__logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 28px;
  border-right: 1px solid #e0e0e0;
}

.msc-brand-archive-logo {
  display: block;
  max-width: 120px;
  max-height: 70px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.msc-brand-archive-header__info {
  flex: 1;
  min-width: 0;
}

.msc-brand-archive-header__title {
  margin: 0 0 6px !important;
  padding: 0 !important;
  font-size: 1.6rem !important;
  line-height: 1.2 !important;
  color: #111 !important;
  font-weight: 700 !important;
  border: none !important;
  background: none !important;
}

.msc-brand-archive-header__desc {
  color: #555;
  font-size: .9em;
  line-height: 1.65;
  margin: 0 0 12px;
}
.msc-brand-archive-header__desc p { margin: 0; }

.msc-brand-archive-header__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.msc-brand-archive-header__count {
  font-size: .76em;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #777;
  background: #f4f4f4;
  padding: 3px 10px;
  border-radius: 20px;
}

.msc-brand-archive-header__website {
  font-size: .82em;
  font-weight: 600;
  color: #111 !important;
  text-decoration: none !important;
  border-bottom: 1px solid #111;
  transition: opacity .2s;
}
.msc-brand-archive-header__website:hover { opacity: .55; }

/* =============================================================================
   DIRECTORIO – wrapper
   ============================================================================= */

.msc-brands-directory {
  width: 100%;
  box-sizing: border-box;
}

/* =============================================================================
   TOOLBAR: buscador + contador
   ============================================================================= */

.msc-brands-dir__toolbar {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* El wrap necesita position:relative para anclar el ✕ dentro */
.msc-brands-dir__search-wrap {
  position: relative !important;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.msc-brands-dir__search-icon {
  position: absolute !important;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #bbb;
  pointer-events: none;
  display: block !important;
  line-height: 0;
  z-index: 1;
}

.msc-brands-dir__search {
  display: block !important;
  width: 100% !important;
  height: 42px !important;
  padding: 0 38px 0 40px !important;
  border: 1px solid #d8d8d8 !important;
  border-radius: 4px !important;
  background: #fff !important;
  color: #222 !important;
  font-size: .9em !important;
  font-family: inherit !important;
  outline: none !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .2s;
}
.msc-brands-dir__search:focus {
  border-color: #999 !important;
}
.msc-brands-dir__search::placeholder { color: #bbb; }
.msc-brands-dir__search::-webkit-search-cancel-button,
.msc-brands-dir__search::-webkit-search-decoration { -webkit-appearance: none; }

/* ✕ anclado dentro del input, a la derecha */
.msc-brands-dir__search-clear {
  position: absolute !important;
  right: 10px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #eee !important;
  border: none !important;
  border-radius: 50% !important;
  cursor: pointer;
  color: #555 !important;
  font-size: 11px !important;
  line-height: 1;
  padding: 0 !important;
  box-shadow: none !important;
  transition: background .15s;
  z-index: 2;
}
.msc-brands-dir__search-clear:hover { background: #ddd !important; }

.msc-brands-dir__count-label {
  font-size: .8em;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
}

/* =============================================================================
   FILTRO A–Z
   ============================================================================= */

.msc-brands-alpha-nav {
  display: flex !important;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e8e8e8;
}

.msc-alpha-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 34px;
  padding: 0 9px;
  background: #fff !important;
  border: 1px solid #d8d8d8 !important;
  border-radius: 3px !important;
  font-size: .8em !important;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .04em;
  color: #333 !important;
  cursor: pointer;
  line-height: 1;
  box-shadow: none !important;
  transition: background .15s, border-color .15s, color .15s;
}
.msc-alpha-btn:hover {
  background: #f4f4f4 !important;
  border-color: #aaa !important;
}
.msc-alpha-btn--active,
.msc-alpha-btn--active:hover {
  background: #111 !important;
  border-color: #111 !important;
  color: #fff !important;
}

/* =============================================================================
   GRID DE TARJETAS
   ============================================================================= */

.msc-brands-dir__grid {
  display: grid !important;
  gap: 16px;
}

.msc-brands-dir__grid.msc-brands-grid--cols-1 { grid-template-columns: repeat(1, 1fr); }
.msc-brands-dir__grid.msc-brands-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.msc-brands-dir__grid.msc-brands-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.msc-brands-dir__grid.msc-brands-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.msc-brands-dir__grid.msc-brands-grid--cols-5 { grid-template-columns: repeat(5, 1fr); }
.msc-brands-dir__grid.msc-brands-grid--cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Tarjeta */
.msc-brand-card {
  display: block;
}

.msc-brand-card__link {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none !important;
  color: #222 !important;
  padding: 22px 14px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  height: 100%;
  box-sizing: border-box;
  position: relative;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.msc-brand-card__link:hover {
  border-color: #bbb;
  box-shadow: 0 3px 16px rgba(0,0,0,.08);
  transform: translateY(-2px);
  text-decoration: none !important;
}

/* Logo: gris en reposo, color en hover */
.msc-brand-card__logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 72px;
  margin-bottom: 10px;
}

.msc-brand-card__logo {
  display: block;
  max-width: 100%;
  max-height: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: grayscale(1);
  opacity: .65;
  transition: filter .25s, opacity .25s;
}
.msc-brand-card__link:hover .msc-brand-card__logo {
  filter: grayscale(0);
  opacity: 1;
}

/* Iniciales cuando no hay logo */
.msc-brand-card__initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f0f0f0;
  font-size: 1.2em;
  font-weight: 700;
  color: #888;
  letter-spacing: .04em;
  transition: background .2s, color .2s;
}
.msc-brand-card__link:hover .msc-brand-card__initials {
  background: #111;
  color: #fff;
}

.msc-brand-card__name {
  display: block;
  font-size: .82em;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  margin-bottom: 3px;
  transition: color .2s;
}
.msc-brand-card__link:hover .msc-brand-card__name { color: #000; }

.msc-brand-card__count {
  display: block;
  font-size: .74em;
  color: #999;
}

/* Badge destacada */
.msc-brand-card__badge {
  position: absolute;
  top: 7px;
  right: 8px;
  font-size: 12px;
  color: #f5a623;
  line-height: 1;
  pointer-events: none;
}

.msc-brand-card--featured .msc-brand-card__link {
  border-color: rgba(245,166,35,.35);
}

/* Estado vacío */
.msc-brands-dir__empty,
.msc-brands-dir__no-brands {
  text-align: center;
  padding: 48px 16px;
  color: #999;
  font-size: .9em;
}

/* =============================================================================
   SHORTCODE SIMPLE [ms_brands]
   ============================================================================= */

.msc-brands-grid {
  display: grid;
  gap: 14px;
}
.msc-brands-grid--cols-1 { grid-template-columns: repeat(1, 1fr); }
.msc-brands-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.msc-brands-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.msc-brands-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.msc-brands-grid--cols-5 { grid-template-columns: repeat(5, 1fr); }
.msc-brands-grid--cols-6 { grid-template-columns: repeat(6, 1fr); }

.msc-brand-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.msc-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none !important;
  transition: opacity .2s;
}
.msc-brand-link:hover { opacity: .6; }
.msc-brand-logo {
  max-height: 48px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
}
.msc-brand-name {
  display: block;
  margin-top: 5px;
  font-size: .78em;
  color: #888;
}
.msc-brand-name-only {
  font-weight: 600;
  color: #333;
}

/* Ficha de producto */
.msc-product-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  font-size: .88em;
}
.msc-brand-label { font-weight: 600; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1100px) {
  .msc-brands-dir__grid.msc-brands-grid--cols-5,
  .msc-brands-dir__grid.msc-brands-grid--cols-6 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .msc-brands-dir__grid.msc-brands-grid--cols-4,
  .msc-brands-dir__grid.msc-brands-grid--cols-5,
  .msc-brands-dir__grid.msc-brands-grid--cols-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .msc-brand-archive-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px;
    padding: 20px !important;
  }
  .msc-brand-archive-header__logo {
    border-right: none !important;
    border-bottom: 1px solid #e0e0e0;
    padding-right: 0 !important;
    padding-bottom: 16px;
    width: 100%;
    justify-content: flex-start;
  }

  .msc-brands-dir__toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .msc-brands-dir__search-wrap { max-width: 100%; }
  .msc-brands-dir__count-label { text-align: right; }

  .msc-alpha-btn { min-width: 30px; height: 30px; }

  .msc-brands-dir__grid.msc-brands-grid--cols-3,
  .msc-brands-dir__grid.msc-brands-grid--cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .msc-brands-dir__grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .msc-brands-grid          { grid-template-columns: repeat(2, 1fr) !important; }
  .msc-brand-card__link { padding: 16px 10px 12px; }
  .msc-brand-card__logo-wrap { min-height: 56px; }
  .msc-brand-card__logo { max-height: 56px; }
}
