/* ════════════════════════════════════════
   HEADER
════════════════════════════════════════ */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--color-header-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-header);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 28px;
  gap: 20px;
  transition: transform 0.3s ease, background var(--t-base), box-shadow var(--t-base);
}
#site-header.header--hidden {
  transform: translateY(-100%);
}
#site-header.scrolled {
  background: var(--color-header-glass-scrolled);
  box-shadow: var(--shadow-sm);
}

/* ── Logo ── */
.logo {
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  display: flex;
  align-items: center;
}
.logo-img {
  height: 42px;
  width: auto;
  display: block;
}
.logo-light-only { display: none; }
[data-theme="light"] .logo-dark-only  { display: none; }
[data-theme="light"] .logo-light-only { display: block; }

/* ════════════════════════════════════════
   BARRA BÚSQUEDA CENTRAL
════════════════════════════════════════ */
.header-search-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid var(--color-border);
  border-radius: 40px;
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
  text-align: left;
}
.header-search-pill:hover {
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.09);
}
.header-search-pill:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139,92,246,.15);
}

.header-search-icon {
  color: var(--color-text-muted);
  font-size: .9rem;
  flex-shrink: 0;
}

.header-search-placeholder {
  flex: 1;
  font-size: .88rem;
  font-weight: 400;
  color: var(--color-text-muted);
  font-family: var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .3s ease, transform .3s ease;
}
.header-search-placeholder.fade-out {
  opacity: 0;
  transform: translateY(-6px);
}
.header-search-placeholder.fade-in {
  opacity: 0;
  transform: translateY(6px);
}

.header-search-ai-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: rgba(139,92,246,.12);
  border: 1px solid rgba(139,92,246,.25);
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ════════════════════════════════════════
   ACCIONES DERECHA
════════════════════════════════════════ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Links Tienda / Blog */
.nav-link-pill {
  padding: 6px 13px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color .18s, background .18s;
  white-space: nowrap;
}
.nav-link-pill:hover {
  color: var(--color-text);
  background: rgba(255,255,255,.07);
}
.nav-link-pill.active { color: var(--color-accent); }

/* Icon buttons */
.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: 1rem;
  transition: color .18s, background .18s;
  position: relative;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--color-text);
  background: rgba(255,255,255,.07);
}

/* Cart badge */
.cart-badge {
  position: absolute;
  top: 3px; right: 3px;
  background: var(--color-accent);
  color: #000;
  font-size: .55rem;
  font-weight: 800;
  min-width: 16px; height: 16px;
  padding: 0 3px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.cart-badge:empty { display: none; }

/* ════════════════════════════════════════
   SANDWICH DROPDOWN
════════════════════════════════════════ */
.header-sandwich-wrap {
  position: relative;
}

.sandwich-btn {
  border-radius: 10px !important;
  border: 1.5px solid var(--color-border) !important;
  width: 40px !important; height: 38px !important;
  transition: border-color .18s, background .18s !important;
}
.sandwich-btn:hover,
.sandwich-btn.open {
  border-color: rgba(255,255,255,.2) !important;
  background: rgba(255,255,255,.07) !important;
  color: var(--color-text) !important;
}

.sandwich-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(.97);
  transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
  z-index: 200;
}
.sandwich-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.sandwich-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
}
.sandwich-link i {
  width: 18px;
  text-align: center;
  color: var(--color-accent);
  font-size: .85rem;
  flex-shrink: 0;
}
.sandwich-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--color-text);
}

.sandwich-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ── Search open: oculta el pill para que no duplique ── */
#site-header.search-open .header-search-pill {
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}

/* ── Hamburger (solo móvil) ── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none; border: none;
  cursor: pointer; padding: 6px;
  border-radius: var(--radius-md);
  color: var(--color-text);
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--t-base), opacity var(--t-fast);
  pointer-events: none;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile overlay ── */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: var(--z-overlay);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}
.mobile-overlay.active {
  opacity: 1; pointer-events: auto; visibility: visible;
}

/* ── Mobile drawer ── */
.mobile-drawer {
  position: fixed;
  top: 0; left: 0;
  width: var(--drawer-w);
  height: 100dvh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform var(--t-slow);
  display: flex; flex-direction: column;
  padding: var(--sp-6);
  gap: var(--sp-6);
}
.mobile-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-header button {
  background: none; border: none;
  color: var(--color-text-muted); font-size: 1.2rem;
  cursor: pointer; padding: 6px; border-radius: var(--radius-md);
  transition: color var(--t-fast);
}
.drawer-header button:hover { color: var(--color-text); }

.drawer-nav {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.drawer-link {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-base); font-weight: 600;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: color var(--t-fast), background var(--t-fast);
  text-decoration: none;
}
.drawer-link:hover {
  color: var(--color-text);
  background: var(--color-drawer-link-hover);
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 900px) {
  #site-header { padding: 0 16px; gap: 10px; }

  /* Ocultar links Tienda/Blog, sandwich, theme y carrito en tablet/móvil */
  .nav-link-pill { display: none; }
  .header-sandwich-wrap { display: none; }
  #theme-toggle { display: none; }
  #cart-toggle { display: none; } /* va al bottom nav en móvil */

  /* Mostrar hamburguesa móvil */
  .hamburger { display: flex; }
  .mobile-overlay { display: block; }

  /* Search: sin badge, centrada dentro de su celda */
  .header-search-pill { max-width: 100%; min-width: 0; }
  .header-search-ai-badge { display: none; }
}

@media (max-width: 520px) {
  #site-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 12px;
  }
  .logo { flex-shrink: 0; }
  .logo-img { height: 30px; }
  .header-search-placeholder { font-size: .8rem; }
}

/* ════════════════════════════════════════
   MOBILE BOTTOM NAV
════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none; /* oculto en desktop */
}

@media (max-width: 900px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: var(--color-header-glass-scrolled);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--color-border);
    z-index: var(--z-header);
    align-items: stretch;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.3s ease;
  }
  .mobile-bottom-nav.mbn--hidden {
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
  }

  .mbn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 0 6px;
    transition: color .15s;
    font-family: var(--font);
    border-radius: 0;
    position: relative;
  }

  .mbn-item i {
    font-size: 1.35rem;
    line-height: 1;
    transition: transform .2s;
  }

  .mbn-item:hover i,
  .mbn-item.active i {
    transform: translateY(-1px);
  }

  .mbn-item.active,
  .mbn-item:hover {
    color: var(--color-accent);
  }

  /* Línea activa arriba del item */
  .mbn-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--color-accent);
    border-radius: 0 0 2px 2px;
  }

  /* Wrap para icono + badge relativo */
  .mbn-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Badge de recientes en bottom nav */
  .mbn-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    min-width: 15px;
    height: 15px;
    background: var(--color-accent);
    color: #000;
    font-size: .52rem;
    font-weight: 800;
    border-radius: 99px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
  }
  .mbn-badge:empty { display: none; }
  .mbn-badge--recientes { background: #ef4444; color: #fff; }

  /* Tooltip sobre el ícono de recientes */
  .mbn-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: var(--color-text);
    color: var(--color-bg, #fff);
    font-size: .72rem;
    font-weight: 600;
    padding: 7px 11px;
    border-radius: 9px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    z-index: calc(var(--z-header) + 20);
    width: 180px;
    text-align: center;
    line-height: 1.35;
    white-space: normal;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
  }
  .mbn-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-text);
  }
  .mbn-tooltip--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* Drawer: botón tema como link */
  .drawer-theme-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
  }

  /* Espacio debajo del contenido para no quedar tapado por el nav */
  body {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}

/* ════════════════════════════════════════
   PANEL VISTOS RECIENTEMENTE
════════════════════════════════════════ */
.recientes-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: calc(var(--z-header) + 10);
  opacity: 0;
  transition: opacity .25s ease;
}
.recientes-overlay.active {
  display: block;
  opacity: 1;
}

.recientes-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80dvh;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--color-border);
  z-index: calc(var(--z-header) + 11);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,0,.67,0);
  overflow: hidden;
}
.recientes-panel.open {
  transform: translateY(0);
  transition: transform .3s cubic-bezier(.33,1,.68,1);
}

.recientes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.recientes-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.recientes-sub {
  font-size: .78rem;
  color: var(--color-text-muted);
  margin: 2px 0 0;
}
.recientes-close {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.07);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.recientes-close:hover { background: rgba(255,255,255,.12); color: var(--color-text); }

.recientes-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 calc(env(safe-area-inset-bottom, 0px) + 8px);
  flex: 1;
}

.recientes-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid var(--color-border);
}
.recientes-item:last-child { border-bottom: none; }
.recientes-item:hover { background: rgba(255,255,255,.04); }

.recientes-thumb-wrap {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface-raised, rgba(255,255,255,.06));
  flex-shrink: 0;
}
.recientes-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.recientes-thumb--empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.4rem;
}
.recientes-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.recientes-brand {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-accent);
}
.recientes-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recientes-price {
  font-size: .8rem;
  color: var(--color-text-muted);
}
.recientes-arrow {
  font-size: .75rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.recientes-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 10px;
  text-align: center;
  color: var(--color-text-muted);
}
.recientes-empty i { font-size: 2rem; opacity: .4; }
.recientes-empty p { margin: 0; font-size: .9rem; }
.recientes-empty-hint { font-size: .78rem !important; opacity: .7; }
