/* ═══════════════════════════════════════════════════════
   SUPPLIER PRODUCTS — Vincular fichas (F2.1)
   index (tabla + candidato OEM + lote) · show · images
   Solo tokens del design system: cero hex, cero !important.
   ═══════════════════════════════════════════════════════ */

/* ── INDEX: búsqueda ─────────────────────────────────────── */
.sps-search-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-wrap: wrap;
}

.sps-search-input {
  min-width: 230px;
}

/* ── INDEX: barra de lote ───────────────────────────────── */
.sps-bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: var(--c-primary-bg);
  border: 1px solid var(--c-primary-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.sps-bulk-hint {
  font-size: var(--text-xs);
  color: var(--gray-600);
  flex: 1;
  min-width: 200px;
}

/* ── INDEX: tabla ───────────────────────────────────────── */
.sps-table-card {
  padding: 0;
  overflow: hidden;
}

.sps-check-cell {
  width: 34px;
  text-align: center;
}

.sps-check {
  width: 15px;
  height: 15px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.sps-supplier-link {
  color: var(--color-text);
  text-decoration: none;
}

.sps-supplier-link:hover { color: var(--color-primary); }

.sps-supplier-link--strong {
  color: var(--color-primary);
  font-weight: 500;
}

.sps-badge-link {
  text-decoration: none;
}

.sps-cell-muted {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sps-date-cell {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.sps-icon-warning { color: var(--c-warning); }

.sps-sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sps-sort-link:hover { color: var(--color-primary); }

.sps-sort-link--active { color: var(--color-primary); }

/* Candidato OEM inline (tab Pendientes) */
.sps-candidate-cell { max-width: 320px; }

.sps-candidate-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sps-candidate-inline .btn { flex-shrink: 0; }

.sps-candidate-ref {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-decoration: none;
}

.sps-candidate-inline-name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.25;
}

.sps-candidate-ref:hover .sps-candidate-inline-name { color: var(--color-primary); }

/* ── SHOW: header ───────────────────────────────────────── */
.spshow-header-main {
  min-width: 0;
  flex: 1;
}

.spshow-title {
  font-size: var(--text-xl);
  word-break: break-word;
  line-height: 1.3;
}

.spshow-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.spshow-meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.spshow-meta-label {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.spshow-meta-dot { color: var(--color-border); }

.oem-chip--more { color: var(--color-text-muted); }

.spshow-header-actions { flex-shrink: 0; }

/* ── SHOW: KPI strip ────────────────────────────────────── */
.sps-kpi-strip {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
}

.sps-kpi {
  padding: var(--space-4) var(--space-5);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.sps-kpi:last-child { border-right: none; }

.sps-kpi--price {
  background: linear-gradient(145deg, var(--color-primary-dark), var(--color-primary));
  border-right-color: rgba(255, 255, 255, 0.12);
}

.sps-kpi--stock-ok {
  background: linear-gradient(145deg, var(--state-emerald), var(--c-success));
  border-right-color: rgba(255, 255, 255, 0.12);
}

.sps-kpi-eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
  display: block;
}

.sps-kpi--price .sps-kpi-eyebrow,
.sps-kpi--stock-ok .sps-kpi-eyebrow { color: rgba(255, 255, 255, 0.65); }

.sps-kpi-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 500;
  line-height: 1;
  color: var(--color-text);
  letter-spacing: -0.03em;
}

.sps-kpi-number--md {
  font-size: var(--text-lg);
  padding-top: var(--space-1);
}

.sps-kpi-number--empty {
  font-size: var(--text-base);
  padding-top: var(--space-1);
  color: var(--color-text-muted);
}

.sps-kpi--price .sps-kpi-number,
.sps-kpi--stock-ok .sps-kpi-number {
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sps-kpi-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  line-height: 1.3;
}

.sps-kpi-sub--strong {
  margin-top: var(--space-2);
  font-weight: 600;
  color: var(--color-text);
}

.sps-kpi--price .sps-kpi-sub,
.sps-kpi--stock-ok .sps-kpi-sub { color: rgba(255, 255, 255, 0.65); }

.sps-kpi-badge { margin-top: var(--space-2); }

.sps-kpi-copy {
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-2);
  width: fit-content;
}

.sps-kpi-copy-btn {
  opacity: 0.7;
  filter: invert(1);
}

/* ── SHOW: layout ───────────────────────────────────────── */
.spshow-grid {
  display: grid;
  grid-template-columns: 1fr 272px;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-4);
}

.spshow-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.spshow-aside {
  position: sticky;
  top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.spshow-card { margin-bottom: 0; }

/* ── SHOW: card de vinculación ──────────────────────────── */
.spshow-link-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.spshow-link-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: white;
}

.spshow-link-header--linked { background: var(--c-success); }

.spshow-link-header--unlinked { background: var(--c-warning); }

.spshow-link-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
}

.spshow-link-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
}

.spshow-link-sub {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
}

.spshow-link-body {
  padding: var(--space-4);
  background: var(--color-surface);
}

/* Producto maestro vinculado */
.spshow-product-ref {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.spshow-product-ref:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.spshow-product-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--color-primary-light);
  border: 1px solid var(--c-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary);
}

.spshow-product-ref-info { min-width: 0; }

.spshow-product-ref-sku {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-primary);
  display: block;
}

.spshow-product-ref-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  display: block;
  line-height: 1.3;
}

.spshow-product-ref-cat {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: 2px;
}

.spshow-product-ref-chevron {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-left: auto;
}

/* Candidatos por OEM (show) */
.sps-candidates {
  margin-bottom: var(--space-3);
}

.sps-candidates-title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-cost);
  margin-bottom: var(--space-2);
}

.sps-candidate {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.sps-candidate + .sps-candidate { margin-top: var(--space-2); }

.sps-candidate .btn { flex-shrink: 0; }

.sps-candidate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}

.sps-candidate-sku {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-primary);
}

.sps-candidate-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.sps-candidate-info:hover .sps-candidate-name { color: var(--color-primary); }

.sps-candidate-oem {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* Autocomplete (show) */
.sps-ac-form {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  flex-wrap: wrap;
}

.sps-ac {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.sps-ac-input { width: 100%; }

.sps-ac-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: var(--z-overlay);
}

.sps-ac-group {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.sps-ac-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

.sps-ac-option:hover { background: var(--color-primary-light); }

.sps-ac-option--candidate { background: var(--c-cost-bg); }

.sps-ac-option--candidate:hover { background: var(--color-primary-light); }

.sps-ac-option-sku {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-primary);
}

.sps-ac-option-name {
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.3;
}

.sps-ac-empty {
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sps-ac-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  line-height: 1.4;
}

/* ── SHOW: detail grid extras ───────────────────────────── */
.sps-detail-inline {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.sps-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.sps-detail-muted {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── SHOW: margen ───────────────────────────────────────── */
.sps-margin-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.sps-margin-input { width: 180px; }

.sps-margin-pct {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.sps-form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.sps-form-hint--spaced { margin-top: var(--space-3); }

.sps-breakdown { margin-top: var(--space-4); }

.sps-breakdown-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.sps-store-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  background: var(--color-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--color-text-muted);
}

.sps-store-margin-badge { margin-left: auto; }

.spshow-store-block {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-top: var(--space-2);
}

.spshow-store-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.spshow-price-breakdown {
  display: flex;
  flex-direction: column;
}

.spshow-price-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.spshow-price-row:last-child { border-bottom: none; }

.spshow-price-operator {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.spshow-price-operator--plus {
  background: var(--c-success-bg);
  border-color: var(--c-success-border);
  color: var(--c-success);
}

.spshow-price-operator--iva {
  background: var(--c-info-bg);
  border-color: var(--c-info-border);
  color: var(--c-info);
}

.spshow-price-operator--eq {
  background: var(--c-primary-bg);
  border-color: var(--c-primary-border);
  color: var(--color-primary);
  font-size: var(--text-base);
}

.spshow-price-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex: 1;
}

.spshow-price-label--total {
  font-weight: 600;
  color: var(--color-text);
}

.spshow-price-row--iva .spshow-price-label,
.spshow-price-row--iva .spshow-price-value { color: var(--c-info); }

.spshow-price-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.spshow-price-value--total {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ── SHOW: compatibilidades crudas ──────────────────────── */
.sps-compat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.sps-compat-title { margin: 0; }

.sps-compat-action { margin-left: auto; }

.sps-compat-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.sps-count-pill {
  font-size: 0.72rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px var(--space-2);
  color: var(--color-text-muted);
  font-weight: 600;
}

.spshow-compat-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.spshow-compat-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: background 0.12s;
}

.spshow-compat-row:last-child { border-bottom: none; }
.spshow-compat-row:hover { background: var(--color-bg); }

.spshow-compat-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  text-transform: uppercase;
}

.spshow-compat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.spshow-compat-brand {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  line-height: 1;
}

.spshow-compat-model {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spshow-compat-years { flex-shrink: 0; }

/* ── SHOW: datos crudos ─────────────────────────────────── */
.sps-raw-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
  list-style: none;
}

.sps-raw-summary::-webkit-details-marker { display: none; }

.sps-raw-title {
  margin: 0;
  pointer-events: none;
}

.sps-raw-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sps-raw-chevron {
  color: var(--color-text-muted);
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.spshow-raw details[open] .sps-raw-chevron { transform: rotate(180deg); }

.spshow-raw pre {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: var(--space-4);
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  line-height: 1.6;
  max-height: 360px;
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-3);
}

/* ── SHOW: galería ──────────────────────────────────────── */
.spshow-gallery-card { padding: var(--space-3); }

.sps-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.sps-gallery-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

.spshow-gallery-main {
  position: relative;
  aspect-ratio: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.spshow-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: var(--space-2);
}

.spshow-gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.18s ease;
  flex-direction: column;
}

.spshow-gallery-main:hover .spshow-gallery-overlay { opacity: 1; }

.spshow-gallery-thumbs {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.spshow-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.spshow-thumb:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.spshow-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spshow-thumb-more {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  border: 1px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.sps-gallery-cta {
  width: 100%;
  margin-top: var(--space-2);
  justify-content: center;
}

/* Placeholder sin fotos */
.sps-no-photos {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.sps-no-photos-icon { color: var(--color-border); }

.sps-no-photos-text {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.sps-no-photos-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ── IMAGES: header ─────────────────────────────────────── */
.sps-title-icon {
  color: var(--color-text-muted);
  vertical-align: -3px;
}

.sps-images-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 860px) {
  .sps-kpi-strip { grid-template-columns: 1fr 1fr; }
  .sps-kpi { border-bottom: 1px solid var(--color-border); }
  .sps-kpi:nth-child(2n) { border-right: none; }
  .sps-kpi:nth-last-child(-n+2) { border-bottom: none; }

  .spshow-grid { grid-template-columns: 1fr; }

  /* Las fotos quedan DEBAJO del contenido principal en mobile */
  .spshow-aside {
    position: static;
    order: 2;
  }

  .spshow-gallery-main { max-width: 100%; }
}

@media (max-width: 600px) {
  .sps-kpi-strip { grid-template-columns: 1fr; }
  .sps-kpi { border-right: none; }
  .sps-kpi:last-child { border-bottom: none; }

  .sps-ac { min-width: 100%; }
  .sps-search-input { min-width: 0; flex: 1; }
  .sps-search-form { width: 100%; margin-left: 0; }
}
