/* ═══════════════════════════════════════════════════════
   HAVEN HEADER v2
   Scope: .hv-header + .hv-drawer + .hv-overlay
   No afecta estilos globales del tema.
═══════════════════════════════════════════════════════ */

/* ── Utilidad accesibilidad ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Overlay ── */
.hv-overlay {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(26, 26, 24, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.hv-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Header shell ── */
.hv-header {
  position: sticky;
  top: 0;
  z-index: 300;
  background: rgba(248, 246, 242, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--c-border);
  transition: box-shadow 0.25s ease;
}
.hv-header.is-scrolled {
  box-shadow: 0 2px 20px rgba(26, 26, 24, 0.08);
}

/* ── Container (reutiliza haven-container) ── */
.hv-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}
@media (max-width: 768px) {
  .hv-container { padding: 0 var(--space-4); }
}

/* ── Bar principal ── */
.hv-header__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 72px;
  gap: var(--space-4);
}

/* ══════════════════════════════
   LOGO
══════════════════════════════ */
.hv-logo {
  text-align: center;
}
.hv-logo a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.hv-logo__img {
  height: 36px;
  width: auto;
  display: block;
}
.hv-logo__text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-black);
  line-height: 1;
}

/* ══════════════════════════════
   NAV DESKTOP
══════════════════════════════ */
.hv-nav {
  display: flex;
  align-items: center;
}
.hv-nav .haven-nav-item {
  list-style: none;
  display: inline-block;
}
.hv-nav .haven-nav-item + .haven-nav-item {
  margin-left: var(--space-6);
}
.hv-nav .haven-nav-item a {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--c-mid);
  letter-spacing: 0.04em;
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
  transition: color 0.25s ease;
}
.hv-nav .haven-nav-item a::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 0; height: 1px;
  background: var(--c-black);
  transition: width 0.25s ease;
}
.hv-nav .haven-nav-item a:hover,
.hv-nav .haven-nav-item.is-active a {
  color: var(--c-black);
}
.hv-nav .haven-nav-item a:hover::after,
.hv-nav .haven-nav-item.is-active a::after {
  width: 100%;
}

/* ══════════════════════════════
   ACCIONES DERECHA
══════════════════════════════ */
.hv-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

/* Botón / link de acción base */
.hv-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--c-black);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
  position: relative;
  white-space: nowrap;
}
.hv-action:hover {
  background: var(--c-border);
}
.hv-action svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* WhatsApp — visible en desktop como pill con label */
.hv-action--whatsapp {
  background: #25D366;
  color: #fff;
  padding: 0 var(--space-3);
}
.hv-action--whatsapp svg {
  stroke: none;
  fill: #fff;
  width: 18px; height: 18px;
}
.hv-action--whatsapp:hover {
  background: #1ebe5a;
  color: #fff;
}
.hv-action__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Carrito — badge + total */
.hv-action--cart {
  gap: 4px;
}
.hv-cart-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 3px;
  background: var(--c-sage);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.2s ease;
}
.hv-cart-badge--hidden {
  display: none;
}
.hv-cart-total {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-black);
  /* Solo visible en desktop cuando hay items */
}
/* Ocultar total si carrito vacío */
.hv-action--cart:has(.hv-cart-badge--hidden) .hv-cart-total {
  display: none;
}

/* Burger */
.hv-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px; height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease;
}
.hv-burger:hover { background: var(--c-border); }
.hv-burger__line {
  display: block;
  width: 20px; height: 1.5px;
  background: var(--c-black);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}
.hv-burger.is-active .hv-burger__line:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.hv-burger.is-active .hv-burger__line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hv-burger.is-active .hv-burger__line:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ══════════════════════════════
   PANEL DE BÚSQUEDA
══════════════════════════════ */
.hv-search-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  border-top: 0px solid var(--c-border);
  transition:
    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease,
    border-top-width 0.35s ease;
}
.hv-search-panel.is-open {
  max-height: 400px;
  opacity: 1;
  border-top-width: 1px;
}

.hv-search-panel__inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}

.hv-search-panel__input {
  flex: 1;
  height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--c-black);
  background: var(--c-bg);
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
}
.hv-search-panel__input:focus {
  outline: none;
  border-color: var(--c-black);
}
.hv-search-panel__input::placeholder {
  color: var(--c-mid);
  font-weight: 300;
}

.hv-search-panel__submit,
.hv-search-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-black);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.hv-search-panel__submit svg,
.hv-search-panel__close svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.hv-search-panel__submit {
  background: var(--c-black);
  border-color: var(--c-black);
  color: var(--c-white);
}
.hv-search-panel__submit:hover {
  background: var(--c-sage);
  border-color: var(--c-sage);
}
.hv-search-panel__close:hover {
  background: var(--c-border);
  border-color: var(--c-black);
}

/* Resultados de búsqueda */
.hv-search-results {
  padding-bottom: var(--space-4);
  display: none;
}
.hv-search-results.has-results {
  display: block;
}
.hv-search-results__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-mid);
  margin-bottom: var(--space-3);
}
.hv-search-results__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}
.hv-search-result-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--c-black);
  transition: opacity 0.2s ease;
}
.hv-search-result-item:hover { opacity: 0.75; }
.hv-search-result-item__img {
  aspect-ratio: 1;
  background: var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.hv-search-result-item__img img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.hv-search-result-item__name {
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.3;
}
.hv-search-result-item__price {
  font-size: var(--text-sm);
  font-weight: 600;
}
.hv-search-results__all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--c-sage);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Estado loading búsqueda */
.hv-search-results__loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  color: var(--c-mid);
}
.hv-search-results__loading::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-sage);
  border-radius: 50%;
  animation: hv-spin 0.6s linear infinite;
}

@keyframes hv-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════
   DRAWER MÓVIL
══════════════════════════════ */
.hv-drawer {
  position: fixed;
  top: 0; right: 0;
  z-index: 400;
  width: min(360px, 90vw);
  height: 100dvh;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 32px rgba(26, 26, 24, 0.12);
}
.hv-drawer.is-open {
  transform: translateX(0);
}

.hv-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.hv-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  color: var(--c-black);
  transition: background 0.2s ease;
}
.hv-drawer__close:hover { background: var(--c-border); }
.hv-drawer__close svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.hv-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-6);
}

.hv-drawer__nav {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
}
.hv-drawer__nav li {
  border-bottom: 1px solid var(--c-border);
}
.hv-drawer__nav li a {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 300;
  color: var(--c-black);
  text-decoration: none;
  padding: var(--space-4) 0;
  transition: color 0.2s ease, padding-left 0.2s ease;
}
.hv-drawer__nav li a:hover {
  color: var(--c-sage);
  padding-left: var(--space-2);
}

.hv-drawer__foot {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

.hv-drawer__social {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.hv-drawer__social a {
  width: 36px; height: 36px;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-mid);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.hv-drawer__social a:hover {
  border-color: var(--c-black);
  color: var(--c-black);
}
.hv-drawer__social svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 900px) {
  /* Ocultar nav desktop y label de WhatsApp */
  .hv-nav { display: none; }
  .hv-action__label { display: none; }
  .hv-action--whatsapp { padding: 0 10px; }
  .hv-burger { display: flex; }

  /* Grid 2 columnas: logo | acciones */
  .hv-header__bar {
    grid-template-columns: auto 1fr;
  }
  .hv-logo { text-align: left; order: -1; }
  .hv-actions { gap: 2px; }
}

@media (max-width: 480px) {
  /* En móvil pequeño ocultar "Mi cuenta" del header, se accede por drawer */
  .hv-action--account { display: none; }
  .hv-cart-total { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hv-drawer,
  .hv-overlay,
  .hv-search-panel,
  .hv-burger__line {
    transition: none !important;
  }
}
