/*
 * Mi Tienda — estilos de mitienda.do.
 *
 * Propios y pequeños, sin CDN: la tienda se abre sobre todo en el móvil, desde
 * un enlace de WhatsApp, y tiene que cargar rápido con datos. --marca es el
 * color de cada tienda (la página lo cambia en línea); el resto es neutro.
 */
:root {
    --marca: #0f766e;
    --marca-texto: #ffffff;
    --tinta: #1c1917;
    --tinta-suave: #57534e;
    --tinta-tenue: #a8a29e;
    --fondo: #ffffff;
    --fondo-suave: #f5f5f4;
    --borde: #e7e5e4;
    --radio: 12px;
    --ancho: 1080px;
    --letra: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--letra);
    font-size: 16px;
    line-height: 1.5;
    color: var(--tinta);
    background: var(--fondo);
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
p { margin: 0; }

/* --- Piezas comunes --------------------------------------------------- */

.marca {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    color: var(--tinta);
}
.marca span { color: var(--marca); }

.barra {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 22px;
    border: 0;
    border-radius: 999px;
    background: var(--marca);
    color: var(--marca-texto);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.boton:hover { filter: brightness(1.08); }
.boton:focus-visible { outline: 3px solid var(--tinta); outline-offset: 2px; }

.chapa {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--fondo-suave);
    color: var(--tinta-suave);
    font-size: 0.85rem;
    font-weight: 600;
}

.pie {
    margin-top: auto;
    padding: 24px 16px;
    text-align: center;
    color: var(--tinta-tenue);
    font-size: 0.85rem;
}

/* --- Portada del servicio (provisional) ------------------------------- */

.portada {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 16px 64px;
    text-align: center;
}
.portada h1 {
    margin-top: 16px;
    font-size: clamp(2rem, 6vw, 3.25rem);
    letter-spacing: -0.03em;
}
.portada-texto {
    margin-top: 20px;
    font-size: 1.125rem;
    color: var(--tinta-suave);
    text-wrap: pretty;
}

.boton-whatsapp { background: #1fae53; color: #ffffff; }
.boton-suave {
    background: var(--fondo-suave);
    color: var(--tinta);
    min-height: 40px;
    padding: 8px 16px;
    font-weight: 500;
}

.sello { text-decoration: none; color: var(--tinta-tenue); }
.sello strong { color: var(--tinta-suave); }
.sello:hover strong { color: var(--tinta); }

/* --- Tienda ----------------------------------------------------------- */

.aviso-previa {
    padding: 10px 16px;
    background: #fef3c7;
    color: #78350f;
    font-size: 0.9rem;
    text-align: center;
}

.tienda-cabecera { width: 100%; }
.tienda-portada {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    aspect-ratio: 3 / 1;
    max-height: 280px;
    background: var(--marca);
    overflow: hidden;
}
.tienda-portada[data-sin-portada] { aspect-ratio: 6 / 1; }
.tienda-portada img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 720px) {
    .tienda-portada { border-radius: 0 0 var(--radio) var(--radio); }
}

.tienda-datos {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.tienda-logo {
    width: 96px;
    height: 96px;
    margin-top: -48px;
    border-radius: 50%;
    border: 4px solid var(--fondo);
    background: var(--marca);
    color: var(--marca-texto);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    flex-shrink: 0;
}
.tienda-logo img { width: 100%; height: 100%; object-fit: cover; background: var(--fondo); }
.error .tienda-logo { margin-top: 0; }
.tienda-datos h1 { font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -0.02em; }
.tienda-descripcion { color: var(--tinta-suave); text-wrap: pretty; white-space: pre-line; }
.tienda-contacto {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.tienda-productos {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 32px 16px 16px;
}
.titulo-seccion { font-size: 1.125rem; margin-bottom: 16px; }
.vacio { text-align: center; color: var(--tinta-suave); padding: 48px 0; }

.rejilla {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 12px;
}
@media (min-width: 640px) { .rejilla { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 20px; } }
@media (min-width: 960px) { .rejilla { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tarjeta { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.tarjeta-foto {
    aspect-ratio: 1 / 1;
    border-radius: var(--radio);
    background: var(--fondo-suave);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    color: var(--tinta-tenue);
    font-size: 2.5rem;
    font-weight: 700;
}
.tarjeta-foto img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s ease; }
.tarjeta:hover .tarjeta-foto img { transform: scale(1.03); }
.tarjeta-nombre {
    font-size: 0.95rem;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tarjeta-precio { font-weight: 700; }
.chapa-agotado { align-self: flex-start; background: #fee2e2; color: #991b1b; font-size: 0.8rem; padding: 2px 10px; }

/* --- Producto --------------------------------------------------------- */

.producto-barra {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 12px 16px;
}
.volver {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    text-decoration: none;
    font-weight: 600;
}
.volver::before { content: "←"; color: var(--tinta-suave); }
.volver-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--marca);
    color: var(--marca-texto);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 700;
    flex-shrink: 0;
}
.volver-logo img { width: 100%; height: 100%; object-fit: cover; background: var(--fondo); }
.volver:hover .volver-nombre { text-decoration: underline; }

.producto {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding-bottom: 24px;
    display: grid;
    gap: 20px;
}
@media (min-width: 860px) {
    .producto {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
        gap: 40px;
        padding: 8px 16px 32px;
        align-items: start;
    }
    .producto-galeria { position: sticky; top: 16px; }
}

.galeria {
    position: relative;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    background: var(--fondo-suave);
}
.galeria::-webkit-scrollbar { display: none; }
.galeria-foto { flex: 0 0 100%; margin: 0; aspect-ratio: 1 / 1; scroll-snap-align: start; }
.galeria-foto img { width: 100%; height: 100%; object-fit: contain; }
.galeria-vacia {
    aspect-ratio: 1 / 1;
    max-height: 60vh;
    width: 100%;
    background: var(--fondo-suave);
    color: var(--tinta-tenue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: 700;
}
.galeria-miniaturas {
    display: flex;
    gap: 8px;
    padding: 8px 16px 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.galeria-miniaturas a {
    flex: 0 0 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--fondo-suave);
}
.galeria-miniaturas a[aria-current="true"] { border-color: var(--marca); }
.galeria-miniaturas img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 860px) {
    .galeria, .galeria-vacia { border-radius: var(--radio); }
    .galeria-miniaturas { padding: 10px 0 0; }
}

.producto-info { padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 860px) { .producto-info { padding: 8px 0 0; } }
.producto-info h1 { font-size: clamp(1.4rem, 4.5vw, 2rem); letter-spacing: -0.02em; }
.producto-precio { font-size: 1.5rem; font-weight: 700; margin-top: -6px; }
.producto-estado { display: flex; flex-wrap: wrap; gap: 8px; }
.producto-estado:not(:has(> :not([hidden]))) { display: none; }
.producto-estado .chapa-agotado { font-size: 0.85rem; padding: 4px 12px; }
.chapa-quedan { background: #fef3c7; color: #78350f; }

.producto-opciones { display: flex; flex-direction: column; gap: 16px; }
.opcion { border: 0; margin: 0; padding: 0; min-width: 0; }
.opcion legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.opcion-valores { display: flex; flex-wrap: wrap; gap: 8px; }
.opcion-valor { position: relative; }
.opcion-valor input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.opcion-valor span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 48px;
    padding: 8px 16px;
    border: 1.5px solid var(--borde);
    border-radius: 999px;
    font-weight: 500;
}
.opcion-valor:hover span { border-color: var(--tinta-tenue); }
.opcion-valor input:checked + span { border-color: var(--marca); background: var(--marca); color: var(--marca-texto); }
.opcion-valor input:focus-visible + span { outline: 3px solid var(--tinta); outline-offset: 2px; }
.opcion-valor[data-no-disponible] span { color: var(--tinta-tenue); text-decoration: line-through; }
.opcion-valor[data-no-disponible] input:checked + span { background: var(--fondo-suave); color: var(--tinta-suave); border-color: var(--tinta-tenue); }
.aviso-combinacion { color: #991b1b; font-size: 0.95rem; }

.producto-info .boton-whatsapp { align-self: stretch; }
@media (min-width: 860px) { .producto-info .boton-whatsapp { align-self: flex-start; } }
.producto-descripcion {
    padding-top: 16px;
    border-top: 1px solid var(--borde);
    color: var(--tinta-suave);
    white-space: pre-line;
    text-wrap: pretty;
}

/* --- Comprar y carrito ------------------------------------------------ */

.boton:disabled, .boton[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; filter: none; }

.cantidad {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid var(--borde);
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}
.cantidad button {
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 1.25rem;
    color: var(--tinta);
    cursor: pointer;
}
.cantidad button:disabled { color: var(--tinta-tenue); cursor: not-allowed; }
.cantidad input, .cantidad [data-cantidad] {
    width: 44px;
    border: 0;
    text-align: center;
    font: inherit;
    font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
}
.cantidad input::-webkit-outer-spin-button, .cantidad input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.comprar { display: flex; gap: 10px; align-items: center; }
.comprar .boton { flex: 1; }
@media (min-width: 860px) { .comprar .boton { flex: 0 1 auto; } }
.anadido { color: #166534; font-weight: 500; margin-top: -6px; }
.anadido a { color: inherit; font-weight: 700; }

.flotante-carrito {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--tinta);
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
.flotante-cuenta {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--marca);
    color: var(--marca-texto);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.carrito {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 16px 32px;
}
.carrito h1 { font-size: clamp(1.4rem, 4.5vw, 1.8rem); margin-bottom: 16px; }
.carrito .vacio { padding: 32px 0 16px; }
.aviso-carrito { padding: 10px 14px; margin-bottom: 12px; border-radius: 8px; background: #fef3c7; color: #78350f; font-size: 0.95rem; }
.carrito-lineas { list-style: none; margin: 0; padding: 0; }
.carrito-linea {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--borde);
}
.carrito-linea[data-problema] .carrito-foto { opacity: 0.5; }
.carrito-foto {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--fondo-suave);
    color: var(--tinta-tenue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
}
.carrito-foto img { width: 100%; height: 100%; object-fit: cover; }
.carrito-detalle { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.carrito-nombre { font-weight: 600; text-decoration: none; }
.carrito-nombre:hover { text-decoration: underline; }
.carrito-variante, .carrito-unitario { color: var(--tinta-suave); font-size: 0.9rem; }
.carrito-problema { color: #991b1b; font-size: 0.9rem; font-weight: 600; }
.carrito-controles { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.carrito-controles .cantidad button { width: 36px; height: 36px; font-size: 1.1rem; }
.carrito-controles .cantidad [data-cantidad] { width: 32px; }
.carrito-quitar {
    border: 0;
    background: none;
    padding: 8px 4px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--tinta-suave);
    text-decoration: underline;
    cursor: pointer;
}
.carrito-subtotal { font-weight: 700; white-space: nowrap; }
.carrito-totales { margin: 16px 0 0; display: flex; flex-direction: column; gap: 6px; }
.carrito-totales div { display: flex; justify-content: space-between; gap: 16px; }
.carrito-totales dt { color: var(--tinta-suave); }
.carrito-totales dd { margin: 0; font-weight: 600; text-align: right; }
.carrito-acciones { margin-top: 20px; display: flex; flex-direction: column; align-items: stretch; }
@media (min-width: 640px) { .carrito-acciones { align-items: flex-end; } }
.carrito-revisar { color: #991b1b; font-weight: 600; text-align: center; }

/* --- Checkout --------------------------------------------------------- */

.checkout {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 8px 16px 32px;
}
.checkout h1 { font-size: clamp(1.4rem, 4.5vw, 1.8rem); margin-bottom: 16px; }
.aviso-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    font-weight: 500;
}
.aviso-error a { color: inherit; font-weight: 700; }
.checkout-form { display: grid; gap: 20px; }
@media (min-width: 860px) {
    .checkout-form { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; gap: 32px; }
    .checkout-resumen { position: sticky; top: 16px; }
}
.checkout-pasos { display: flex; flex-direction: column; gap: 20px; }
.bloque {
    margin: 0;
    padding: 18px 16px;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.bloque legend, .bloque h2 { font-size: 1.05rem; font-weight: 700; padding: 0 4px; }
.bloque h2 { padding: 0; }
.bloque[aria-invalid="true"] { border-color: #dc2626; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span { font-weight: 600; font-size: 0.95rem; }
.campo em { font-style: normal; font-weight: 400; color: var(--tinta-tenue); }
.campo small, .nota-campo { color: var(--tinta-suave); font-size: 0.875rem; }
.campo input, .campo select, .campo textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1.5px solid var(--borde);
    border-radius: 10px;
    background: var(--fondo);
    color: var(--tinta);
    font: inherit;
}
.campo textarea { resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--marca); box-shadow: 0 0 0 3px rgb(0 0 0 / 0.06); }
.campo [aria-invalid="true"] { border-color: #dc2626; }
.trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.metodos { display: flex; flex-direction: column; gap: 8px; }
.metodo {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1.5px solid var(--borde);
    border-radius: 10px;
    cursor: pointer;
}
.metodo:has(input:checked) { border-color: var(--marca); }
.metodo input { margin-top: 4px; accent-color: var(--marca); width: 18px; height: 18px; flex-shrink: 0; }
.metodo span { display: flex; flex-direction: column; }
.metodo small { color: var(--tinta-suave); }

.resumen-lineas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.resumen-lineas li { display: flex; justify-content: space-between; gap: 12px; }
.resumen-lineas small { color: var(--tinta-suave); }
.carrito-totales .total { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--borde); font-size: 1.1rem; }
.carrito-totales .total dt, .carrito-totales .total dd { color: var(--tinta); font-weight: 700; }
.cupon { display: flex; gap: 8px; align-items: flex-end; }
.cupon .campo { flex: 1; }
.cupon .boton { min-height: 46px; }
.boton-enviar { width: 100%; min-height: 52px; font-size: 1.05rem; }

/* --- Pedido ------------------------------------------------------------ */

.pedido {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 16px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.pedido-nuevo {
    padding: 14px 16px;
    border-radius: var(--radio);
    background: #dcfce7;
    color: #14532d;
}
.pedido-cabecera { display: flex; flex-direction: column; gap: 6px; }
.pedido-cabecera h1 { font-size: clamp(1.3rem, 4.5vw, 1.7rem); }
.pedido-cuerpo { display: flex; flex-direction: column; gap: 16px; }
.chapa-pago-pagado { background: #dcfce7; color: #166534; }
.chapa-pago-comprobante { background: #fef3c7; color: #78350f; }
.chapa-pago-rechazado { background: #fee2e2; color: #991b1b; }
.cuenta { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.cuenta div { display: flex; justify-content: space-between; gap: 16px; }
.cuenta dt { color: var(--tinta-suave); flex-shrink: 0; }
.cuenta dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.cuenta-numero { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; user-select: all; }
.instrucciones { color: var(--tinta-suave); white-space: pre-line; }
.subir-comprobante { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--borde); }
.subir-comprobante input[type="file"] { padding: 8px; min-height: 0; }
.volver-sin-enlace::before { content: none; }

/* --- Página de error -------------------------------------------------- */

.error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 16px;
    text-align: center;
}
.error .marca { margin-bottom: 24px; }
.error-codigo {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--tinta-tenue);
}
.error h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.error-texto { max-width: 420px; color: var(--tinta-suave); }
.error .boton { margin-top: 16px; }
