/* --- Base --------------------------------------------------------------- */
:root {
    --primario: #0f766e;
    --primario-oscuro: #0b5d57;
    --primario-suave: #e6f4f2;
    --texto: #111827;
    --texto-suave: #6b7280;
    --borde: #e7e9ee;
    --fondo: #f6f7f9;
    --tarjeta: #ffffff;
    --acento: #f59e0b;
    --sombra-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --sombra-md: 0 8px 24px rgba(16, 24, 40, 0.08);
    --radio: 16px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    -webkit-font-smoothing: antialiased;
    line-height: 1.45;
}
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { color: var(--primario); }

/* --- Barra superior ----------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px max(16px, calc((100% - 1120px) / 2));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--borde);
}
.topbar .marca {
    display: flex; align-items: center; gap: 10px;
    color: var(--texto); text-decoration: none; font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em;
}
/* El dibujo del logo está en logo.css (.logo-sofi) */
.marca-icono { width: 32px; height: 32px; }
.carrito-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: #fff; background: var(--primario); text-decoration: none; font-weight: 600;
    padding: 9px 16px; border-radius: 999px; transition: background 0.15s;
}
.carrito-link:hover { background: var(--primario-oscuro); }
.burbuja {
    background: #fff; color: var(--primario); border-radius: 999px;
    padding: 0 8px; font-size: 0.78rem; font-weight: 700; min-width: 22px; text-align: center;
}

.contenedor { max-width: 1120px; margin: 0 auto; padding: 24px 16px 72px; }
.subtitulo { color: var(--texto-suave); margin: 0 0 8px; }
.volver {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--primario); text-decoration: none; font-weight: 600; font-size: 0.9rem;
}
.volver:hover { text-decoration: underline; }
.vacio {
    color: var(--texto-suave); margin-top: 24px; padding: 40px 20px; text-align: center;
    background: var(--tarjeta); border: 1px dashed var(--borde); border-radius: var(--radio);
}

/* --- Mensajes ----------------------------------------------------------- */
.mensajes { list-style: none; padding: 0; margin: 0 0 12px; }
.mensaje { padding: 12px 16px; border-radius: 12px; margin-bottom: 10px; font-weight: 500; }
.mensaje.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.mensaje.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.mensaje.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.aviso { background: #eff6ff; color: #1e40af; padding: 12px 16px; border-radius: 12px; border: 1px solid #bfdbfe; }

/* --- Categorías --------------------------------------------------------- */
.grid-categorias {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px; margin-top: 24px;
}
.tarjeta-categoria {
    background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
    padding: 28px 12px; text-align: center; cursor: pointer; font: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    box-shadow: var(--sombra-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
}
.tarjeta-categoria:hover { transform: translateY(-3px); box-shadow: var(--sombra-md); border-color: #b7e0db; }
.tarjeta-categoria .icono {
    font-size: 2rem; width: 64px; height: 64px; display: grid; place-items: center;
    background: var(--primario-suave); border-radius: 18px;
}
.tarjeta-categoria .etiqueta { font-weight: 600; }
.estado-ubicacion { margin-top: 20px; color: var(--primario); font-weight: 600; }

/* --- Negocio ------------------------------------------------------------ */
.negocio {
    background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 20px;
    padding: 20px; margin-top: 20px; box-shadow: var(--sombra-sm);
}
.negocio-cabecera, .encabezado-negocio {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.negocio-identidad { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.avatar-negocio {
    flex: 0 0 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
    background: linear-gradient(135deg, #ccfbf1, #99f6e4); color: var(--primario-oscuro);
    font-weight: 800; font-size: 1.4rem; text-transform: uppercase;
}
.detalle-negocio { color: var(--texto-suave); margin: 4px 0 0; font-size: 0.9rem; }
.abierto, .cerrado { font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.abierto { color: #15803d; }
.cerrado { color: #b91c1c; }
.abierto::before, .cerrado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.opciones-entrega { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip {
    background: var(--primario-suave); color: #065f46; border-radius: 999px;
    padding: 4px 11px; font-size: 0.78rem; font-weight: 600;
}
.chip.suave { background: #f3f4f6; color: #4b5563; font-weight: 500; }

.boton-secundario {
    display: inline-flex; align-items: center; border: 1.5px solid var(--primario); color: var(--primario);
    text-decoration: none; padding: 8px 16px; border-radius: 999px; font-weight: 600;
    white-space: nowrap; font-size: 0.9rem; transition: background 0.15s, color 0.15s;
}
.boton-secundario:hover { background: var(--primario); color: #fff; }
.boton-carrito {
    background: var(--primario); color: #fff; text-decoration: none;
    padding: 10px 16px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.boton-texto { background: none; border: none; color: var(--primario); font-weight: 600; cursor: pointer; padding: 4px; font: inherit; }
.boton-texto:hover { text-decoration: underline; }

/* --- Carrusel horizontal ----------------------------------------------- */
.carrusel-marco { position: relative; margin-top: 18px; }
.carrusel {
    display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px;
    scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.carrusel::-webkit-scrollbar { height: 6px; }
.carrusel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.carrusel .producto { flex: 0 0 196px; scroll-snap-align: start; }
.carrusel .producto-nombre { display: block; -webkit-line-clamp: unset; overflow: visible; overflow-wrap: anywhere; }
.carrusel-flecha {
    position: absolute; top: 38%; z-index: 2; width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid var(--borde); background: #fff; color: var(--texto);
    font-size: 1.5rem; line-height: 1; cursor: pointer; box-shadow: var(--sombra-md);
    display: grid; place-items: center; padding-bottom: 3px;
}
.carrusel-flecha:hover { background: var(--primario); color: #fff; border-color: var(--primario); }
.carrusel-flecha[hidden] { display: none; }
.carrusel-flecha.izq { left: -14px; }
.carrusel-flecha.der { right: -14px; }

.grid-productos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
/* Tienda: foto a la izquierda, datos y botón a la derecha */
.grid-productos .producto {
    display: grid; grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: 1fr auto;
    column-gap: 18px; row-gap: 12px; align-items: start; padding: 14px;
}
.grid-productos .producto-imagen { grid-row: 1 / 3; aspect-ratio: 1; align-self: center; }
.grid-productos .producto-info { grid-column: 2; }
.grid-productos .form-agregar { grid-column: 2; }
@media (max-width: 900px) {
    .grid-productos .producto { grid-template-columns: 150px minmax(0, 1fr); }
}

/* --- Tarjeta de producto ----------------------------------------------- */
.producto {
    background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
    padding: 10px; display: flex; flex-direction: column; gap: 10px;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s;
}
.producto:hover { box-shadow: var(--sombra-md); transform: translateY(-2px); border-color: #d6dae1; }
.producto-imagen {
    position: relative; aspect-ratio: 1; border-radius: 12px; background: #f8fafc;
    display: grid; place-items: center; overflow: hidden;
}
.producto-imagen img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.producto-imagen img { cursor: zoom-in; }

/* Visor de foto en grande */
.visor-foto {
    border: none; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh;
    width: 100vw; height: 100vh; margin: 0; overflow: hidden;
}
.visor-foto[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.visor-foto::backdrop { background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(2px); }
.visor-foto img {
    max-width: min(92vw, 900px); max-height: 78vh; object-fit: contain;
    background: #fff; border-radius: 16px; padding: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.visor-titulo { margin: 0; color: #fff; font-weight: 600; text-align: center; padding: 0 20px; max-width: 900px; }
.visor-cerrar {
    position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 1.3rem; cursor: pointer;
}
.visor-cerrar:hover { background: rgba(255, 255, 255, 0.3); }

.producto-placeholder { display: none; font-size: 2.6rem; opacity: 0.45; }
.producto-imagen.sin-imagen { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }
.producto-imagen.sin-imagen .producto-placeholder { display: block; }
.badge-promo {
    position: absolute; top: 8px; left: 8px; background: var(--acento); color: #fff;
    font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase;
}
.producto-info { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.producto-fab {
    margin: 0; font-size: 0.7rem; color: var(--texto-suave); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.producto-nombre {
    font-weight: 600; margin: 0; font-size: 0.88rem; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 2.6em;
}
.producto-precio { margin: 6px 0 0; color: var(--texto); font-weight: 800; font-size: 1.1rem; letter-spacing: -0.01em; }
.promo { margin: 2px 0 0; font-size: 0.76rem; color: #b45309; font-weight: 600; }
.promo.suave { color: #92400e; font-weight: 500; }
.etiqueta-tienda {
    display: inline-block; align-self: flex-start; margin: 4px 0 0; font-size: 0.7rem;
    background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 6px; font-weight: 600;
}

.form-agregar { display: flex; gap: 6px; align-items: stretch; }
.form-agregar input[type=number] {
    width: 54px; padding: 8px 6px; border-radius: 10px; border: 1px solid #d1d5db;
    font: inherit; text-align: center;
}
.form-agregar button {
    flex: 1; padding: 9px 12px; border-radius: 10px; border: none; cursor: pointer;
    background: var(--primario); color: #fff; font: inherit; font-weight: 600; font-size: 0.88rem;
    transition: background 0.15s;
}
.form-agregar button:hover { background: var(--primario-oscuro); }

/* --- Tienda: logo, buscador y paginación ------------------------------- */
.tienda-cabecera { align-items: center; }
.logo-tienda {
    flex: 0 0 140px; height: 140px; border-radius: 24px; overflow: hidden;
    background: #fff; border: 1px solid var(--borde); box-shadow: var(--sombra-md);
    display: grid; place-items: center;
}
.logo-tienda img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.logo-tienda span { display: none; }
.logo-tienda.sin-logo { background: linear-gradient(135deg, #ccfbf1, #99f6e4); border-color: #99f6e4; }
.logo-tienda.sin-logo span {
    display: block; font-size: 4rem; font-weight: 800; color: var(--primario-oscuro); text-transform: uppercase;
}

.buscador { display: flex; gap: 8px; margin: 20px 0; }
.buscador input {
    flex: 1; padding: 12px 16px; border-radius: 12px; border: 1px solid #d1d5db;
    font: inherit; background: #fff;
}
.buscador input:focus, .form-entrega input:focus, .entrega select:focus, .form-agregar input:focus {
    outline: none; border-color: var(--primario); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.buscador button {
    padding: 12px 20px; border-radius: 12px; border: none; background: var(--texto);
    color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.paginas { display: flex; justify-content: space-between; margin-top: 24px; }
.paginas a { color: var(--primario); font-weight: 600; text-decoration: none; }

/* --- Inventario (lista) ------------------------------------------------- */
.lista-items { display: flex; flex-direction: column; gap: 12px; }
.item-card {
    background: #fff; border-radius: 14px; padding: 14px 16px; border: 1px solid var(--borde);
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.item-nombre { font-weight: 600; margin: 0; }
.item-precio { margin: 2px 0; color: var(--primario); font-weight: 700; }
.item-existencia { margin: 0; font-size: 0.85rem; color: var(--texto-suave); }

/* --- Carrito ------------------------------------------------------------ */
.lista-carrito { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.fila-carrito { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f1f2f4; }
.fila-carrito img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #f8fafc; }
.fila-info { flex: 1; min-width: 0; }
.fila-info .detalle-negocio { margin: 2px 0 0; font-size: 0.85rem; }
.fila-info .producto-nombre { min-height: 0; }
.form-cantidad { display: flex; align-items: center; gap: 2px; }
.form-cantidad input { width: 56px; padding: 7px; border-radius: 8px; border: 1px solid #d1d5db; font: inherit; text-align: center; }
.fila-valor { font-weight: 700; min-width: 80px; text-align: right; }
.subtotal { text-align: right; font-weight: 600; margin: 12px 0 0; }
.total-carrito { text-align: right; font-weight: 800; font-size: 1.2rem; margin-top: 12px; }
.entrega {
    border: 1px solid var(--borde); border-radius: 14px; margin-top: 14px; padding: 12px 16px;
    display: flex; flex-direction: column; gap: 10px; background: #fafbfc;
}
.entrega legend { font-weight: 700; padding: 0 6px; }
.entrega label { display: flex; align-items: center; gap: 8px; }
.entrega input[type=radio] { accent-color: var(--primario); width: 18px; height: 18px; }
.entrega .campo { flex-direction: column; align-items: stretch; gap: 4px; font-size: 0.9rem; }
.entrega select { padding: 10px; border-radius: 10px; border: 1px solid #d1d5db; font: inherit; background: #fff; }

.form-entrega {
    display: flex; flex-direction: column; gap: 14px; margin-top: 24px;
    background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 20px; padding: 20px;
}
.form-entrega h2 { margin-top: 0; }
.form-entrega label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 500; color: #374151; }
.form-entrega input { padding: 12px 14px; border-radius: 10px; border: 1px solid #d1d5db; font: inherit; }
.boton-confirmar {
    padding: 14px; border-radius: 999px; border: none; background: var(--primario); color: #fff;
    font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; transition: background 0.15s;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25);
}
.boton-confirmar:hover { background: var(--primario-oscuro); }
.boton-confirmar:disabled { opacity: 0.6; cursor: wait; }

/* Carrito y confirmación dentro del ancho de lectura */
.grupo-carrito, .form-entrega, .confirmacion { max-width: 760px; margin-left: auto; margin-right: auto; }
.confirmacion { text-align: center; margin-top: 48px; }
.confirmacion .negocio { text-align: left; }

/* --- Estado de pedidos -------------------------------------------------- */
.topbar-acciones { display: flex; align-items: center; gap: 8px; }
.mis-pedidos-link {
    color: var(--texto); text-decoration: none; font-weight: 600;
    padding: 9px 14px; border-radius: 999px; transition: background 0.15s;
}
.mis-pedidos-link:hover { background: #f1f5f4; }
.pagina-estrecha { max-width: 760px; margin: 0 auto; }
.estado-cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.estado-cabecera h1 { margin: 2px 0; }
.estado-cabecera .detalle-negocio:first-child { margin: 0; font-weight: 600; }

.pasos { list-style: none; display: flex; padding: 0; margin: 22px 0 6px; }
.paso { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.paso:not(:first-child)::before {
    content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 3px;
    background: var(--borde); z-index: 0;
}
.paso.hecho:not(:first-child)::before { background: var(--primario); }
.paso-punto {
    position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
    background: #fff; border: 2px solid var(--borde); color: var(--texto-suave);
}
.paso.hecho .paso-punto { background: var(--primario); border-color: var(--primario); color: #fff; }
.paso.actual .paso-punto { box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.18); }
.paso-etiqueta { font-size: 0.8rem; color: var(--texto-suave); font-weight: 500; }
.paso.hecho .paso-etiqueta { color: var(--texto); }
.paso.actual .paso-etiqueta { color: var(--primario); font-weight: 700; }

.estado-mensaje {
    margin: 16px 0 0; padding: 12px 16px; border-radius: 12px;
    background: var(--primario-suave); color: #065f46; font-weight: 500;
}
.estado-mensaje.cancelado, .estado-cancelado { background: #fef2f2; color: #991b1b; }
.estado-cancelado { margin-top: 18px; padding: 10px 14px; border-radius: 12px; font-weight: 700; }
.chip-cancelado { background: #fef2f2; color: #991b1b; }

.acciones-contacto { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.boton-whatsapp {
    display: inline-flex; align-items: center; background: #25d366; color: #fff; text-decoration: none;
    padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
}
.boton-whatsapp:hover { background: #1ebe5b; }
.acciones-contacto .boton-secundario { margin-top: 0; }

.lista-detalle { margin-top: 12px; }
.linea-detalle { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1f2f4; }
.linea-detalle.suave { color: var(--texto-suave); font-size: 0.9rem; }
.linea-detalle.total { border-bottom: none; font-weight: 800; font-size: 1.1rem; padding-top: 12px; }
.nota-enlace { text-align: center; margin-top: 18px; }

.tarjeta-pedido { display: block; color: inherit; text-decoration: none; transition: box-shadow 0.15s, border-color 0.15s; }
.tarjeta-pedido:hover { box-shadow: var(--sombra-md); border-color: #b7e0db; }
.tarjeta-pedido .pasos { margin-bottom: 0; }
.acciones-confirmacion { display: flex; justify-content: center; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 22px; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
    h1 { font-size: 1.45rem; }
    .negocio { padding: 16px; border-radius: 16px; }
    .negocio-cabecera { flex-direction: column; }
    .negocio-cabecera .boton-secundario { align-self: stretch; justify-content: center; }
    .tienda-cabecera { flex-direction: row; align-items: flex-start; }
    .mis-pedidos-link { padding: 9px 8px; font-size: 0.9rem; }
    .carrito-link { padding: 9px 12px; font-size: 0.9rem; }
    .topbar .marca { font-size: 1rem; }
    .paso-etiqueta { font-size: 0.7rem; }
    .estado-cabecera { flex-direction: column; }
    .logo-tienda { flex-basis: 80px; height: 80px; border-radius: 16px; }
    .logo-tienda.sin-logo span { font-size: 2.4rem; }
    .carrusel .producto { flex-basis: 160px; }
    .carrusel-flecha { display: none; }
    .grid-productos { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .grid-productos .producto { grid-template-columns: 130px minmax(0, 1fr); column-gap: 14px; padding: 12px; }
    .grid-categorias { grid-template-columns: repeat(2, 1fr); }
    .fila-carrito { flex-wrap: wrap; }
    .fila-info { flex-basis: calc(100% - 70px); }
    .form-cantidad { margin-left: 68px; }
    .fila-valor { margin-left: auto; }
}

/* Aviso de privacidad y autorización (Ley 1581) */
.aviso-datos { font-size: 0.8rem; color: var(--texto-suave); margin: 4px 0 0; }
.form-entrega label.autoriza { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.form-entrega label.autoriza input { width: 20px; height: 20px; padding: 0; margin-top: 2px; flex-shrink: 0; accent-color: #0f766e; }
.autoriza a, .pie a { color: #0f766e; }
.pie { text-align: center; font-size: 0.8rem; color: var(--texto-suave); padding: 24px 16px 32px; }
.politica { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.politica h2 { font-size: 1.1rem; margin-top: 28px; }

/* Producto sin foto en el carrito */
.fila-carrito .sin-foto { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; background: #eef0f3; border-radius: 10px; font-size: 1.4rem; flex-shrink: 0; }
