/* =========================================================
   MODULES — Scanner, costos, curva ABC, métricas drag,
             stock, PEF, publicaciones, notas, calidad ML
   ========================================================= */

/* ── OPERACIONES (scanner) ── */
.scan-box {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: background 0.25s, border-color 0.25s;
}
.scan-box h3 { font-size: 15px; font-weight: 600; margin-bottom: 1rem; color: var(--text); }
.scan-input-row { display: flex; gap: 8px; align-items: center; }
.scan-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s, color 0.25s;
}
.scan-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  display: none;
  background: var(--surface2);
}
.scan-result.show { display: block; }
.scan-product-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.scan-product-info { font-size: 12px; color: var(--muted); }
.qty-row { display: flex; align-items: center; gap: 10px; margin-top: 1rem; flex-wrap: wrap; }
.qty-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.qty-btn:hover { background: var(--bg); }
.qty-val { font-size: 20px; font-weight: 600; min-width: 40px; text-align: center; color: var(--text); }
.scan-log-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-sku { font-family: monospace; font-size: 11px; color: var(--muted); }
.log-qty-pos { color: var(--green-txt); font-weight: 600; }
.log-qty-neg { color: var(--red-txt); font-weight: 600; }

/* ── COSTOS ── */
.cost-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; margin-bottom: 1rem; }
.cost-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: background 0.25s, border-color 0.25s;
}
.cost-card-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.cost-card-val { font-size: 20px; font-weight: 600; color: var(--text); }

/* ── CURVA ABC ── */
.curva-cards { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.curva-card { background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius-lg); padding:1rem; }
.curva-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:.75rem; }
.curva-count { font-size:12px; color:var(--muted); }
.curva-item { display:flex; justify-content:space-between; align-items:center; padding:5px 0; border-bottom:0.5px solid var(--border); font-size:12px; }
.curva-item:last-child { border:none; }

/* ── DROP ZONE ── */
.drop-zone { border:2px dashed var(--border); border-radius:var(--radius-lg); padding:2.5rem; text-align:center; cursor:pointer; transition:border-color .15s; }
.drop-zone:hover { border-color:var(--primary); }
.drop-icon { font-size:2.5rem; margin-bottom:.5rem; }
.drop-sub { font-size:12px; color:var(--muted); margin-top:.25rem; }

/* ── ALERTAS DECISIONES ── */
.alerta-item { display:flex; align-items:center; gap:12px; padding:12px; background:var(--surface); border:0.5px solid var(--border); border-radius:var(--radius); margin-bottom:8px; }
.alerta-tipo { font-weight:500; font-size:13px; flex:1; text-transform:capitalize; }

/* ── SIDEBAR COLLAPSIBLE ── */
.sidebar-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 1rem;
  transition: color 0.15s;
}
.sidebar-toggle:hover { color: var(--text); }

.toggle-arrow {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s ease;
  display: inline-block;
}

.sidebar-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.sidebar-items.collapsed {
  max-height: 0;
  opacity: 0;
}
.toggle-arrow.collapsed {
  transform: rotate(-90deg);
}

/* ── MÉTRICAS: GRID 2x6 ── */
.metricas-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 10px;
  margin-bottom: 1.25rem;
}

/* ── Tarjeta base ── */
.mc {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  cursor: pointer;
  position: relative;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  user-select: none;
  /* Transición suave de todo */
  transition: border-color 0.18s, background 0.18s, transform 0.18s, box-shadow 0.18s;
}

/* ── Hover: vibra y cambia color notablemente ── */
.mc:not(.mc-hidden):not(.mc-empty):hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-3px) scale(1.025);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  animation: mc-pulse 0.3s ease;
}

@keyframes mc-pulse {
  0%   { transform: translateY(0) scale(1); }
  30%  { transform: translateY(-4px) scale(1.03) rotate(-0.5deg); }
  60%  { transform: translateY(-2px) scale(1.02) rotate(0.5deg); }
  100% { transform: translateY(-3px) scale(1.025); }
}

.mc.active-filter {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary);
}

/* Drag over */
.mc.mc-drag-over,
.mc-empty.mc-drag-over {
  border: 2px dashed var(--primary) !important;
  background: var(--primary-light) !important;
  transform: scale(1.02);
}

/* ── Slot vacío ── */
.mc-empty {
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: border-color 0.18s, background 0.18s;
}
.mc-empty:hover {
  border-color: var(--muted);
}
.mc-empty-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* ── Handle de arrastre ── */
.mc-drag {
  position: absolute;
  top: 6px; left: 7px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s;
  cursor: grab;
}
.mc:hover .mc-drag { opacity: 0.7; }
.mc-drag:active { cursor: grabbing; }

/* ── Botón ojo ── */
.mc-eye {
  position: absolute;
  top: 5px; right: 7px;
  background: none;
  border: none;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  padding: 2px 3px;
  border-radius: 4px;
  line-height: 1;
  /* Puntero de mano con indicador de acción */
  cursor: pointer;
}
.mc:hover .mc-eye { opacity: 1; }
/* Al pasar sobre el ojo: agrandar y mostrar tooltip visual */
.mc-eye:hover {
  opacity: 1 !important;
  transform: scale(1.3);
  background: var(--bg);
  cursor: pointer;
}
/* Cuando está oculta, el ojo siempre visible */
.mc.mc-hidden .mc-eye { opacity: 1; }

/* ── Labels ── */
.mc-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.3;
}
.mc-val {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.mc-val.g  { color: var(--green-txt); }
.mc-val.y  { color: var(--yellow-txt); }
.mc-val.r  { color: var(--red-txt); }
.mc-val.b  { color: var(--blue-txt); }
.mc-val.o  { color: var(--primary-hover); }

/* ── Tarjeta oculta ── */
.mc.mc-hidden {
  opacity: 0.3;
  cursor: default;
  filter: grayscale(0.8);
}
.mc.mc-hidden:hover {
  border-color: var(--border) !important;
  background: var(--surface) !important;
  transform: none !important;
  box-shadow: none !important;
  animation: none !important;
}
.mc-hidden-label {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 1100px) {
  .metricas-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 700px) {
  .metricas-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── ALERTA CORTE FULL ── */
.alerta-corte {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--yellow-bg);
  border: 1.5px solid var(--yellow-txt);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 1rem;
  font-size: 13px;
  color: var(--yellow-txt);
}
.alerta-corte strong { font-weight: 700; }

/* ── STOCK SUMMARY BAR ── */
.stock-summary-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 13px;
}
.stock-summary-item { display: flex; align-items: center; gap: 5px; }
.stock-summary-sep  { color: var(--muted); font-weight: 600; }

/* ── DÍAS DE STOCK ── */
.dias-stock-cell { display: flex; flex-direction: column; gap: 2px; }
.dias-stock-row  { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.dias-label      { font-size: 10px; color: var(--muted); min-width: 26px; }

/* ── PRÓXIMO ENVÍO FULL ── */
.pef-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  flex-wrap: wrap;
}
.pef-item:last-child { border-bottom: none; }
.pef-main   { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.pef-nombre { font-weight: 500; font-size: 13px; color: var(--text); }
.pef-stock  { display: flex; gap: 12px; font-size: 12px; }
.pef-actions { display: flex; align-items: center; gap: 6px; }

/* ── PUBLICACIONES: TOPBAR ── */
.pub-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.pub-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}
.pub-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ── METRICAS PUBLICACIONES (4 tarjetas, 1 fila) ── */
.metricas-pub {
  grid-template-columns: repeat(5, 1fr) !important;
  margin-bottom: 1rem;
}
@media (max-width: 1100px) {
  .metricas-pub { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 700px) {
  .metricas-pub { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ID ML copiable */
.ml-id-copy {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  border: 0.5px solid var(--border);
  background: var(--surface);
  display: inline-block;
  transition: background 0.15s;
}
.ml-id-copy:hover { background: var(--primary-light); border-color: var(--primary); }

/* Botón nota */
.btn-nota {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-nota-vacia {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-nota-vacia:hover { border-color: var(--primary); color: var(--primary); }
.btn-nota-activa {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.4);
  color: var(--primary);
  font-weight: 500;
}
.btn-nota-activa:hover { background: rgba(59,130,246,0.2); }

/* Calidad ML */
.calidad-cell { display: flex; flex-direction: column; gap: 5px; }
.calidad-bar-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}
.calidad-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
.calidad-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-block;
  white-space: nowrap;
}

/* Acción en columna vertical */
.accion-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 130px;
}
.btn-accion {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, filter 0.15s;
  text-decoration: none;
}
.btn-accion:hover { opacity: 0.85; filter: brightness(1.08); }
.btn-accion:disabled { opacity: 0.4; cursor: default; }

.btn-accion-ver {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-accion-gestionar {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

/* ── ID ML formato #número + ícono copiar ── */
.ml-id-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.ml-id-num {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
}
.ml-id-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.ml-id-copy-btn:hover { opacity: 1; color: var(--primary); }

/* ── ID ML ── */
.ml-id {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
}
.ml-id:hover { color: var(--primary); }

/* ── Botones acción publicaciones ── */
.btn-accion-editar {
  color: #fff;
  background: #3B82F6;
  border: none;
}
.btn-accion-ver, .btn-accion-gestionar {
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--text);
}
.btn-accion-gestionar { color: var(--muted); }

/* ── Modal nota checkboxes ── */
.nota-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.nota-check-row:hover { background: var(--bg); }
.nota-check-row input[type="checkbox"] { width:16px; height:16px; margin-top:2px; flex-shrink:0; cursor:pointer; }
.nota-urgente-row:has(input:checked)    { background:rgba(220,53,69,0.08);  border-color:rgba(220,53,69,0.4); }
.nota-importante-row:has(input:checked) { background:rgba(255,152,0,0.08);  border-color:rgba(255,152,0,0.4); }
.nota-mejora-row:has(input:checked)     { background:rgba(59,130,246,0.08); border-color:rgba(59,130,246,0.4); }
.nota-revisar-row:has(input:checked)    { background:rgba(255,152,0,0.08);  border-color:rgba(255,152,0,0.4); }
.nota-realizada-row:has(input:checked)  { background:rgba(40,167,69,0.08);  border-color:rgba(40,167,69,0.4); }

/* Badges de nota en tabla */
.nota-badge-urgente, .nota-badge-importante, .nota-badge-revisar {
  font-size: 13px; margin-right: 2px;
}

/* ── Botones acción activos (azul) ── */
.btn-accion-ver-active,
.btn-accion-gestionar-active {
  color: #fff !important;
  background: #3B82F6 !important;
  border-color: #3B82F6 !important;
  text-decoration: none;
}
.btn-accion-ver-active:hover,
.btn-accion-gestionar-active:hover {
  background: #2563EB !important;
  opacity: 1 !important;
}

/* ── Botón Notas con notas activas → naranja ── */
.btn-nota-con-nota {
  background: rgba(234, 88, 12, 0.12);
  border-color: rgba(234, 88, 12, 0.5);
  color: #ea580c;
  font-weight: 600;
}
.btn-nota-con-nota:hover {
  background: rgba(234, 88, 12, 0.22);
}
.btn-nota-devuelta {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.5);
  color: #dc2626;
  font-weight: 600;
}
.btn-nota-devuelta:hover { background: rgba(220, 38, 38, 0.22); }
.btn-nota-pendiente {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.5);
  color: #2563eb;
  font-weight: 600;
}
.btn-nota-pendiente:hover { background: rgba(37, 99, 235, 0.22); }
.btn-nota-revision {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.5);
  color: #d97706;
  font-weight: 600;
}
.btn-nota-revision:hover { background: rgba(217, 119, 6, 0.22); }
.btn-nota-aprobada {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.5);
  color: #16a34a;
  font-weight: 600;
}
.btn-nota-aprobada:hover { background: rgba(22, 163, 74, 0.22); }
.nota-pregunta-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6366f1;
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-left: 3px;
  vertical-align: middle;
}
.nota-panel-mlid {
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: color 0.15s;
}
.nota-panel-mlid:hover {
  color: #2563eb;
  text-decoration: underline;
}
.nota-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #534AB7;
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}
.nota-pregunta-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  margin-top: 6px;
}
.nota-respuesta-box {
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid rgba(22, 163, 74, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #15803d;
  margin-top: 4px;
}
.dark .nota-respuesta-box { color: #86efac; }
.nota-devolucion-box {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 6px;
}
.dark .nota-devolucion-box {
  background: rgba(234, 179, 8, 0.08);
  color: #fcd34d;
}
.nota-contador-banner {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  cursor: default;
}
.nota-banner-superadmin {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.35);
  color: #92400e;
  cursor: pointer;
}
.nota-banner-superadmin:hover { background: rgba(217, 119, 6, 0.18); }
.dark .nota-banner-superadmin { color: #fcd34d; }
.nota-banner-usuario {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: #1e40af;
}
.dark .nota-banner-usuario { color: #93c5fd; }
