/* ============================================================
   Cambio de precios — Design system
   Paleta: dark navy con acentos azul-cobalto, success mint,
   warning ámbar, danger coral, variations violeta.
   ============================================================ */

:root {
  /* Layers (de fondo a primer plano) */
  --bg:           #0a0d16;
  --bg-elev-1:    #121726;
  --bg-elev-2:    #1a2033;
  --bg-elev-3:    #232c44;
  --bg-variation: #1c1932;       /* fila variación: tinte violeta sutil */
  --bg-dirty:     #2a230f;       /* fila con cambios sin guardar */
  --bg-selected:  #15263e;       /* fila seleccionada */

  /* Bordes */
  --border:       #2a334a;
  --border-soft:  #1e2536;
  --border-strong:#3b4565;

  /* Texto */
  --text:         #e8edf6;
  --text-muted:   #8a94ae;
  --text-subtle:  #5d6680;

  /* Acentos */
  --accent:       #6aa3ff;
  --accent-2:     #4685eb;
  --accent-3:     #2f6ed4;
  --accent-bg:    rgba(106, 163, 255, 0.1);
  --accent-bg-2:  rgba(106, 163, 255, 0.18);

  /* Estados */
  --success:      #52e5b1;
  --success-bg:   rgba(82, 229, 177, 0.12);
  --warning:      #ffc94a;
  --warning-bg:   rgba(255, 201, 74, 0.12);
  --danger:       #ff6b7d;
  --danger-bg:    rgba(255, 107, 125, 0.12);

  /* Variations (violeta) */
  --variation:    #b07cff;
  --variation-2:  #8c5ee5;
  --variation-bg: rgba(176, 124, 255, 0.08);
  --variation-bg-strong: rgba(176, 124, 255, 0.14);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 3px var(--accent-bg-2);

  /* Geometría */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Transiciones */
  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  0.2s  cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(ellipse 1200px 600px at 50% -300px, rgba(106, 163, 255, 0.08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar global más limpio */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-elev-1); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-3); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-2); text-decoration: underline; }

kbd {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  padding: 1px 6px;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* ========== Layout ========== */
.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ========== Header ========== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--text) 0%, var(--text-muted) 200%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.header .sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.header-stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
  align-items: center;
}
.header-stats > div { display: flex; align-items: baseline; gap: 6px; }
.header-stats strong { font-size: 16px; font-weight: 600; }
.warn-text { color: var(--warning); }

/* ========== Toolbars ========== */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  border-radius: var(--r-lg);
  padding: 12px;
  border: 1px solid var(--border-soft);
}
.toolbar.primary {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  box-shadow: var(--shadow-sm);
}
.toolbar.filters {
  background: var(--bg-elev-1);
  border-style: dashed;
}
.spacer { flex: 1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field .lbl {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* ========== Inputs y selects ========== */
.input, .select {
  background: var(--bg-elev-1);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus {
  border-color: var(--accent);
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-glow);
}
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input.search {
  min-width: 280px;
  flex: 1;
  max-width: 420px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94ae' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px 50%;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94ae' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ========== Botones ========== */
.btn {
  background: var(--accent-2);
  color: white;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  letter-spacing: 0.005em;
}
.btn:hover { background: var(--accent); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary {
  background: linear-gradient(180deg, var(--success), #3dd29a);
  color: #052016;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 12px rgba(82, 229, 177, 0.3);
}
.btn.primary:hover { filter: brightness(1.1); }

.btn.secondary {
  background: var(--bg-elev-2);
  border-color: var(--border);
  color: var(--text);
}
.btn.secondary:hover { background: var(--bg-elev-3); border-color: var(--border-strong); }

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); background: var(--accent-bg); }

/* ========== Bulk action bar ========== */
.bulk-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent-bg-2), rgba(176, 124, 255, 0.08));
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(106, 163, 255, 0.2) inset;
  animation: slide-down 0.25s ease-out;
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.bulk-info { display: flex; gap: 16px; font-size: 13px; align-items: center; }
.bulk-info span:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bulk-info span:not(:empty)::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.bulk-info .warn-text::before { background: var(--warning); }
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ========== Stats bar ========== */
.stats-bar {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 6px 14px;
  flex-wrap: wrap;
  background: var(--bg-elev-1);
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
}
.stats-bar > span { white-space: nowrap; }

/* ========== Tabla ========== */
.table-wrap {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

thead { position: sticky; top: 0; z-index: 5; }
thead::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--border);
}
th {
  background: var(--bg-elev-2);
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr { transition: background var(--t-fast); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(106, 163, 255, 0.04); }

/* Variation rows: tinte violeta + indent + barra lateral */
tr.variation-row {
  background: var(--variation-bg);
}
tr.variation-row td { background: var(--variation-bg); }
tr.variation-row:hover td { background: var(--variation-bg-strong); }
tr.variation-row td:first-child {
  padding-left: 32px;
  position: relative;
}
tr.variation-row td:first-child::before {
  content: '';
  position: absolute;
  left: 14px; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--variation), var(--variation-2));
  border-radius: 2px;
}

/* Dirty rows: tinte ámbar + barra lateral */
tr.dirty-row td {
  background: var(--bg-dirty) !important;
  position: relative;
}
tr.dirty-row td:first-child::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--warning);
}

/* ========== Thumbnails ========== */
.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  transition: transform var(--t-med), box-shadow var(--t-med);
}
.thumb:hover {
  transform: scale(2.4);
  z-index: 10;
  position: relative;
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

/* ========== Texto auxiliar ========== */
.muted { color: var(--text-muted); font-size: 12px; }
.sku {
  color: var(--text-muted);
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11.5px;
  letter-spacing: -0.01em;
}
.prod-name {
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.prod-name a { color: var(--text); }
.prod-name a:hover { color: var(--accent); }

/* ========== Categorías ========== */
.cat-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.cat-chip {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-bg-2);
  border-radius: var(--r-xs);
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast);
}
.cat-chip:hover { background: var(--accent-bg-2); }

/* ========== Price input ========== */
.price-input {
  width: 116px;
  text-align: right;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.price-input.dirty {
  border-color: var(--warning);
  background: var(--warning-bg);
  color: var(--text);
  animation: dirty-pulse 1.4s ease-in-out infinite;
}
@keyframes dirty-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 74, 0); }
  50% { box-shadow: 0 0 0 3px rgba(255, 201, 74, 0.15); }
}

/* ========== Row actions ========== */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.row-actions .btn { padding: 6px 12px; font-size: 13px; }

/* ========== Status pills ========== */
.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.status.ok { background: var(--success-bg); color: var(--success); border-color: rgba(82, 229, 177, 0.2); }
.status.warn { background: var(--warning-bg); color: var(--warning); border-color: rgba(255, 201, 74, 0.2); }
.status.err { background: var(--danger-bg); color: var(--danger); border-color: rgba(255, 107, 125, 0.2); }
.status.muted { background: rgba(138, 148, 174, 0.12); color: var(--text-muted); border-color: rgba(138, 148, 174, 0.2); }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
  padding: 8px 0;
}
.pagination .btn { min-width: 36px; padding: 8px 10px; }

/* ========== Banner ========== */
.banner {
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner.err {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.banner.err::before { content: '⚠'; font-size: 18px; }

/* ========== Empty / loading ========== */
.empty, .loading {
  padding: 64px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty::before {
  content: '';
  display: block;
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 24 24' fill='none' stroke='%235d6680' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/><line x1='8' y1='11' x2='14' y2='11'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
}
.loading::before {
  content: '';
  display: block;
  width: 28px; height: 28px;
  margin: 0 auto 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Expand button (chevron) ========== */
.expand-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  width: 26px; height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.expand-btn:hover {
  color: var(--variation);
  border-color: var(--variation);
  background: var(--variation-bg);
}

/* CTA "Editar variaciones" para productos variables */
.variations-cta {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--variation);
  border: 1px dashed var(--variation);
  background: var(--variation-bg);
  font-weight: 500;
}
.variations-cta:hover {
  background: var(--variation-bg-strong);
  border-style: solid;
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(176, 124, 255, 0.15);
}

/* ========== Variation attribute chips ========== */
.attrs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.attr-chip {
  background: var(--variation-bg-strong);
  border: 1px solid rgba(176, 124, 255, 0.25);
  color: var(--variation);
  border-radius: var(--r-xs);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
}

/* ========== Footer tip ========== */
.footer-tip {
  margin-top: 24px;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-subtle);
  border-top: 1px solid var(--border-soft);
}

/* ========== Toasts ========== */
.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  pointer-events: auto;
  padding: 12px 16px 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-left-width: 4px;
}
.toast.ok { border-left-color: var(--success); }
.toast.ok::before { content: '✓ '; color: var(--success); font-weight: 700; }
.toast.err { border-left-color: var(--danger); }
.toast.err::before { content: '✕ '; color: var(--danger); font-weight: 700; }
.toast.info { border-left-color: var(--accent); }
.toast.info::before { content: 'ⓘ '; color: var(--accent); font-weight: 700; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== Checkbox ========== */
input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* ========== Selección visible ========== */
tbody tr.selected td { background: var(--bg-selected) !important; }
tbody tr.selected td:first-child::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

/* ========== Responsive (mínimo) ========== */
@media (max-width: 900px) {
  .app { padding: 16px 12px 32px; }
  .header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-stats { flex-wrap: wrap; }
  .input.search { min-width: 200px; }
  .thumb:hover { transform: scale(1.6); }
}
