/* Estructura general de la cabecera */
.site-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 100;
  background-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.site-header__container {
  display: flex;
  align-items: center;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Nivel superior */
.site-header__top {
  background-color: var(--primary);
  height: 84px;
  display: flex;
  align-items: center;
}

.site-header__container--top {
  justify-content: space-between;
  gap: 2rem;
}

.site-header__mobile-toggle {
  display: none;
}

/* Identidad de marca */
.site-header__brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.site-header__brand .custom-logo-link {
  display: inline-flex;
}

.site-header__brand img {
  max-height: 48px;
  width: auto;
  display: block;
}

.site-header__brand-link {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--text-inverse);
  text-decoration: none;
  letter-spacing: -0.02em;
}

/* Buscador central */
.site-header__search {
  position: relative;
  flex: 1 1 auto;
  max-width: 680px;
  z-index: 102;
}

.header-search {
  position: relative;
  display: flex;
  align-items: stretch;
  background-color: var(--input-bg);
  border-radius: 6px;
  height: 46px;
  overflow: hidden;
}

.header-search__input-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 1rem;
}

.header-search__input {
  width: 100%;
  height: 100%;
  padding: 0;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
}

.header-search__input::-webkit-search-cancel-button,
.header-search__input::-webkit-search-decoration,
.header-search__input::-webkit-search-results-button,
.header-search__input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.header-search__input::placeholder {
  color: var(--placeholder);
  font-weight: 400;
}

.header-search__clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  cursor: pointer;
}

.header-search.has-value .header-search__clear {
  display: inline-flex;
}

.header-search__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  background-color: var(--accent);
  border: none;
  color: var(--text-inverse);
  font-size: var(--fs-md);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.header-search__submit:hover {
  background-color: var(--accent-hover);
}

/* Resultados predictivos */
.site-header__search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  max-height: 440px;
  overflow-y: auto;
  z-index: 103;
}

.site-header__search-results[hidden] {
  display: none;
}

.site-header__search-results[aria-busy="true"] {
  min-height: 80px;
  opacity: 0.7;
  pointer-events: none;
}

.header-search-results {
  display: flex;
  flex-direction: column;
}

.header-search-result {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.15s ease;
}

.header-search-result:last-child {
  border-bottom: none;
}

.header-search-result:hover,
.header-search-result.is-active,
.header-search-result[aria-selected="true"],
.header-search-results__all:hover,
.header-search-results__all.is-active,
.header-search-results__all[aria-selected="true"] {
  background-color: var(--bg-dark);
}

.header-search-result__image {
  flex-shrink: 0;
  width: 44px;
  height: 60px;
  background-color: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-search-result__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-search-result__content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.header-search-result__title {
  margin: 0;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-search-result__price {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--price-regular);
}

.header-search-result__price ins {
  text-decoration: none;
  color: var(--price-sale);
}

.header-search-result__price del {
  color: var(--price-old);
  font-weight: 400;
  margin-right: 0.2rem;
}

.header-search-results__all {
  display: block;
  padding: 0.75rem 1rem;
  background-color: var(--bg);
  color: var(--accent);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-top: 1px solid var(--border-light);
}

.header-search-results__empty {
  padding: 1.75rem 1rem;
  text-align: center;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.site-header__search-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 101;
}

.site-header__search-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* Acciones de usuario */
.site-header__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.site-header__action-wrapper {
  position: relative;
}

.site-header__action {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-inverse);
  cursor: pointer;
}

/* Enlace Login / Registro */
.site-header__action--login {
  padding: 0.5rem 0.75rem;
  color: var(--text-inverse);
}

.site-header__action--login .site-header__action-icon {
  font-size: var(--fs-lg);
}

.site-header__action--login .site-header__action-label {
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* Botones con estilo pastilla 3D */
.site-header__action--pill {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-header__action--wishlist {
  background-color: var(--bg-light);
  color: var(--primary);
  box-shadow: 0 3px 0 var(--border);
}

.site-header__action--wishlist:hover {
  background-color: var(--bg);
}

.site-header__action--cart {
  background-color: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 3px 0 var(--accent-hover);
}

.site-header__action--cart:hover {
  background-color: var(--accent-hover);
}

.site-header__action-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  line-height: 1;
}

.site-header__badge {
  position: absolute;
  top: -8px;
  right: -10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  line-height: 1;
  border-radius: 9999px;
}

.site-header__badge--cart {
  background-color: var(--bg-light);
  color: var(--accent);
}

.site-header__badge--wishlist {
  background-color: var(--accent);
  color: var(--text-inverse);
}

.site-header__action-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
}

/* Nivel inferior de navegación */
.site-header__bottom {
  background-color: var(--primary);
  height: 44px;
  border-top: 1px solid var(--secondary);
}

.site-header__container--bottom {
  height: 100%;
  gap: 1.5rem;
}

/* Botón de categorías en la barra inferior */
.site-header__categories {
  position: relative;
  flex-shrink: 0;
  height: 100%;
}

.site-header__categories-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  padding: 0 1rem;
  background-color: var(--primary-hover);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  transition: background-color 0.15s ease;
}

.site-header__categories-btn:hover,
.site-header__categories-btn[aria-expanded="true"] {
  background-color: var(--secondary-hover);
}

.site-header__categories-icon {
  font-size: var(--fs-md);
  line-height: 1;
}

.site-header__categories-text {
  color: inherit;
}

.site-header__categories-arrow {
  font-size: var(--fs-xs);
  line-height: 1;
  transition: transform 0.2s ease;
}

.site-header__categories-btn[aria-expanded="true"] .site-header__categories-arrow {
  transform: rotate(180deg);
}

/* Menú temático */
.site-header__nav {
  flex: 1;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-header__nav::-webkit-scrollbar {
  display: none;
}

.site-header__nav-list {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
  white-space: nowrap;
}

.site-header__nav-list > li {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.site-header__bottom .site-header__nav-list > li > a {
  display: inline-flex;
  align-items: center;
  height: 100%;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  color: var(--text-inverse);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.site-header__bottom .site-header__nav-list > li > a:hover {
  opacity: 0.8;
}

.site-header__nav-list > li.menu-item-has-children > a::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 0.35rem;
  border-right: 1.5px solid var(--text-inverse);
  border-bottom: 1.5px solid var(--text-inverse);
  transform: rotate(45deg);
  position: relative;
  top: -2px;
}

/* Tablet (769px a 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .site-header__container {
    padding: 0 1.25rem;
    gap: 1rem;
  }

  .site-header__search {
    max-width: 440px;
  }

  .site-header__actions {
    gap: 0.75rem;
  }

  .site-header__action--pill {
    padding: 0.5rem 0.85rem;
  }

  .site-header__nav-list {
    gap: 1.25rem;
  }
}

/* Móvil (<= 768px) */
@media (max-width: 768px) {
  .site-header__top {
    height: auto;
    padding: 0.65rem 0;
  }

  .site-header__container--top {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1rem;
  }

  .site-header__mobile-toggle {
    order: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--text-inverse);
    background: transparent;
    border: none;
    font-size: var(--fs-xl);
    cursor: pointer;
    flex-shrink: 0;
  }

  .site-header__brand {
    order: 2;
    flex: 1;
  }

  .site-header__brand img {
    max-height: 32px;
  }

  .site-header__actions {
    order: 3;
    gap: 0.5rem;
  }

  .site-header__action--login {
    padding: 0.25rem;
  }

  .site-header__action--login .site-header__action-label {
    display: none;
  }

  .site-header__action--pill {
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
  }

  .site-header__action--pill .site-header__action-label {
    display: none;
  }

  .site-header__search {
    order: 4;
    width: 100%;
    max-width: 100%;
  }

  .header-search {
    height: 40px;
  }

  .site-header__search-results {
    position: fixed;
    top: 6.5rem;
    left: 0.75rem;
    right: 0.75rem;
    max-height: 60vh;
  }

  .site-header__bottom {
    display: none;
  }
}