/**
 * TiendaPocket — Header 7 (Tienda Electro layout)
 * Fila 1: Logo | Buscador con categoría | Timer + Favoritos + Carrito
 * Fila 2: Hamburguesa + Menú | Nav secundaria | Redes sociales
 * Mobile: Hamburguesa | Logo | Carrito
 */

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --h7-announce-height: 30px;
  --h7-row1-height: 68px;
  --h7-row2-height: 42px;
  --h7-total-height: calc(var(--h7-announce-height) + var(--h7-row1-height) + var(--h7-row2-height));
  --h7-total-height-no-bar: calc(var(--h7-row1-height) + var(--h7-row2-height));
  --h7-mobile-bar-height: 56px;
  --h7-bg: var(--header-bg, var(--color-bg, #ffffff));
  --h7-bg-row2: var(--header-bg, var(--color-surface, #f8fafc));
  --h7-text: var(--color-text, #1e293b);
  --h7-accent: var(--color-accent, #6366f1);
  --h7-search-bg: var(--color-bg, #ffffff);
  --h7-search-border: var(--color-border, #e2e8f0);
  --h7-search-radius: 6px;
  --h7-row2-border: var(--color-border, #e2e8f0);
  --h7-max-w: 1280px;
  --h7-px: clamp(1rem, 3vw, 2rem);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ANNOUNCEMENT BAR
═══════════════════════════════════════════════════════════════════════════════ */
.tp-h7-announce {
  background: var(--topbar-bg, #0f172a);
  height: var(--h7-announce-height);
  overflow: hidden;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.tp-h7-announce__track {
  display: flex;
  align-items: center;
  animation: tp-h7-marquee 28s linear infinite;
  will-change: transform;
  width: max-content;
}

.tp-h7-announce:hover .tp-h7-announce__track {
  animation-play-state: paused;
}

.tp-h7-announce__item {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--topbar-text, #ffffff);
  padding: 0 2rem;
  flex-shrink: 0;
  text-transform: uppercase;
}

.tp-h7-announce__sep {
  color: var(--topbar-text, #ffffff);
  flex-shrink: 0;
  opacity: 0.35;
  font-size: 10px;
}

@keyframes tp-h7-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-33.333%); }
}

/* Posición "Debajo del header": la barra sale del wrapper sticky y queda en
   flujo normal, entre el header y el primer bloque de la página. */
.tp-h7-announce--below {
  position: relative;
  z-index: 1;
  width: 100%;
}

/* ── Wrapper ────────────────────────────────────────────────────────────────── */
.tp-h7-wrap {
  width: 100%;
  background: var(--h7-bg);
}

.tp-h7-wrap--sticky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* Ocultar deslizando hacia arriba al scrollear hacia abajo (solo mobile) */
@media (max-width: 768px) {
  .tp-h7-wrap--sticky {
    transition: transform 0.25s ease;
    will-change: transform;
  }

  .tp-h7-wrap--sticky.tp-h7-wrap--hidden {
    transform: translateY(-100%);
  }
}

body.admin-bar .tp-h7-wrap--sticky {
  top: 32px;
}

@media (max-width: 782px) {
  body.admin-bar .tp-h7-wrap--sticky {
    top: 46px;
  }
}

/* Compensar espacio del header fijo — desktop */
@media (min-width: 769px) {
  body:has(.tp-h7-wrap--sticky) {
    padding-top: var(--h7-total-height);
  }
  body:has(.tp-h7-wrap--sticky):not(:has(.tp-h7-wrap .tp-h7-announce)) {
    padding-top: var(--h7-total-height-no-bar);
  }
}

/* Mobile */
@media (max-width: 768px) {
  body:has(.tp-h7-wrap--sticky) {
    padding-top: calc(var(--h7-announce-height) + var(--h7-mobile-bar-height));
  }
  body:has(.tp-h7-wrap--sticky):not(:has(.tp-h7-wrap .tp-h7-announce)) {
    padding-top: var(--h7-mobile-bar-height);
  }
}

/* ── Inner container ────────────────────────────────────────────────────────── */
.tp-h7__inner {
  max-width: var(--h7-max-w);
  margin: 0 auto;
  padding: 0 var(--h7-px);
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HEADER DESKTOP — oculto en mobile
═══════════════════════════════════════════════════════════════════════════════ */
.tp-h7 {
  display: block;
}

/* ── Fila 1 ─────────────────────────────────────────────────────────────────── */
.tp-h7__row1 {
  background: var(--h7-bg);
  height: var(--h7-row1-height);
}

.tp-h7__row1 .tp-h7__inner {
  height: 100%;
}

/* Logo */
.tp-h7__logo {
  flex-shrink: 0;
}

.tp-h7__logo a,
.tp-h7__logo img {
  display: block;
  max-height: 42px;
  width: auto;
}

/* ── Buscador ───────────────────────────────────────────────────────────────── */
.tp-h7__search-wrap {
  flex: 1;
  min-width: 0;
  max-width: 620px;
  position: relative;
}

.tp-h7-search {
  display: flex;
  align-items: stretch;
  background: var(--h7-search-bg);
  border-radius: var(--h7-search-radius);
  overflow: visible;
  height: 42px;
  border: 2px solid var(--h7-search-border);
  transition: border-color 0.2s;
  padding: 0;
  clip-path: none;
}

.tp-h7-search:focus-within {
  border-color: var(--h7-accent);
}

/* Select de categoría */
.tp-h7-search__cat-wrap {
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
  border-radius: calc(var(--h7-search-radius) - 2px) 0 0 calc(var(--h7-search-radius) - 2px);
  overflow: hidden;
}

/* Sin categorías: border-radius izquierdo en el input */
.tp-h7-search__input:first-child {
  border-radius: calc(var(--h7-search-radius) - 2px) 0 0 calc(var(--h7-search-radius) - 2px);
}

/* Dropdown de sugerencias anclado al search-wrap */
.tp-h7__search-wrap .tp-search-dropdown {
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
}

.tp-h7-search__cat-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--color-text, #374151);
  padding: 0 28px 0 12px;
  height: 100%;
  cursor: pointer;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-h7-search__cat-arrow {
  position: absolute;
  right: 8px;
  pointer-events: none;
  color: var(--color-text-muted, #6b7280);
}

.tp-h7-search__divider {
  width: 1px;
  height: 22px;
  background: var(--color-border, #d1d5db);
  flex-shrink: 0;
}

/* Input */
.tp-h7-search__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--color-text, #111);
  padding: 0 12px;
  min-width: 0;
}

.tp-h7-search__input::placeholder {
  color: var(--color-text-muted, #9ca3af);
}

/* Botón búsqueda */
.tp-h7-search__btn {
  flex-shrink: 0;
  background: var(--h7-accent);
  border: none;
  outline: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  align-self: stretch;
  transition: background 0.2s;
  border-radius: 0 calc(var(--h7-search-radius) - 2px) calc(var(--h7-search-radius) - 2px) 0;
}

.tp-h7-search__btn:hover {
  filter: brightness(1.1);
}

/* ── Acciones (timer + fav + carrito) ──────────────────────────────────────── */
.tp-h7__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.tp-h7-action {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--h7-text);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  gap: 6px;
}

.tp-h7-action:hover {
  background: var(--color-surface, rgba(0,0,0,0.05));
}

.tp-h7-action--icon {
  flex-direction: column;
  gap: 3px;
  padding: 6px 10px;
}

.tp-h7-action__icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.tp-h7-action__label {
  font-size: 11px;
  color: var(--h7-text);
  white-space: nowrap;
  opacity: 0.85;
}

/* Timer: ya tiene su propio estilo del plugin */
.tp-h7-action--timer {
  padding: 0 6px;
}

.tp-h7-action--timer .header-shipping-timer {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Badge ──────────────────────────────────────────────────────────────────── */
.tp-h7-action__icon-wrap .tp-h7-badge,
.tp-h7-action__icon-wrap .tp-cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--h7-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  transform: none;
  opacity: 1;
}

/* El badge de favoritos siempre está en el DOM (la lista de los invitados vive
   en localStorage y la completa el JS), así que se oculta hasta tener valor. */
.tp-h7-action__icon-wrap .tp-wishlist-badge { display: none; }
.tp-h7-action__icon-wrap .tp-wishlist-badge.tp-wishlist-badge--visible { display: flex; }

/* ── Fila 2 ─────────────────────────────────────────────────────────────────── */
.tp-h7__row2 {
  background: var(--h7-bg-row2);
  border-top: 1px solid var(--h7-row2-border);
  height: var(--h7-row2-height);
}

.tp-h7__row2 .tp-h7__inner {
  height: 100%;
  gap: 0;
}

/* Botón hamburguesa + "Menú" */
.tp-h7-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--h7-text);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px 6px 0;
  border-right: 1px solid var(--h7-row2-border);
  margin-right: 16px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.tp-h7-menu-btn:hover {
  opacity: 0.8;
}

/* Nav bottom */
.tp-h7__bottom-nav {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tp-h7-bottom-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
}

.tp-h7-bottom-menu > li > a {
  display: flex;
  align-items: center;
  height: var(--h7-row2-height);
  padding: 0 14px;
  font-size: 13px;
  color: var(--h7-text);
  text-decoration: none;
  opacity: 0.85;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s;
  border-bottom: 2px solid transparent;
}

.tp-h7-bottom-menu > li > a:hover,
.tp-h7-bottom-menu > li.current-menu-item > a,
.tp-h7-bottom-menu > li.current-page-ancestor > a {
  opacity: 1;
  border-bottom-color: var(--h7-accent);
}

/* Redes */
.tp-h7__socials {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.tp-h7__socials-label {
  font-size: 12px;
  color: var(--h7-text);
  opacity: 0.7;
  white-space: nowrap;
  margin-right: 4px;
}

.tp-h7__social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-surface, rgba(0,0,0,0.06));
  color: var(--h7-text);
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.tp-h7__social-link:hover {
  background: var(--h7-accent);
  transform: scale(1.08);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE TOP BAR — visible solo en mobile
═══════════════════════════════════════════════════════════════════════════════ */
.tp-h7-mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--h7-bg);
  height: var(--h7-mobile-bar-height);
  padding: 0 16px;
}

.tp-h7-mobile-bar__hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--h7-text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.tp-h7-mobile-bar__logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.tp-h7-mobile-bar__logo a,
.tp-h7-mobile-bar__logo img {
  display: block;
  max-height: 34px;
  width: auto;
}

.tp-h7-mobile-bar__right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tp-h7-mobile-bar__cart {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--h7-text);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px;
}

.tp-h7-mobile-bar__cart .tp-h7-mobile-cart-badge,
.tp-h7-mobile-bar__cart .tp-cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--h7-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  transform: none;
  opacity: 1;
}

.tp-h7-mobile-bar__cart .tp-h7-mobile-cart-badge.tp-cart-badge--visible,
.tp-h7-mobile-bar__cart .tp-cart-badge.tp-cart-badge--visible {
  display: flex;
}

/* ── Favoritos en la barra mobile ──────────────────────────────────────────── */
.tp-h7-mobile-bar__fav {
  color: var(--h7-text);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px;
}

.tp-h7-mobile-bar__fav .tp-wishlist-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--h7-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.tp-h7-mobile-bar__fav .tp-wishlist-badge.tp-wishlist-badge--visible {
  display: flex;
}

/* ── Mobile sub-bar: timer + buscador ──────────────────────────────────────── */
.tp-h7-mobile-sub {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--h7-bg);
  padding: 8px 14px 10px;
  border-top: 1px solid var(--h7-row2-border);
  position: relative;
}

.tp-h7-mobile-sub__timer {
  display: flex;
  justify-content: center;
  align-items: center;
}

.tp-h7-mobile-sub__timer .header-shipping-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}


.tp-h7-mobile-sub__search {
  display: flex;
  align-items: stretch;
  background: var(--h7-search-bg);
  border: 2px solid var(--h7-search-border);
  border-radius: var(--h7-search-radius);
  height: 40px;
  overflow: hidden;
  padding: 0;
}

.tp-h7-mobile-sub__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--color-text, #111);
  padding: 0 12px;
  min-width: 0;
}

.tp-h7-mobile-sub__input::placeholder {
  color: var(--color-text-muted, #9ca3af);
}

.tp-h7-mobile-sub__btn {
  flex-shrink: 0;
  background: var(--h7-accent);
  border: none;
  outline: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  align-self: stretch;
  border-radius: 0 calc(var(--h7-search-radius) - 2px) calc(var(--h7-search-radius) - 2px) 0;
  transition: background 0.2s;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Ocultar header desktop */
  .tp-h7 {
    display: none;
  }

  /* Mostrar mobile bar + sub-bar */
  .tp-h7-mobile-bar {
    display: flex;
    position: relative;
  }

  .tp-h7-mobile-sub {
    display: flex;
  }

  /* Padding-top actualizado para incluir sub-bar */
  body:has(.tp-h7-wrap--sticky) {
    padding-top: calc(var(--h7-announce-height) + var(--h7-mobile-bar-height) + 66px);
  }
  body:has(.tp-h7-wrap--sticky):not(:has(.tp-h7-wrap .tp-h7-announce)) {
    padding-top: calc(var(--h7-mobile-bar-height) + 66px);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .tp-h7__socials-label {
    display: none;
  }

  .tp-h7__search-wrap {
    max-width: 380px;
  }

  .tp-h7-action__label {
    display: none;
  }

  .tp-h7-action--icon {
    flex-direction: row;
    gap: 4px;
  }
}

@media (min-width: 769px) {
  .tp-h7-mobile-bar,
  .tp-h7-mobile-sub {
    display: none;
  }
}

/* Home transparente (opcional, si se usa) */
body.home:has(.tp-h7-wrap--sticky) .tp-h7 {
  /* No transparente por defecto en este layout — fondo oscuro siempre */
}
