/* === BATCHES TAB (Sprint P4 V2) === */
/* Namespace: .batches-* para evitar colisiones */

/* ── Toolbar ── */
.batches-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ── Filter bar ── */
.batches-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.batches-sort-hint {
  font-size: var(--size-xs);
  color: var(--potisse-chocolate-mute);
  margin-left: auto;
}

/* ── List ── */
.batches-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.batches-row {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
}

.batches-row:hover {
  box-shadow: 0 2px 8px rgba(58,50,46,0.08);
}

.batches-row-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Thumbnail ── */
.batches-thumb {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--potisse-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--potisse-chocolate-mute);
  font-size: var(--size-lg);
}

.batches-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ── Info block ── */
.batches-row-info {
  flex: 1;
  min-width: 0;
}

.batches-row-title-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.batches-row-title {
  font-weight: 600;
  font-size: var(--size-lg);
  color: var(--potisse-chocolate);
}

.batches-row-meta {
  font-size: var(--size-sm);
  color: var(--potisse-chocolate-mute);
  margin-top: 2px;
}

/* ── Timeline in row ── */
.batches-row-timeline {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

/* ── Status / ETA ── */
.batches-row-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 80px;
}

.batches-row-eta {
  font-size: var(--size-xs);
  color: var(--potisse-chocolate-mute);
}

.batches-row-delete {
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.batches-row:hover .batches-row-delete {
  opacity: 1;
}

/* ── Badges ── */
.batches-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.batches-badge--urgente {
  background: #A54848;
  color: #fff;
}

.batches-badge--alta {
  background: var(--potisse-chocolate);
  color: var(--potisse-cream);
}

.batches-badge--baja {
  background: rgba(58,50,46,0.15);
  color: rgba(58,50,46,0.7);
}

.batches-badge--paused {
  background: #B8863D;
  color: #fff;
}

.batches-badge--standby {
  background: rgba(58,50,46,0.35);
  color: #fff;
}

.batches-badge--cancelled {
  background: rgba(58,50,46,0.15);
  color: rgba(58,50,46,0.6);
}

.batches-badge--stock-incomplete {
  background: rgba(165,72,72,0.15);
  color: #A54848;
}

.batches-badge--planned {
  background: var(--potisse-cream);
  color: var(--potisse-chocolate-mute);
  border: 1px solid var(--hairline);
}

.batches-badge--in-progress {
  background: #3B748C;
  color: #fff;
}

.batches-badge--completed {
  background: #4E7A5A;
  color: #fff;
}

/* ── Timeline dots ── */
.batches-timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.batches-dot--completed {
  background: #4E7A5A;
  color: #fff;
}

.batches-dot--in-progress {
  background: #3B748C;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(59,116,140,0.25);
}

.batches-dot--pending {
  background: rgba(58,50,46,0.15);
  color: var(--potisse-chocolate-mute);
}

/* ═══════════════════════════════════════════════════════════════════════
   DETAIL MODAL
   ═══════════════════════════════════════════════════════════════════════ */

.batches-modal {
  max-width: 720px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.batches-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.batches-detail-title-block {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.batches-detail-thumb {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-sm);
  background: var(--potisse-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--potisse-chocolate-mute);
  font-size: var(--size-xl);
}

.batches-detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.batches-detail-title-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.batches-detail-title {
  font-weight: 600;
  font-size: var(--size-xl);
  color: var(--potisse-chocolate);
}

.batches-detail-subtitle {
  font-size: var(--size-sm);
  color: var(--potisse-chocolate-mute);
  margin-top: 2px;
}

/* Menu button */
.batches-menu-btn {
  font-weight: 700;
  letter-spacing: 2px;
  padding: var(--space-1) var(--space-2);
}

/* Dropdown */
.batches-menu-dropdown {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(58,50,46,0.12);
  padding: var(--space-1) 0;
  min-width: 180px;
}

.batches-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  font-size: var(--size-base);
  color: var(--potisse-chocolate);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.batches-menu-item:hover {
  background: var(--potisse-cream-hover);
}

.batches-menu-item--danger {
  color: var(--danger);
}

.batches-menu-item--danger:hover {
  background: rgba(165,72,72,0.08);
}

/* ── Progress bar ── */
.batches-progress-wrap {
  margin: var(--space-4) 0;
}

.batches-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--hairline);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.batches-progress-fill {
  height: 100%;
  background: #4E7A5A;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.batches-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-1);
  font-size: var(--size-sm);
  color: var(--potisse-chocolate-mute);
}

/* ── Detail timeline ── */
.batches-detail-timeline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  padding: var(--space-3) 0;
  position: relative;
}

.batches-detail-timeline::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--hairline);
  z-index: 0;
}

.batches-timeline-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

.batches-timeline-label {
  font-size: var(--size-xs);
  color: var(--potisse-chocolate-mute);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Alert ── */
.batches-alert {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.batches-alert--warning {
  background: rgba(184,134,61,0.1);
  color: #B8863D;
  border: 1px solid rgba(184,134,61,0.2);
}

/* ── Materials section ── */
.batches-materials-section {
  margin: var(--space-4) 0;
}

.batches-materials-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--size-base);
}

.batches-materials-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
}

.batches-materials-table th,
.batches-materials-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}

.batches-materials-table th {
  font-weight: 600;
  color: var(--potisse-chocolate-mute);
  font-size: var(--size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.batches-materials-table td {
  color: var(--potisse-chocolate);
  vertical-align: middle;
}

.batches-materials-table input[type="number"] {
  width: 70px;
}

/* ── Action buttons ── */
.batches-detail-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.batches-btn-complete {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--size-lg);
  background: var(--potisse-chocolate);
  color: #fff;
}

.batches-btn-complete:hover {
  background: var(--potisse-chocolate-soft);
}

.batches-btn-rollback {
  background: #E8C866;
  color: var(--potisse-chocolate);
}

.batches-btn-rollback:hover {
  background: #d4b55a;
}

/* ── Collapsible sections ── */
.batches-collapsible-section {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  margin: var(--space-2) 0;
  overflow: hidden;
}

.batches-collapsible-section--danger {
  border-left: 3px solid #A54848;
}

.batches-collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  background: var(--potisse-cream-soft);
  font-weight: 500;
  font-size: var(--size-sm);
  color: var(--potisse-chocolate);
  transition: background var(--transition-fast);
}

.batches-collapsible-header:hover {
  background: var(--potisse-cream-hover);
}

.batches-collapsible-count {
  color: var(--potisse-chocolate-mute);
  font-weight: 400;
}

.batches-collapsible-body {
  padding: var(--space-3) var(--space-4);
  background: #fff;
}

.batches-collapsible-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.batches-collapsible-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--size-sm);
}

.batches-collapsible-item:last-child {
  border-bottom: none;
}

.batches-collapsible-sku {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--potisse-chocolate);
}

.batches-collapsible-meta {
  color: var(--potisse-chocolate-mute);
  font-size: var(--size-xs);
}

/* ── History ── */
.batches-history {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
}

.batches-history-title {
  font-size: var(--size-lg);
  font-weight: 600;
  color: var(--potisse-chocolate);
  margin-bottom: var(--space-3);
}

.batches-history-list {
  position: relative;
  padding-left: var(--space-4);
}

.batches-history-list::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(59,116,140,0.3);
}

.batches-history-item {
  position: relative;
  padding-bottom: var(--space-3);
}

.batches-history-dot {
  position: absolute;
  left: -14px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: #3B748C;
}

.batches-history-event {
  font-weight: 600;
  font-size: var(--size-sm);
  color: #3B748C;
}

.batches-history-detail {
  font-size: var(--size-sm);
  color: var(--potisse-chocolate);
  margin-top: 2px;
}

.batches-history-meta {
  font-size: var(--size-xs);
  color: var(--potisse-chocolate-mute);
  margin-top: 2px;
}

/* ── Modal overlay namespace ── */
.batches-modal-overlay {
  z-index: 100;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .batches-row-main {
    flex-wrap: wrap;
  }
  .batches-row-timeline {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
  .batches-detail-timeline::before {
    display: none;
  }
  .batches-detail-timeline {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  .batches-timeline-item {
    flex: 0 0 auto;
  }
}
