/* Controles independientes de las fuentes de iconos y los botones del tema. */
.nxrs-cart-svg {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    vertical-align: middle;
    font-size: 14px;
}

/* El selector y el aviso se insertan en body, fuera del reset del panel. */
.nxrs-combos-modal,
.nxrs-combos-modal *,
.nxrs-product__cart-wrap,
.nxrs-product__cart-wrap *,
.nxrs-cart-toast {
    box-sizing: border-box;
}

.nxrs-combos-modal button,
.nxrs-combos-modal input {
    font-family: inherit;
}

.nxrs-product {
    position: relative;
    overflow: visible;
}

/* El carrito reserva su espacio debajo de los datos, sin tapar el precio. */
.nxrs-product__cart-wrap {
    position: relative;
    width: 100%;
    margin-top: 10px;
    padding: 0;
    z-index: 3;
}

.nxrs-product__cart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.nxrs-product__cart-container--inline {
    flex-direction: row;
    justify-content: center;
    gap: 4px;
}

.nxrs-product__cart-btn,
.nxrs-combo-row__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 32px;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: var(--nxrs-radius-sm, 6px);
    background: var(--nxrs-primary, #1f2937);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease;
}

.nxrs-product__cart-btn {
    width: 100%;
}

.nxrs-product__cart-btn:hover:not(:disabled),
.nxrs-combo-row__btn:hover:not(:disabled) {
    background: var(--nxrs-accent, #111827);
}

.nxrs-product__cart-btn--options {
    background: var(--nxrs-bg, #fff);
    color: var(--nxrs-text, #1f2937);
    border-color: var(--nxrs-border, #e5e7eb);
}

.nxrs-product__cart-btn--options:hover:not(:disabled) {
    background: var(--nxrs-bg, #fff);
    border-color: var(--nxrs-primary, #1f2937);
}

.nxrs-cart-chevron {
    font-size: 13px;
    color: var(--nxrs-text-muted, #6b7280);
}

.nxrs-product__cart-btn:disabled,
.nxrs-combo-row__btn:disabled {
    background: #f3f4f6;
    color: #6b7280;
    border-color: var(--nxrs-border, #e5e7eb);
    cursor: not-allowed;
}

.nxrs-product__cart-btn--success:disabled,
.nxrs-combo-row__btn--success:disabled {
    background: #1a7a38;
    color: #fff;
    border-color: transparent;
}

.nxrs-product__cart-btn[data-stock-status="backorder"] {
    background: #fff8e1;
    color: #705000;
    border-color: #e9dba7;
}

.nxrs-product__cart-btn[data-stock-status="backorder"]:hover:not(:disabled) {
    background: #fff0bc;
}

.nxrs-product__cart-btn--loading .nxrs-cart-icon,
.nxrs-combo-row__btn--loading .nxrs-cart-svg {
    animation: nxrs-cart-spin .5s linear infinite;
}

@keyframes nxrs-cart-spin {
    to { transform: rotate(360deg); }
}

/* Altura común; las tarjetas estrechas reducen el ancho sin partir la fila. */
.nxrs-quantity-control {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    width: 94px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--nxrs-border, #e5e7eb);
    border-radius: var(--nxrs-radius-sm, 6px);
    background: var(--nxrs-bg, #fff);
    color: var(--nxrs-text, #1f2937);
}

.nxrs-quantity-btn {
    display: flex;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-width: 0;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: inherit;
    box-shadow: none;
    cursor: pointer;
}

.nxrs-quantity-btn:hover:not(:disabled) {
    background: var(--nxrs-border, #e5e7eb);
}

.nxrs-quantity-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.nxrs-quantity-input {
    appearance: textfield;
    -moz-appearance: textfield;
    flex: 1 1 auto;
    width: 32px;
    min-width: 0;
    height: 30px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    box-shadow: none;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    line-height: 30px;
}

.nxrs-product__cart-container--inline .nxrs-quantity-control {
    flex: 1 1 94px;
    min-width: 70px;
    max-width: 94px;
}

.nxrs-product__cart-container--inline .nxrs-quantity-btn {
    flex: 0 1 30px;
    min-width: 24px;
}

.nxrs-product__cart-container--inline .nxrs-quantity-input {
    min-width: 20px;
}

.nxrs-quantity-input::-webkit-inner-spin-button,
.nxrs-quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nxrs-quantity-btn:focus-visible,
.nxrs-quantity-input:focus-visible,
.nxrs-product__cart-btn:focus-visible,
.nxrs-combo-row__btn:focus-visible,
.nxrs-combos-modal__close:focus-visible {
    outline: 2px solid var(--nxrs-primary, #1f2937);
    outline-offset: 2px;
}

.nxrs-combos-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: calc(var(--nxrs-overlay-z, 10000) + 10);
}

.nxrs-combos-backdrop--open {
    display: block;
}

.nxrs-combos-modal {
    display: none;
    position: fixed;
    z-index: calc(var(--nxrs-overlay-z, 10000) + 11);
    width: 420px;
    max-width: calc(100vw - 24px);
    max-height: 640px;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--nxrs-radius, 12px);
    background: var(--nxrs-bg, #fff);
    color: var(--nxrs-text, #1f2937);
    box-shadow: 0 12px 28px rgba(0,0,0,.2);
}

.nxrs-combos-modal--open {
    display: flex;
}

.nxrs-combos-modal__header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--nxrs-border, #e5e7eb);
}

.nxrs-combos-modal__thumb {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: var(--nxrs-radius-sm, 6px);
    background: #f5f5f5;
}

.nxrs-combos-modal__title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.nxrs-combos-modal__close {
    display: flex;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--nxrs-radius-sm, 6px);
    background: transparent;
    color: var(--nxrs-text-muted, #6b7280);
    cursor: pointer;
}

.nxrs-combos-modal__close:hover {
    background: var(--nxrs-border, #e5e7eb);
    color: var(--nxrs-text, #1f2937);
}

.nxrs-combos-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--nxrs-border, #e5e7eb) transparent;
}

.nxrs-combos-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 0;
    color: var(--nxrs-text-muted, #6b7280);
    font-size: 13px;
}

.nxrs-combos-spinner {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 2px solid var(--nxrs-border, #e5e7eb);
    border-top-color: var(--nxrs-accent, #1f2937);
    border-radius: 50%;
    animation: nxrs-cart-spin .55s linear infinite;
}

/* Imagen a la izquierda; datos y acciones siempre en ese orden a la derecha. */
.nxrs-combo-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: start;
    gap: 8px 12px;
    padding: 12px 0;
}

.nxrs-combo-row + .nxrs-combo-row {
    border-top: 1px solid var(--nxrs-border, #e5e7eb);
}

.nxrs-combo-row__img {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 40px;
    height: 48px;
    object-fit: contain;
    border: 1px solid var(--nxrs-border, #e5e7eb);
    border-radius: var(--nxrs-radius-sm, 6px);
    background: #f5f5f5;
}

.nxrs-combo-row__img--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nxrs-text-muted, #6b7280);
}

.nxrs-combo-row__info {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nxrs-combo-row__label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.nxrs-combo-row__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    line-height: 1.3;
}

.nxrs-combo-row__price {
    font-size: 13px;
    font-weight: 700;
    color: var(--nxrs-primary, #1f2937);
}

.nxrs-combo-row__ref {
    width: 100%;
    font-size: 11px;
    color: var(--nxrs-text-muted, #6b7280);
    overflow-wrap: anywhere;
}

.nxrs-combo-row__stock {
    font-size: 11px;
    font-weight: 500;
}

.nxrs-combo-row__stock--in { color: #1a7a38; }
.nxrs-combo-row__stock--out { color: #b42318; }

.nxrs-combo-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nxrs-combo-row__btn {
    flex: 0 0 auto;
    min-width: 84px;
}

.nxrs-product__cart-btn--icon,
.nxrs-combo-row__btn--icon {
    flex: 0 0 32px;
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
}

.nxrs-product__cart-btn--icon .nxrs-cart-svg,
.nxrs-combo-row__btn--icon .nxrs-cart-svg {
    font-size: 16px;
}

.nxrs-combos-modal__footer {
    flex: 0 0 auto;
    padding: 12px 14px;
    border-top: 1px solid var(--nxrs-border, #e5e7eb);
    text-align: center;
}

.nxrs-combos-modal__product-link {
    font-size: 12px;
    line-height: 18px;
    color: var(--nxrs-text-muted, #6b7280);
    text-decoration: none;
}

.nxrs-combos-modal__product-link:hover {
    color: var(--nxrs-accent, #1f2937);
    text-decoration: underline;
}

.nxrs-product__stock--variants {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(0,0,0,.05);
    color: var(--nxrs-text-muted, #6b7280);
}

.nxrs-cart-toast {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: calc(var(--nxrs-overlay-z, 10000) + 20);
    max-width: 300px;
    padding: 10px 14px;
    border-radius: var(--nxrs-radius-sm, 6px);
    background: #1a7a38;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    box-shadow: 0 3px 10px rgba(0,0,0,.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.nxrs-cart-toast--error { background: #b71c1c; }
.nxrs-cart-toast--visible { opacity: 1; transform: translateY(0); }

@media (max-width: 767px) {
    .nxrs-product__cart-wrap { margin-top: 8px; }

    .nxrs-combos-modal {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: 65vh;
        max-height: min(640px, 65dvh);
        bottom: max(10px, env(safe-area-inset-bottom));
        left: 10px;
        right: 10px;
        top: auto;
    }

    .nxrs-cart-toast {
        right: 10px;
        left: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        max-width: none;
        justify-content: center;
        text-align: center;
    }

    /* La confirmación no tapa las últimas opciones ni el enlace a la ficha. */
    .nxrs-cart-toast--over-modal {
        top: max(10px, env(safe-area-inset-top));
        bottom: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nxrs-product__cart-wrap *,
    .nxrs-combos-modal *,
    .nxrs-cart-toast {
        animation: none !important;
        transition: none !important;
    }
}
