/**
 * ps_bulkordermatrix — Estilos aislados con prefijo .bom-
 * Compatible con cualquier tema de PS8/9.
 */

.bom-matrix-wrapper {
    margin: 24px 0;
    padding: 20px 22px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    font-family: inherit;
    box-sizing: border-box;
}

/* ── Botón disparador (modo "modal" en la ficha de producto) ── */
.bom-trigger-wrapper { margin: 24px 0; }
.bom-trigger-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color .15s, background .15s;
}
.bom-trigger-btn:hover { border-color: #333; background: #fafafa; }
.bom-trigger-btn .bom-icon { color: #555; }
.bom-trigger-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bom-trigger-arrow {
    margin-left: auto;
    font-size: 20px;
    line-height: 1;
    color: #999;
}

/* ── Cabecera ── */
.bom-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.bom-icon {
    display: flex;
    color: #555;
    flex-shrink: 0;
}
.bom-icon svg { width: 18px; height: 18px; }
.bom-title {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Filtros ── */
.bom-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}
.bom-filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.bom-selector-label {
    font-size: 13px;
    font-weight: 500;
    color: #444;
    flex-shrink: 0;
}
.bom-primary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.bom-primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1.5px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: border-color .15s, background .15s, color .15s;
    line-height: 1.4;
}
.bom-primary-btn:hover {
    border-color: #888;
    background: #f5f5f5;
}
.bom-primary-btn--active {
    border-color: #333;
    background: #333;
    color: #fff;
}
.bom-primary-btn--active .bom-swatch {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #333;
}
.bom-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.bom-swatch--texture {
    background-size: cover;
    background-position: center;
}
.bom-primary-btn--stacked {
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 10px;
}
.bom-swatch--image {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
}
.bom-primary-btn--active .bom-swatch--image {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #333;
}

/* ── Cuadrícula ── */
.bom-grid-wrap { margin-bottom: 16px; }
.bom-matrix-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.bom-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
}
.bom-cell-label {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    text-align: center;
    white-space: nowrap;
}
.bom-cell-stock {
    font-size: 11px;
    text-align: center;
}
.bom-cell-stock--low { color: #c0392b; }
.bom-cell-stock--ok  { color: #27ae60; }

.bom-qty-input {
    width: 64px;
    height: 36px;
    text-align: center;
    border: 1.5px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #222;
    background: #fff;
    padding: 0 4px;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
    -moz-appearance: textfield;
}
.bom-qty-input::-webkit-outer-spin-button,
.bom-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.bom-qty-input:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(51,51,51,0.12);
}
.bom-qty-input:disabled,
.bom-cell--unavailable .bom-qty-input {
    background: #f2f2f2;
    color: #bbb;
    border-color: #e0e0e0;
    cursor: not-allowed;
}
.bom-cell--unavailable .bom-cell-label { color: #bbb; }
.bom-cell--unavailable .bom-cell-stock { color: #ccc; }
.bom-grid-empty {
    font-size: 13px;
    color: #888;
    padding: 10px 0;
}

/* ── Footer ── */
.bom-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}
.bom-summary { font-size: 13px; color: #555; }
.bom-summary-units {
    font-weight: 700;
    color: #222;
    margin-right: 3px;
}
.bom-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    line-height: 1;
}
.bom-add-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.bom-add-btn:hover:not(:disabled) { background: #111; }
.bom-add-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bom-add-btn--loading { opacity: 0.7; pointer-events: none; }

/* ── Feedback ── */
.bom-feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
}
.bom-feedback--success {
    background: #eafaf1;
    border: 1px solid #a9dfbf;
    color: #1e8449;
}
.bom-feedback--error {
    background: #fdedec;
    border: 1px solid #f5b7b1;
    color: #c0392b;
}
.bom-hidden { display: none !important; }

/* ── Selector nativo de color con miniaturas (opción independiente) ── */
.bom-native-swatch-image {
    background-repeat: no-repeat !important;
}

/* ── Vista previa de color en el listado (capa superpuesta, no toca la <img> del tema) ── */
.bom-hover-preview {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 4;
}
.bom-hover-preview--visible { opacity: 1; }

/* ── Icono "Pedido rápido" en el listado de categoría ── */
.bom-listing-icon-btn {
    position: absolute;
    z-index: 5;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background .15s, color .15s, transform .15s;
}
.bom-listing-icon-btn svg { width: 17px; height: 17px; }
.bom-listing-icon-btn:hover {
    background: #333;
    color: #fff;
    transform: scale(1.06);
}

/* Posición configurable (BOMATRIX_ICON_POSITION): 4 esquinas + 4 centros de lado */
.bom-listing-icon-btn--top-left      { top: 8px;    left: 8px; }
.bom-listing-icon-btn--top-center    { top: 8px;    left: 50%; transform: translateX(-50%); }
.bom-listing-icon-btn--top-right     { top: 8px;    right: 8px; }
.bom-listing-icon-btn--middle-left   { top: 50%;    left: 8px;  transform: translateY(-50%); }
.bom-listing-icon-btn--middle-right  { top: 50%;    right: 8px; transform: translateY(-50%); }
.bom-listing-icon-btn--bottom-left   { bottom: 8px; left: 8px; }
.bom-listing-icon-btn--bottom-center { bottom: 8px; left: 50%; transform: translateX(-50%); }
.bom-listing-icon-btn--bottom-right  { bottom: 8px; right: 8px; }

.bom-listing-icon-btn--top-center:hover,
.bom-listing-icon-btn--bottom-center:hover {
    transform: translateX(-50%) scale(1.06);
}
.bom-listing-icon-btn--middle-left:hover,
.bom-listing-icon-btn--middle-right:hover {
    transform: translateY(-50%) scale(1.06);
}

/* ── Modal "Pedido rápido" (listado) ── */
.bom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.bom-modal-box {
    position: relative;
    background: #fff;
    border-radius: 6px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.bom-modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: none;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    z-index: 1;
}
.bom-modal-close:hover { color: #222; }
.bom-modal-body { padding: 28px 22px 22px; }
.bom-modal-title {
    margin: 0 0 14px;
    padding-right: 24px;
    font-size: 17px;
    font-weight: 600;
    color: #222;
}
.bom-modal-loading,
.bom-modal-error {
    padding: 30px 10px;
    text-align: center;
    font-size: 14px;
    color: #666;
}
.bom-modal-error { color: #c0392b; }
.bom-modal-widget-container .bom-matrix-wrapper {
    margin: 0;
    border: none;
    padding: 0;
}

@media (max-width: 480px) {
    .bom-matrix-wrapper { padding: 14px 12px 12px; }
    .bom-cell { min-width: 58px; }
    .bom-qty-input { width: 54px; height: 32px; font-size: 13px; }
    .bom-footer { flex-direction: column; align-items: flex-start; }
    .bom-add-btn { width: 100%; justify-content: center; }
}
