/* ============================================================
   bodega.css — vista del bodeguero + mapa LED
   ============================================================ */

.bodeguero-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.bodeguero-kpis .kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--highlight);
}
.bodeguero-kpis .kpi.warn {
  border-left-color: var(--warning);
}
.bodeguero-kpis .kpi.danger {
  border-left-color: var(--danger);
}
.bodeguero-kpis .kpi .label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.bodeguero-kpis .kpi .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}
.bodeguero-kpis .kpi .sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Inventario grid */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.inv-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inv-card .name {
  font-weight: 700;
  font-size: 1rem;
}
.inv-card .cat {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
}
.inv-card .bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.inv-card .bar > div {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}
.inv-card .bar.low > div {
  background: var(--danger);
}
.inv-card .bar.warn > div {
  background: var(--warning);
}
.inv-card .qty {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}
.inv-card .actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
/* Inventario subcontrato — sección separada visualmente del inventario propio */
.inv-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Sección subcontrato — tonos derivados de la paleta (antes morado fuera de
   paleta; FASE 8: alinearlo con el tema Ocean Royale usando el accent azul) */
.inv-section-subcontrato {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  padding: 16px;
}
.inv-section-subcontrato .inv-card {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.chip-subcontrato {
  background: var(--accent);
  color: #fff;
}

.inv-card input[type="number"] {
  min-height: 36px;
  max-width: 80px;
  padding: 0 8px;
  font-size: 0.85rem;
}

/* Modal del mapa */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--deep-blue) 55%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.15s ease-out;
}
.modal-overlay.closing {
  animation: fade-in 0.18s ease-out reverse;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s cubic-bezier(0.19, 1, 0.22, 1);
}
.modal.closing {
  animation: modal-in 0.18s var(--ease-out) reverse;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 8px;
}
.modal-close:hover {
  color: var(--text);
}
.modal-body {
  padding: 20px;
  background: var(--card);
  color: var(--text);
}

/* Mapa de bodega */
.mapa {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.mapa-zona {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 12px;
}
.mapa-zona h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--text);
}
.mapa-zona h3 .badge {
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 6px;
}
.estantes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.casilla {
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  position: relative;
  transition: background 0.2s;
}
.casilla.empty {
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
  background: repeating-linear-gradient(
    45deg,
    var(--card),
    var(--card) 6px,
    var(--bg-2) 6px,
    var(--bg-2) 12px
  );
}
.casilla .slot {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 400;
}
.casilla .stock-mini {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}
.casilla.led-on {
  background: var(--led);
  color: #0d0d0d;
  font-weight: 700;
  animation: pulse-led 1.2s ease-in-out infinite;
  border: 2px solid var(--led-dark);
  box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.5);
}
.casilla.led-on .slot,
.casilla.led-on .stock-mini {
  color: rgba(13, 13, 13, 0.75);
}
@keyframes pulse-led {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(255, 176, 32, 0);
    transform: scale(1.05);
  }
}

.mapa-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.code-block {
  background: #050505;
  color: #d4d4d4;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-x: auto;
  margin-top: 12px;
  white-space: pre;
  position: relative;
}
.code-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}
.code-block .copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   Órdenes — pedidos agrupados por trabajador + acción masiva
   (aceptación estilo email: checkbox por pedido, seleccionar todos,
   entregar/cancelar en lote, entrega rápida por línea)
   ============================================================ */

.pedidos-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.pedidos-toolbar.modo-seleccion {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-2));
}
.pedidos-toolbar-sel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: auto;
}
.pedidos-toolbar-sel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.pedidos-sel-contador {
  font-weight: 600;
  color: var(--text);
}

.pedidos-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pedido-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pedido-card.entregado,
.pedido-card.cancelado {
  opacity: 0.65;
}
.pedido-card.seleccionado {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.pedido-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--card);
}
.pedido-header:hover {
  background: var(--bg-2);
}
.pedido-header.abierto {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.pedido-header input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.pedido-usuario {
  min-width: 0;
  flex: 1 1 auto;
}
.pedido-nombre {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.pedido-resumen {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pedido-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pedido-progreso {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.pedido-fecha {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.pedido-chevron {
  color: var(--muted);
  font-size: 0.75rem;
}

.pedido-body {
  padding: 4px 14px 12px;
  background: var(--card);
}
.pedido-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 10px 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pedido-line:last-of-type {
  border-bottom: none;
}
.pedido-line-m {
  min-width: 0;
  flex: 1 1 auto;
}
.pedido-line-nombre {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pedido-line-cant {
  font-size: 0.75rem;
  color: var(--muted);
}
.pedido-line-acciones {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pedido-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.pedido-footer-info {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: auto;
}
