/* =========================
   RESPONSIVE - TABLET
   ========================= */
@media (max-width: 1024px) {

  .header-search-wrap {
    max-width: min(560px, 42vw);
  }

  /* Contenido */
  .productos {
    flex-direction: column;
    align-items: center;
  }

  .producto {
    width: 80%;
    margin-bottom: 20px;
  }

  /* Cabecera más compacta */
  .top-bar {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .top-bar h1 {
    font-size: 20px;
    margin: 0;
  }

  /*MENÚ: ocultar barra normal y mostrar hamburguesa */
  nav ul {
    display: none !important;
  }

  .hamburger {
    display: inline-flex;
    margin-right: 0
  }

  nav {
    top: 0;
    box-shadow: none;
  }

  .footer-content {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  /* ========================================================
     🔥 SOLUCIÓN ALTURA HEADER (LOGIN COMPACTO) 🔥
     Forzamos a los inputs a ser de una sola línea y baja altura
     para que no estiren el header más que el texto de usuario.
     ======================================================== */
  
  /* Contenedor del formulario en línea */
  .search-login {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important; /* Obliga a no bajar de línea */
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Inputs (Cajas de texto) Ultra Compactos */
  .search-login input[type="text"],
  .search-login input[type="password"] {
    width: auto !important;
    flex: 1;                 /* Se reparten el espacio disponible */
    min-width: 70px;         /* Ancho mínimo usable */
    height: 28px !important; /* Altura reducida fija (antes era auto/32px) */
    padding: 0 5px !important;
    margin: 0 !important;
    font-size: 12px !important; /* Letra pequeña para que quepa */
    border: 1px solid #ccc !important;
    box-sizing: border-box;
  }

  /* Botón Ingresar Compacto */
  .search-login button {
    height: 28px !important; /* Misma altura que los inputs */
    padding: 0 10px !important;
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 28px !important; /* Centrado vertical exacto */
    white-space: nowrap;
  }

  /* Ocultar enlace de registro para ahorrar espacio */
  .search-login a {
    display: none; 
  }
  
  /* Ajuste al contenedor padre (si existe en tu HTML) para quitar márgenes extra */
  #btn-login {
    margin-top: 4px !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
  }
}

/* =========================
   RESPONSIVE - CELULAR
   ========================= */
@media (max-width: 600px) {

  header {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .top-bar h1 {
    font-size: 18px;
    display: none !important; /* OCULTAR TÍTULO EN MÓVIL PEQUEÑO */
  }

  .header-search-input-wrap .search-results {
    width: calc(100% + 10px) !important;
    max-width: none !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
    top: 100% !important;
    margin-top: 1px !important;
    box-sizing: border-box !important;
    font-size: 12px;
  }

  .producto {
    width: 90%;
  }

  footer {
    font-size: 12px;
  }

  .whatsapp img {
    width: 20px;
    height: 20px;
  }

  .mobile-drawer {
    width: 86vw;
  }

  .drawer-menu li a {
    font-size: 1.05rem;
    padding: 14px 18px;
  }
}

/* =========================
   900px - Contacto
   ========================= */
@media (max-width: 900px) {
  .contacto-contenedor {
    flex-direction: column;
    align-items: stretch;
  }

  .contact-mapa {
    margin-top: 25px;
    min-width: auto;
  }
}

/* 900px - Detalle producto layout */
@media (max-width: 900px) {
  .product-detail-layout {
    flex-direction: column;
  }

  .product-sidebar {
    width: 100%;
  }
}

/* 768px - Detalle producto card (ESTILO CUADRADO PERFECTO) */
@media (max-width: 768px) {

  /* 1. Contenedor Principal */
  .product-detail-card {
    display: flex;
    flex-direction: column;
    gap: 10px; 
    margin: 0;
    padding: 0;
  }

  /* 2. El Marco de la Foto (EL CUADRADO) */
  .product-detail-img-wrapper {
    width: 100% !important;       
    aspect-ratio: 1 / 1;          
    overflow: hidden;             
    position: relative;
    background: #ffffff;          
    margin: 0;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
  }

  /* 3. La Imagen */
  .product-detail-img-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain; 
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
    will-change: transform; 
  }

  /* 4. Efecto ZOOM al mantener presionado */
  .product-detail-img-wrapper:active img {
    transform: scale(1.8); 
    cursor: zoom-in;
  }

  /* 5. Información del producto (Texto) */
  .product-detail-info {
    width: 100%;
    padding: 0 15px; 
    box-sizing: border-box;
  }
}

/* 768px - Registro */
@media (max-width: 768px) {
  .register-card {
    padding: 18px 15px 22px;
  }

  .register-form .form-grid {
    flex-direction: column;
  }
}

/* 768px - Grids productos home y catálogo: 2 columnas (ver catalogo.css) */

/* ==========================
   MENÚ RESPONSIVE: ocultar nav desktop y usar drawer
   ========================== */
@media (max-width: 1024px) {
  nav ul {
    display: none !important;
  }

  .hamburger {
    display: inline-flex;
  }

  .header-actions-logged {
    display: none !important;
  }

  #user-greeting {
    display: none !important;
  }

  #btn-login {
    display: none !important; 
  }
  
  /* Aseguramos que el login-form (inputs) SI se muestre */
  div#btn-login {
      display: flex !important; 
  }

  .top-bar {
    align-items: center !important;
    justify-content: flex-start;
    text-align: left;
  }
}


/* =========================
   CELULAR: Nueva Distribución Header
   Orden: Logo -> Buscar -> Carrito -> Menú
   ========================= */
@media (max-width: 1024px) {

  header {
    padding: 10px 15px;
  }

  .top-bar {
    display: grid !important;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 8px;
    position: relative;
  }

  .top-left {
    display: flex;
    align-items: center;
    gap: 10px;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .top-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    grid-column: 2 / 5;
    grid-row: 1;
    justify-self: end;
  }

  /* Logo centrado horizontalmente en la primera fila del header */
  .logo-link {
    display: flex;
    align-items: center;
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    height: 36px; /* misma altura que la hamburguesa (fila 1) */
  }

  .logo-img {
    height: 35px; 
    width: auto;
  }

  .header-search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  .header-search-pill {
    min-height: 36px;
  }

  .header-search-categoria {
    flex: 0 0 38%;
    width: 38%;
    max-width: 38%;
    min-width: 100px;
    font-size: 0.8rem;
  }

  .btn-cart-header-pill {
    padding: 3px 6px 3px 10px;
    min-height: 36px;
    font-size: 0.8rem;
  }

  .btn-cart-header-pill .cart-header-icon {
    font-size: 1rem;
  }

  /* Carrito: importe en barra inferior, no en cabecera */
  .top-right .btn-cart-header-pill {
    display: none !important;
  }

  body.has-cart-mobile-bar {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body.has-cart-mobile-bar .whatsapp-float {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  body.has-cart-mobile-bar .btn-scroll-top {
    bottom: calc(158px + env(safe-area-inset-bottom, 0px));
  }

  /* Cuando NO hay sesión iniciada, los hijos de .header-auth-buttons
     (#btn-login y .btn-outline-header) se ocultan en móvil. Ocultamos
     también el contenedor vacío y el saludo vacío para que no generen
     filas fantasmas en el grid que descentran la fila del logotipo. */
  .header-auth-buttons {
    display: none !important;
  }

  #user-greeting:empty {
    display: none !important;
  }
}

/* =========================
   RESPONSIVE PREVIO PEDIDO (Móvil < 900px)
   ========================= */
@media (max-width: 900px) {
  .checkout-layout {
    flex-direction: column;
    gap: 20px;
  }

  .checkout-summary,
  .checkout-sidebar {
    width: 100%;
    position: static;
  }

  .checkout-sidebar {
    order: 2;
  }

  .cart-summary-box {
    overflow-x: auto;
  }
}

/* RESPONSIVE CONTACTO*/
@media (max-width: 900px) {
  .contacto-grid {
    grid-template-columns: 1fr;
  }
  #mapa-tiendas {
    min-height: 300px; 
    margin-top: 30px;  
  }
  .form-row-responsive {
    flex-direction: column;
    gap: 0;
  }
}

/* --- Arreglo para DNI/Celular Responsive --- */
.form-row-responsive {
  display: flex;
  gap: 15px;
}

/* En celulares, cambiar la dirección a columna */
@media (max-width: 600px) {
  .form-row-responsive {
    flex-direction: column;
    gap: 0; 
  }
}

/* =========================================
   MEJORA CAPTCHA PARA CELULAR
   ========================================= */

@media (max-width: 600px) {
  
  .captcha-group .captcha-box {
    flex-wrap: wrap; 
  }

  .captcha-box img {
    flex: 1; 
  }

  .captcha-box input {
    flex: 1 1 100%;
    margin-top: 10px;
    height: 45px;
    font-size: 1.2rem;
    padding: 10px;
  }
}

@media (max-width: 1024px) {
  .btn-outline-header {
    display: none !important;
  }
}

/* =========================
   LOGIN RESPONSIVE (Móvil)
   ========================= */
@media (max-width: 768px) {
  main.auth-page {
    overflow-x: hidden;
  }

  .incorporacion-wrapper {
    flex-direction: column !important;
    min-height: auto !important;
  }

  .incorporacion-form-side {
    flex: 0 0 100% !important;
    width: 100% !important;
    padding: 24px 16px !important;
    box-sizing: border-box !important;
  }

  .incorporacion-form-container {
    max-width: 100% !important;
    width: 100% !important;
  }

  .incorporacion-visual {
    display: none !important;
  }
}