/* ============================================================
   IntercoTableVariations — tabla de variaciones de producto
   ============================================================ */
:root {
    --itv-magenta: #b51977;
    --itv-magenta-dark: #8e125c;
    --itv-border: #e3e3e3;
    --itv-bg: #fafafa;
    --itv-text: #222;
    --itv-muted: #777;
}

.itv-wrapper {
    margin: 18px 0 28px;
    padding: 16px 18px 12px;
    background: #fff;
    border: 1px solid var(--itv-border);
    border-radius: 12px;
}

/* Cabecera (título + buscador) */
.itv-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--itv-magenta);
}
.itv-title {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--itv-text);
    margin: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}
.itv-count {
    color: var(--itv-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}
.itv-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: var(--itv-bg);
    border: 1px solid var(--itv-border);
    border-radius: 8px;
    padding: 0 10px;
    min-width: 240px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.itv-search:focus-within {
    border-color: var(--itv-magenta);
    box-shadow: 0 0 0 3px rgba(181,25,119,0.08);
    background: #fff;
}
.itv-search .fa-search {
    color: var(--itv-muted);
    font-size: 12px;
    margin-right: 8px;
}
.itv-search__input {
    background: transparent;
    border: 0;
    padding: 9px 0;
    font-size: 13px;
    flex: 1;
    outline: none;
    color: var(--itv-text);
    min-width: 0;
}
.itv-search__input::placeholder { color: var(--itv-muted); }
.itv-search__clear {
    background: transparent;
    border: 0;
    color: var(--itv-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.itv-search__clear:hover { color: var(--itv-magenta); }

/* Wrapper con altura máxima + scroll interno */
.itv-tableWrap {
    max-height: 460px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    /* scrollbar fina */
    scrollbar-width: thin;
    scrollbar-color: var(--itv-magenta) #f0f0f0;
}
.itv-tableWrap::-webkit-scrollbar { width: 8px; height: 8px; }
.itv-tableWrap::-webkit-scrollbar-thumb { background: var(--itv-magenta); border-radius: 4px; }
.itv-tableWrap::-webkit-scrollbar-track { background: #f0f0f0; }

.itv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
/* Cabecera sticky dentro del scroll */
.itv-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--itv-muted);
    padding: 8px 10px;
    background: var(--itv-bg);
    border-bottom: 1px solid var(--itv-border);
}
.itv-table thead th.itv-col-swatch { width: 56px; }
.itv-table thead th.itv-col-stock,
.itv-table thead th.itv-col-qty { width: 130px; }

.itv-table tbody tr {
    border-bottom: 1px solid #f3f3f3;
    transition: background .12s ease;
}
.itv-table tbody tr:hover { background: rgba(181,25,119,0.03); }
.itv-table tbody tr:last-child { border-bottom: 0; }
.itv-row--out { opacity: .55; }
.itv-row--hidden { display: none; }
.itv-empty td {
    text-align: center;
    padding: 28px 12px !important;
    color: var(--itv-muted);
    font-style: italic;
}

.itv-table td {
    padding: 7px 10px;
    vertical-align: middle;
}
.itv-col-name strong {
    color: var(--itv-text);
    font-weight: 600;
    font-size: 13.5px;
}
.itv-ref {
    display: block;
    color: var(--itv-muted);
    font-size: 11px;
    margin-top: 1px;
}

/* Swatch */
.itv-swatchImg {
    width: 38px; height: 38px;
    border-radius: 6px;
    border: 1px solid var(--itv-border);
    background: #fff;
    object-fit: contain;
    display: block;
}
.itv-swatchColor {
    display: inline-block;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--itv-border);
    box-shadow: inset 0 0 0 2px #fff;
}
.itv-swatchPlaceholder {
    display: inline-block;
    width: 28px; height: 28px;
    background: #f3f3f3;
    border-radius: 50%;
    border: 1.5px dashed var(--itv-border);
}

/* Stock badges */
.itv-stockBadge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.itv-stockBadge--ok {
    background: #e6f6ec;
    color: #2e7d44;
    border: 1px solid #cce8d4;
}
.itv-stockBadge--ko {
    background: #fde8e9;
    color: #a82431;
    border: 1px solid #f5c5c9;
}

/* Quantity selector — botones - input + (más compacto) */
.itv-qty {
    display: inline-flex;
    align-items: stretch;
    border: 1.5px solid var(--itv-border);
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
    height: 30px;
}
.itv-qty__btn {
    width: 28px;
    background: #fff;
    border: none;
    color: var(--itv-text);
    font-weight: 700;
    cursor: pointer;
    font-size: 15px;
    padding: 0;
    line-height: 1;
    transition: background .12s ease, color .12s ease;
}
.itv-qty__btn:hover:not(:disabled) {
    background: rgba(181,25,119,0.08);
    color: var(--itv-magenta);
}
.itv-qty__btn:disabled { opacity: .35; cursor: not-allowed; }
.itv-qty__minus { border-right: 1px solid var(--itv-border); }
.itv-qty__plus  { border-left:  1px solid var(--itv-border); }
.itv-qty__input {
    border: none;
    background: transparent;
    text-align: center;
    width: 42px;
    font-weight: 700;
    font-size: 13px;
    color: var(--itv-text);
    -moz-appearance: textfield;
    appearance: textfield;
}
.itv-qty__input::-webkit-outer-spin-button,
.itv-qty__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Footer sticky (siempre visible debajo) */
.itv-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 12px -18px -12px;
    padding: 12px 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border-top: 1px solid var(--itv-border);
    border-radius: 0 0 12px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.itv-summary {
    font-size: 13.5px;
    color: var(--itv-text);
}
.itv-summary__label { color: var(--itv-muted); }
.itv-summary__qty {
    font-weight: 800;
    color: var(--itv-magenta);
    font-size: 16px;
    margin-right: 2px;
}
.itv-addBtn {
    background: var(--itv-magenta);
    color: #fff;
    border: none;
    padding: 11px 24px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background .15s ease, transform .15s ease, opacity .15s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(181,25,119,0.25);
}
.itv-addBtn:hover:not(:disabled) {
    background: var(--itv-magenta-dark);
    transform: translateY(-1px);
}
.itv-addBtn:disabled {
    opacity: .45;
    cursor: not-allowed;
    box-shadow: none;
}
.itv-addBtn.is-loading { opacity: .7; }
.itv-addBtn .fa { font-size: 13px; }

/* Feedback */
.itv-feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    display: none;
}
.itv-feedback:not(:empty) { display: block; }
.itv-feedback--ok { background: #e6f6ec; color: #2e7d44; border: 1px solid #cce8d4; }
.itv-feedback--ko { background: #fde8e9; color: #a82431; border: 1px solid #f5c5c9; }
.itv-feedback--info { background: #eef4ff; color: #2b4877; border: 1px solid #c9d6f0; }

/* === Ocultar el selector estándar de variaciones cuando este módulo está activo === */
body.itv-active .product-variants,
body.itv-active .product-add-to-cart,
body.itv-active .product-actions .product-quantity,
body.itv-active form#add-to-cart-or-refresh .product-actions { display: none !important; }

/* Responsive */
@media (max-width: 575px) {
    .itv-head { flex-direction: column; align-items: stretch; }
    .itv-search { min-width: 0; width: 100%; }
    .itv-tableWrap { max-height: 360px; }
    .itv-table thead { display: none; }
    .itv-table tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
    .itv-table td { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; }
    .itv-table td.itv-col-swatch { justify-content: flex-start; }
    .itv-footer { flex-direction: column; align-items: stretch; }
    .itv-addBtn { width: 100%; justify-content: center; }
}
