/* ===========================================================================
   Cart widgets COMPARTIDOS (modal de variantes .nvm + toast del carrito).
   Extraido de storefront-modern.css para reusarlo tambien en la pagina de
   producto (layouts/app). Este archivo se carga en AMBOS layouts.
   ========================================================================= */

/* ═══════════════ Modal de variante (elegí talla/color antes de cargar) ═══════════════ */
.nvm {
    position: fixed; inset: 0; z-index: 1100;
    visibility: hidden; pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.nvm.open { visibility: visible; pointer-events: auto; }
.nvm__overlay {
    position: absolute; inset: 0;
    background: rgba(10,10,11,.55); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
}
.nvm.open .nvm__overlay { opacity: 1; }
.nvm__dialog {
    position: relative;
    width: min(880px, 100%); max-height: 92vh; overflow: hidden;
    background: var(--surface-card); color: var(--fg-default);
    border: 1px solid var(--border-subtle); border-radius: 22px;
    box-shadow: 0 30px 80px rgba(10,10,11,.35);
    display: grid; grid-template-columns: 1.05fr 1fr;
    transform: translateY(14px) scale(.98); opacity: 0;
    transition: transform var(--dur-medium) var(--ease-spring), opacity var(--dur-base) var(--ease-out);
}
.nvm.open .nvm__dialog { transform: translateY(0) scale(1); opacity: 1; }
.nvm__close {
    position: absolute; top: 14px; right: 14px; z-index: 2;
    width: 36px; height: 36px; border-radius: 9999px;
    border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--fg-strong);
    font-size: 18px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: border-color var(--dur-base), color var(--dur-base);
}
.nvm__close:hover { border-color: var(--brand); color: var(--brand); }

/* Panel de la foto — grande y elegante */
.nvm__media {
    position: relative; background: var(--surface-sunken);
    display: flex; align-items: center; justify-content: center; min-height: 320px; padding: 24px;
}
.nvm__media::after { /* viñeta sutil para dar profundidad a la foto */
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(120% 90% at 50% 15%, transparent 55%, rgba(10,10,11,.10));
}
.nvm__img {
    max-width: 100%; max-height: 60vh; object-fit: contain;
    border-radius: 14px; transition: opacity var(--dur-base) var(--ease-out);
}

/* Panel de selección */
.nvm__body { padding: 30px 30px 24px; overflow-y: auto; display: flex; flex-direction: column; }
.nvm__name { margin: 4px 44px 10px 0; font-size: 22px; font-weight: 800; line-height: 1.2; color: var(--fg-strong); text-wrap: balance; }
.nvm__price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 20px; }
.nvm__price { font-size: 26px; font-weight: 800; color: var(--brand); letter-spacing: -.01em; }
.nvm__price--muted { color: var(--fg-muted); font-size: 20px; }

.nvm__group { margin-bottom: 18px; }
.nvm__label {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--fg-muted); margin-bottom: 9px;
}
.nvm__label b { color: var(--fg-strong); font-weight: 800; }
.nvm__opts { display: flex; flex-wrap: wrap; gap: 9px; }

.nvm__chip {
    position: relative; overflow: hidden;
    min-width: 52px; padding: 9px 15px; border-radius: 12px;
    border: 1.5px solid var(--border-strong); background: var(--surface-card); color: var(--fg-strong);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: border-color var(--dur-base), background var(--dur-base), color var(--dur-base);
}
.nvm__chip:hover:not(.is-out):not(.is-active) { border-color: var(--fg-muted); }
.nvm__chip.is-active {
    border-color: var(--brand); color: var(--brand);
    background: rgba(var(--brand-rgb), .08);
}
/* Tilde estilo Apple TV en la esquina de la opción elegida */
.nvm__chip.is-active::after {
    content: ""; position: absolute; right: 0; bottom: 0;
    width: 16px; height: 16px; background: var(--brand);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.nvm__chip.is-out {
    color: var(--fg-subtle); border-color: var(--border-subtle);
    cursor: not-allowed; text-decoration: line-through; opacity: .65;
}

/* Chips de color: swatch/foto + nombre */
.nvm__chip--color { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px 7px 8px; }
.nvm__swatch { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--border-subtle); object-fit: cover; flex: none; }

.nvm__stock { font-size: 13px; font-weight: 700; margin: 2px 0 20px; min-height: 18px; }
.nvm__stock--ok { color: #16A34A; }
.nvm__stock--out { color: #B91C1C; }

.nvm__qty-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.nvm__qty-row > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); }
.nvm__stepper { display: inline-flex; align-items: center; gap: 4px; border: 1.5px solid var(--border-strong); border-radius: 12px; padding: 3px; }
.nvm__stepper button {
    width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--fg-strong);
    font-size: 19px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.nvm__stepper button:hover:not(:disabled) { background: var(--surface-hover); color: var(--brand); }
.nvm__stepper button:disabled { opacity: .35; cursor: not-allowed; }
.nvm__stepper input {
    width: 42px; text-align: center; border: 0; background: transparent; color: var(--fg-strong);
    font-size: 16px; font-weight: 800; -moz-appearance: textfield;
}
.nvm__stepper input::-webkit-outer-spin-button, .nvm__stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.nvm__actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.nvm__add {
    width: 100%; padding: 15px 20px; border: 0; border-radius: 13px;
    background: var(--brand); color: var(--brand-fg);
    font-size: 15px; font-weight: 800; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    transition: filter var(--dur-base), opacity var(--dur-base);
}
.nvm__add:hover:not(:disabled) { filter: brightness(1.06); }
.nvm__add:disabled { opacity: .5; cursor: not-allowed; }
.nvm__detail {
    text-align: center; font-size: 13.5px; font-weight: 700; color: var(--fg-muted); text-decoration: none;
    padding: 6px; transition: color var(--dur-base);
}
.nvm__detail:hover { color: var(--brand); }

.nvm__loading { grid-column: 1 / -1; padding: 70px 24px; text-align: center; color: var(--fg-muted); font-weight: 600; }

@media (max-width: 720px) {
    .nvm { padding: 0; align-items: flex-end; }
    .nvm__dialog {
        grid-template-columns: 1fr;
        /* minmax(0,1fr) es OBLIGATORIO: sin él la fila del cuerpo no puede
           achicarse, el contenido desborda bajo el overflow:hidden del diálogo
           y el botón de agregar queda cortado e INTOCABLE (bug real reportado
           desde un celular en producción). */
        grid-template-rows: auto minmax(0, 1fr);
        width: 100%;
        max-height: 92vh;  /* fallback para navegadores sin dvh */
        max-height: 92dvh; /* dvh descuenta la barra del navegador móvil */
        border-radius: 22px 22px 0 0; border-bottom: 0;
        transform: translateY(100%);
    }
    /* La foto CEDE espacio (min-height 0) en vez de robárselo a los controles. */
    .nvm__media { min-height: 0; max-height: 30vh; padding: 14px; }
    .nvm__img { max-height: 26vh; }
    .nvm__body { padding: 18px 20px 0; min-height: 0; -webkit-overflow-scrolling: touch; }
    .nvm__name { font-size: 19px; margin-right: 40px; }
    /* CTA SIEMPRE visible: barra pegajosa al fondo del área scrolleable, con
       margen para la home-bar de los teléfonos sin botones. */
    .nvm__actions {
        position: sticky; bottom: 0;
        background: var(--surface-card);
        padding: 10px 0 calc(14px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 18px -14px rgba(10,10,11,.35);
    }
}
@media (prefers-reduced-motion: reduce) {
    .nvm__dialog, .nvm__overlay, .nvm__img { transition: none; }
}

.nube-cart-toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    z-index: 1100; max-width: 90vw;
    background: var(--fg-strong); color: var(--bg-page);
    padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
    box-shadow: 0 12px 30px rgba(10,10,11,.35);
    opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.nube-cart-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
