/* Modal "Elegir tienda" para los botones de comprar (carrito) de los comparadores.
   Reutiliza las variables de soft-ui.css (--sui-*) y panel-skin.css (--pn-*)
   para que el relieve neumorphism sea el mismo que el resto del panel. Se
   carga DESPUÉS de esos dos archivos. */

.buy-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.buy-modal-overlay.hidden { display: none; }
body.panel-ui.light-theme .buy-modal-overlay { background: rgba(0,0,0,0.4); }

body.buy-modal-open { overflow: hidden; }

.buy-modal {
    background: var(--pn-bg, #1e1e1e);
    border: none;
    border-radius: var(--sui-radio, 14px);
    width: 100%;
    max-width: 460px;
    /* Con el selector de versiones y el gráfico el modal puede pasar del alto de
       la pantalla: que haga scroll ÉL, no la página de detrás. */
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.6rem;
    box-shadow: var(--sui-alto, 0 24px 64px rgba(0,0,0,0.6));
    animation: buyModalIn 0.2s cubic-bezier(0.22,0.61,0.36,1) both;
    position: relative;
}
@keyframes buyModalIn {
    from { opacity: 0; transform: translateY(-14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.buy-modal-close {
    position: absolute;
    z-index: 2;
    top: 0.8rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--pn-dim, rgba(255,255,255,0.5));
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 9px;
    border-radius: 8px;
    transition: color 0.15s, box-shadow 0.15s;
}
.buy-modal-close:hover {
    color: var(--pn-text, #fff);
    box-shadow: var(--sui-hondo);
}

/* ---------- Cuerpo: imagen a la izquierda, tiendas a la derecha ---------- */
.buy-modal-body {
    display: flex;
    align-items: stretch;
    gap: 1.4rem;
}

.buy-modal-left {
    flex: none;
    width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* La foto del producto va hundida, como una pantalla: mismo lenguaje que
   el visor del gráfico y la lista de modelos (comparacion_visual/soft-ui). */
.buy-modal-img-wrap {
    width: 160px;
    height: 160px;
    border-radius: var(--sui-radio, 14px);
    background: var(--sui-hueco-bg, #141414);
    box-shadow: var(--sui-hondo);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.6rem;
}
.buy-modal-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Título arriba, con el mismo acento lateral que .card-name en las tarjetas
   del catálogo. Padding a la derecha para no chocar con el botón de cerrar. */
.buy-modal-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--pn-text, #fff);
    line-height: 1.35;
    border-left: 3px solid var(--pn-accent);
    padding-left: 0.6rem;
    padding-right: 2rem;
    margin-bottom: 1.3rem;
}

.buy-modal-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.7rem;
}

.buy-modal-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--pn-dim, rgba(255,255,255,0.45));
}

.buy-modal-stores {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Botón de tienda: sobresale en reposo, se hunde al pulsar — mismo
   comportamiento que .btn-compare / .btn-share del resto del panel. */
.buy-modal-store {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: var(--pn-bg2);
    box-shadow: var(--sui-suave);
    color: var(--pn-text, #fff);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    transition: box-shadow 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.buy-modal-store:hover {
    color: var(--pn-accent);
    box-shadow: var(--sui-alto);
    transform: translateY(-1px);
}
.buy-modal-store:active {
    box-shadow: var(--sui-hondo);
    transform: translateY(1px);
}
.buy-modal-store:focus-visible {
    outline: 2px solid var(--pn-accent);
    outline-offset: 2px;
}
.buy-modal-store i:first-child {
    font-size: 1.05rem;
    color: var(--pn-accent);
    width: 20px;
    text-align: center;
}
.buy-modal-store span { flex: 1; }
.buy-modal-store-price {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--pn-dim, rgba(255,255,255,0.5));
}
.buy-modal-store-stock.is-in { color: #3bb273; }
.buy-modal-store-stock.is-out { color: #e0574c; }
.buy-modal-store-best {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #3bb273;
    background: rgba(59, 178, 115, 0.14);
    vertical-align: 0.05em;
}

/* Icono cuadrado (imagen, no font-icon): fondo claro fijo para que se lea
   siempre igual de bien, tanto en el tema oscuro del modal como en el claro. */
.buy-modal-store span.buy-modal-store-icon {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background-color: #fff;
    background-image: url("../img/afiliados/coolmod-icon.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 68%;
    box-sizing: border-box;
}
.buy-modal-store span.buy-modal-store-icon--msi {
    background-image: url("../img/afiliados/msi-icon.svg");
    background-size: 80%;
}
.buy-modal-store span.buy-modal-store-icon--pcbox {
    background-image: url("../img/afiliados/pcbox-icon.png");
    background-size: 92%;
}
.buy-modal-store span.buy-modal-store-icon--pccomponentes {
    background-image: url("../img/afiliados/pccomponentes-icon.svg");
    background-size: 84%;
}
.buy-modal-store-go {
    font-size: 0.7rem;
    color: var(--pn-dim);
}

@media (prefers-reduced-motion: reduce) {
    .buy-modal-store { transition: none; }
    .buy-modal-store:hover { transform: none; }
}

/* ---------- Móvil: columnas apiladas ---------- */
@media (max-width: 480px) {
    .buy-modal-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .buy-modal-left {
        width: 100%;
    }
    .buy-modal-right {
        width: 100%;
    }
}

/* Pastillas de variante (capacidad, velocidad…): cambian todo el modal */
.buy-modal-variantes { margin: 0 0 1rem; }
.buy-modal-variantes[hidden] { display: none; }
.buy-modal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .45rem; }
.buy-modal-chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border: 0; border-radius: 11px;
    font: inherit; font-size: .82rem; font-weight: 700; color: var(--pn-text, #e8e8e8);
    background: var(--pn-bg2, #1e1e1e); box-shadow: var(--sui-suave); cursor: pointer;
    transition: color .15s, box-shadow .15s;
}
.buy-modal-chip small { font-size: .72rem; font-weight: 600; color: var(--pn-dim, #9a9a9a); }
.buy-modal-chip small.agotado { color: #e5534b; }
.buy-modal-chip:hover { color: var(--pn-accent, #ff7b3a); }
.buy-modal-chip.activa { color: var(--pn-accent, #ff7b3a); background: var(--sui-hueco-bg); box-shadow: var(--sui-hondo); }
.buy-modal-chip.sin-precio:not(.activa) { opacity: .62; }
.buy-modal-chip:focus-visible { outline: 2px solid var(--pn-accent, #ff7b3a); outline-offset: 2px; }

/* Desplegable propio de variantes (igual que el del modal de variantes) */
.bm-dd { position: relative; margin-top: .45rem; }
.bm-dd-btn, .bm-dd-opt {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0;
    font: inherit; font-size: .85rem; font-weight: 700; color: var(--pn-text, #e8e8e8); cursor: pointer; background: transparent;
}
.bm-dd-btn { padding: 11px 13px; border-radius: 11px; background: var(--sui-hueco-bg, #141414); box-shadow: var(--sui-hondo); transition: color .15s; }
.bm-dd-btn:hover, .bm-dd.abierto .bm-dd-btn { color: var(--pn-accent, #ff7b3a); }
.bm-dd-btn:focus-visible, .bm-dd-opt:focus-visible { outline: 2px solid var(--pn-accent, #ff7b3a); outline-offset: 2px; }
.bm-dd-txt { flex: 1; min-width: 0; }
.bm-dd-precio { font-size: .76rem; font-weight: 600; white-space: nowrap; }
.bm-dd-precio.flojo { color: var(--pn-dim, #9a9a9a); font-weight: 500; }
.bm-dd-precio.agotado { color: #e5534b; }
.bm-dd-flecha { font-size: .62rem; color: var(--pn-dim, #9a9a9a); transition: transform .15s; }
.bm-dd.abierto .bm-dd-flecha { transform: rotate(180deg); color: inherit; }
.bm-dd-panel {
    margin-top: .4rem; padding: .3rem; border-radius: 12px; background: var(--pn-bg2, #1b1b1b);
    box-shadow: var(--sui-alto, 0 18px 40px rgba(0,0,0,.55)); max-height: 240px; overflow-y: auto; overscroll-behavior: contain;
}
.bm-dd-panel[hidden] { display: none; }
.bm-dd-opt { padding: 9px 11px; border-radius: 9px; font-weight: 600; }
.bm-dd-opt + .bm-dd-opt { margin-top: 2px; }
.bm-dd-opt:hover { background: var(--sui-hueco-bg, #141414); color: var(--pn-accent, #ff7b3a); }
.bm-dd-opt.activa { color: var(--pn-accent, #ff7b3a); background: var(--sui-hueco-bg, #141414); box-shadow: var(--sui-hondo); font-weight: 700; }
