/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    /* ============================================================
       NAVBAR RESPONSIVE - MÓVIL
       ============================================================ */
    .navbar {
        flex-wrap: wrap;
        padding: 0.6rem 1rem;
        gap: 0.5rem;
        height: auto;
        min-height: 60px;
        align-items: center;
        position: fixed;
    }

    /* Fila 1: hamburguesa */
    .hamburger {
        font-size: 1.4rem;
        padding: 0.4rem 0.6rem;
        order: 1;
    }

    /* Fila 1: logo */
    .logo {
        font-size: 1rem;
        flex: 1;
        text-align: center;
        order: 2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Fila 1: carrito */
    .carrito-btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
        order: 3;
        white-space: nowrap;
    }

    /* Fila 2: buscador ocupa todo el ancho */
    .search-bar {
        order: 4;
        flex: 0 0 100%;
        max-width: 100%;
        margin: 0;
        width: 100%;
    }

    .search-bar input {
        font-size: 16px !important; /* evita zoom automático en iOS */
        padding: 0.7rem 1rem;
        border-radius: 25px 0 0 25px;
    }

    .search-bar button {
        padding: 0.7rem 1rem;
    }

    /* ============================================================
       SIDEBAR
       ============================================================ */
    .sidebar.open {
        width: 280px;
    }

    /* ============================================================
       CARRITO
       ============================================================ */
    .carrito.open {
        width: 100%;
    }

    .carrito-footer {
        padding: 1rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }

    .carrito-header {
        padding: 0.8rem 1rem;
    }

    .carrito-header h2 {
        font-size: 1.1rem;
    }

    /* ============================================================
       CONTENIDO PRINCIPAL
       ============================================================ */
    .main-content {
        margin-top: 110px; /* más alto porque el navbar ahora tiene 2 filas */
        padding: 1rem;
    }

    /* ============================================================
       CARRUSEL
       ============================================================ */
    .carrusel-grande {
        height: 300px;
    }

    .carrusel-text h2 {
        font-size: 1.5rem;
    }

    .carrusel-text p {
        font-size: 1rem;
    }

    /* ============================================================
       FILTROS
       ============================================================ */
    .filtros-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ============================================================
       PRODUCTOS - HEADER
       NOTA: el grid (.productos-grid) se maneja en productos.css
       ============================================================ */
    .productos-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    /* ============================================================
       CARRITO - ESTADO
       ============================================================ */
    .carrito-estado {
        padding: 0.8rem;
    }

    .estado-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .estado-editar {
        align-self: flex-end;
    }

    /* ============================================================
       FOOTER
       ============================================================ */
    .footer-content {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
}

/* ============================================================
   MÓVILES PEQUEÑOS (hasta 480px)
   ============================================================ */
@media (max-width: 480px) {
    /* Navbar aún más compacto */
    .navbar {
        padding: 0.5rem 0.7rem;
    }

    .hamburger {
        font-size: 1.2rem;
        padding: 0.3rem 0.5rem;
    }

    .logo {
        font-size: 0.9rem;
    }

    .carrito-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .search-bar input {
        padding: 0.6rem 0.9rem;
    }

    .search-bar button {
        padding: 0.6rem 0.9rem;
    }

    /* Ajustar margen del contenido por si el navbar cambia de alto */
    .main-content {
        margin-top: 105px;
    }
}

/* ============================================================
   RESULTADOS DE BÚSQUEDA - Evitar saltos mientras cargan imágenes
   NOTA: el precio (.resultado-precio) se maneja en productos.css
   ============================================================ */

/* El contenedor del dropdown */
#resultados-busqueda {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1500;
    min-height: 60px;
}

/* Cada resultado con altura mínima fija */
.resultado-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
    min-height: 70px;
    transition: background 0.2s;
}

.resultado-item:hover {
    background: #f5f5f5;
}

/* Imagen del resultado: tamaño FIJO siempre */
.resultado-imagen {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resultado-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Texto del resultado */
.resultado-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.resultado-nombre {
    font-weight: 600;
    font-size: 0.9rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resultado-categoria {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
}

/* ============================================================
   EVITAR ZOOM AL TOCAR RÁPIDO (doble tap) EN MÓVIL
   ============================================================ */
button,
.btn-agregar,
.btn-cantidad,
.btn-cantidad-detalle,
.surtida-btn,
.btn-continuar,
.btn-whatsapp,
.btn-volver,
.estado-editar,
.categoria-btn,
a,
select,
input[type="checkbox"],
input[type="radio"] {
    touch-action: manipulation;
}

/* Evitar selección accidental de texto al tocar rápido */
.btn-cantidad,
.btn-cantidad-detalle,
.surtida-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}