/* ============================================================
   header.css — estilos del header, drawer lateral y buscador,
   compartidos por TODAS las páginas del sitio (index, catalogo,
   checkout, producto/*.html).

   Requiere que la página ya defina las variables de color
   (--bg, --texto, --linea, --azul, --ember, --whatsapp, etc.)
   en su propio :root — igual que ya lo hace producto.css.
   ============================================================ */

/* ---------- Header ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--linea);
}

html[data-tema="oscuro"] header { background: rgba(11, 12, 30, 0.92); }

.header-fila {
  padding: 12px 20px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "izq der"
    "buscador buscador";
  align-items: center;
  row-gap: 10px;
  column-gap: 12px;
}

@media (min-width: 780px) {
  .header-fila {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "izq buscador der";
    row-gap: 0;
  }
}

.header-izquierda { grid-area: izq; display: flex; align-items: center; gap: 10px; }
.contenedor-buscador { grid-area: buscador; }
.header-derecha { grid-area: der; justify-self: end; display: flex; align-items: center; gap: 8px; }

.logo-chip { background: #fff; padding: 6px 12px; border-radius: 10px; display: flex; align-items: center; }
.logo-chip img { height: 30px; }

.btn-hamburguesa {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-elevada); border: 1px solid var(--linea); color: var(--texto);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}

.btn-tema, .btn-carrito {
  width: 40px; height: 40px; border-radius: 50%; position: relative;
  background: var(--bg-elevada); border: 1px solid var(--linea); color: var(--texto);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-tema svg, .btn-carrito svg { width: 18px; height: 18px; }

.icono-luna { display: none; }
html[data-tema="claro"] .icono-luna { display: block; }
html[data-tema="claro"] .icono-sol { display: none; }

.badge-carrito {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--ember); color: var(--texto-sobre-ember);
  font-family: 'IBM Plex Mono', monospace; font-size: 0.65rem; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}

.btn-nav-whatsapp {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--whatsapp); display: flex; align-items: center; justify-content: center;
}
.btn-nav-whatsapp svg { width: 19px; height: 19px; fill: #0d1f13; }

/* ---------- Buscador del header ---------- */

.buscador-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevada);
  border: 1px solid var(--linea);
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
  max-width: 860px;
  margin: 0 auto;
}

.buscador-header svg { flex-shrink: 0; opacity: 0.55; width: 17px; height: 17px; }

.buscador-header input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--texto); font-family: 'Inter', sans-serif; font-size: 0.88rem; padding: 9px 0;
}
.buscador-header input::placeholder { color: var(--texto-muted); }

.buscador-header button {
  background: var(--azul); color: var(--texto-sobre-azul); border: none;
  border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 0.82rem; cursor: pointer; flex-shrink: 0;
}
.buscador-header button:hover { background: var(--azul-hover); }

.contenedor-buscador { position: relative; max-width: 860px; margin: 0 auto; width: 100%; }

.resultados-busqueda {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-elevada);
  border: 1px solid var(--linea);
  border-radius: 14px;
  box-shadow: 0 12px 32px var(--sombra);
  overflow: hidden;
  z-index: 50;
  max-height: 70vh;
  overflow-y: auto;
}
.resultados-busqueda.abierto { display: block; }

.resultado-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--linea); cursor: pointer; }
.resultado-item:last-child { border-bottom: none; }
.resultado-item:hover, .resultado-item.resaltado { background: var(--bg-elevada-hover); }

.resultado-img { width: 46px; height: 46px; flex-shrink: 0; background: var(--bg); border-radius: 9px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.resultado-img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.resultado-img .sin-foto { font-size: 0.55rem; color: var(--texto-muted); font-family: 'IBM Plex Mono', monospace; }

.resultado-info { flex: 1; min-width: 0; }
.resultado-nombre { font-size: 0.85rem; font-weight: 500; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 0 3px; }
.resultado-meta { display: flex; align-items: center; gap: 8px; }
.resultado-precio { font-family: 'Big Shoulders Display', sans-serif; font-weight: 800; font-size: 0.98rem; color: var(--azul); }
.resultado-categoria { font-family: 'IBM Plex Mono', monospace; font-size: 0.65rem; color: var(--texto-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.resultado-badge-oferta { font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; font-weight: 700; color: var(--texto-sobre-ember); background: var(--ember); padding: 2px 6px; border-radius: 5px; text-transform: uppercase; }

.resultado-ver-todos { display: block; text-align: center; padding: 12px; font-size: 0.85rem; font-weight: 600; color: var(--azul); background: var(--bg-elevada-hover); }
.resultado-ver-todos:hover { text-decoration: underline; }

.resultado-estado { padding: 18px 14px; text-align: center; font-size: 0.85rem; color: var(--texto-muted); }

/* ---------- Drawer lateral (menú) ---------- */

.fondo-drawer { display: none; position: fixed; inset: 0; background: rgba(10,8,6,0.6); z-index: 40; }
.fondo-drawer.abierto { display: block; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 82%; max-width: 320px;
  background: var(--bg-elevada); border-right: 1px solid var(--linea); z-index: 41;
  transform: translateX(-100%); transition: transform .25s ease; overflow-y: auto; padding: 18px;
}
.drawer.abierto { transform: translateX(0); }

.btn-cerrar-drawer { width: 32px; height: 32px; border-radius: 50%; background: var(--bg); border: 1px solid var(--linea); color: var(--texto); cursor: pointer; }

.drawer-seccion-titulo { font-family: 'IBM Plex Mono', monospace; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-muted); margin: 18px 0 8px; }
.drawer-link { display: block; padding: 11px 10px; border-radius: 9px; font-weight: 600; font-size: .92rem; }
.drawer-link:hover { background: var(--bg-elevada-hover); }

.drawer-cat-buscador {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg); border: 1px solid var(--linea); border-radius: 9px;
  padding: 3px 3px 3px 10px; margin-bottom: 4px;
}
.drawer-cat-buscador svg { flex-shrink: 0; opacity: 0.55; width: 15px; height: 15px; }
.drawer-cat-buscador input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--texto); font-family: 'Inter', sans-serif; font-size: .86rem; padding: 8px 0;
}
.drawer-cat-buscador input::placeholder { color: var(--texto-muted); }

.drawer-cat-resultado-lista {
  display: flex; flex-direction: column; max-height: 360px; overflow-y: auto;
  border-top: 1px solid var(--linea); margin-top: 8px; padding-top: 4px;
}

.drawer-cat-split {
  display: flex; height: 360px; border-top: 1px solid var(--linea); margin-top: 8px;
}

.drawer-cat-col-izq {
  width: 40%; overflow-y: auto; border-right: 1px solid var(--linea);
  padding-right: 4px; display: flex; flex-direction: column; gap: 1px;
}
.drawer-cat-item {
  width: 100%; text-align: left; background: none; border: none; border-radius: 7px;
  color: var(--texto-muted); font-size: .82rem; font-weight: 500; line-height: 1.35;
  padding: 9px 6px; cursor: pointer;
}
.drawer-cat-item:hover { background: var(--bg-elevada-hover); }
.drawer-cat-item.activo { background: var(--bg-elevada-hover); color: var(--azul); font-weight: 700; }

.drawer-cat-col-der { width: 60%; overflow-y: auto; padding-left: 10px; display: flex; flex-direction: column; }
.drawer-cat-vacio { padding: 14px 6px; color: var(--texto-muted); font-size: .8rem; }
.drawer-cat-ver-todo { padding: 8px 6px; font-size: .86rem; font-weight: 700; color: var(--azul); }
.drawer-cat-ver-todo:hover { text-decoration: underline; }
.drawer-cat-sub { display: flex; justify-content: space-between; gap: 8px; padding: 8px 6px; font-size: .86rem; color: var(--texto-muted); }
.drawer-cat-sub:hover { color: var(--ember); }
.cat-cantidad { font-family: 'IBM Plex Mono', monospace; font-size: .67rem; color: var(--texto-muted); flex-shrink: 0; }

.drawer-redes { display: flex; gap: 10px; margin-top: 20px; padding-top: 18px; }
.drawer-redes a { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); border: 1px solid var(--linea); display: flex; align-items: center; justify-content: center; }
.drawer-redes svg { width: 17px; height: 17px; }

/* ============================================================
   En pantallas anchas hay más espacio disponible: el drawer y
   el panel de categorías crecen para que los nombres largos
   ("Baterías, Pilas y Accesorios") no se corten en 2-3 líneas.
   ============================================================ */
@media (min-width: 780px) {
  .drawer { max-width: 460px; padding: 24px; }
  .drawer-cat-split { height: calc(100vh - 320px); min-height: 420px; max-height: 640px; }
  .drawer-cat-col-izq { width: 42%; }
  .drawer-cat-col-der { width: 58%; }
  .drawer-cat-item { font-size: .97rem; padding: 12px 10px; }
  .drawer-cat-sub, .drawer-cat-ver-todo { font-size: 1rem; padding: 11px 10px; }
  .cat-cantidad { font-size: .74rem; }
}

@media (min-width: 1100px) {
  .drawer { max-width: 540px; }
  .drawer-cat-split { max-height: 760px; }
}
