/* ============ SCHEDULED ORDERS SIDEBAR ============ */
/* The Send Order page becomes two columns: the form on the left, and what is
   queued for later on the right, so a scheduled order is never out of sight. */
.so-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.so-layout > .so-main { min-width: 0; }

.so-side {
  position: sticky;
  top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.so-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.so-side-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.so-side-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 0;
}
.so-side-refresh:hover { background: var(--surface-alt); color: var(--text); }

.so-sched-health {
  font-size: 11px;
  line-height: 1.45;
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 10px;
}
.so-sched-health-ok { background: var(--success-bg); color: #065f46; }
.so-sched-health-bad { background: var(--danger-bg); color: #991b1b; font-weight: 600; }

.so-sched-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 22px 8px;
  line-height: 1.6;
}
.so-sched-empty span { color: var(--text-light); font-size: 11px; }

.so-sched-list { display: flex; flex-direction: column; gap: 10px; }

.so-sched-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 10px 11px;
  background: var(--surface);
}
.so-sched-card-late { border-color: var(--warning); background: #fffbeb; }

.so-sched-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.so-sched-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
  min-width: 0;
  overflow-wrap: anywhere;
}
.so-sched-when { font-size: 11px; color: var(--text-muted); }
.so-sched-countdown {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin: 3px 0 7px;
}
.so-sched-late { color: var(--warning); }

.so-sched-products {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.so-sched-products li {
  font-size: 11px;
  color: var(--text);
  background: var(--surface-alt);
  border-radius: 5px;
  padding: 4px 6px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.so-sched-qty { color: var(--text-muted); }
.so-sched-meta { font-size: 11px; color: var(--text-muted); }

.so-sched-problems {
  margin-top: 7px;
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 7px 8px;
}
.so-sched-problems-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #991b1b;
  margin-bottom: 3px;
}
.so-sched-problems ul { margin: 0; padding-left: 15px; }
.so-sched-problems li { font-size: 11px; color: #991b1b; line-height: 1.4; }

.so-sched-actions { display: flex; gap: 6px; margin-top: 9px; }
.so-sched-btn {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.so-sched-btn:hover:not(:disabled) { background: var(--surface-alt); }
.so-sched-btn:disabled { opacity: 0.55; cursor: default; }
.so-sched-btn-danger { color: var(--danger); border-color: #fecaca; }
.so-sched-btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

/* Status pills */
.so-sb {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.so-sb-wait { background: var(--info-bg); color: #1e40af; }
.so-sb-send { background: var(--warning-bg); color: #92400e; }
.so-sb-ok { background: var(--success-bg); color: #065f46; }
.so-sb-warn { background: #ffedd5; color: #9a3412; }
.so-sb-fail { background: var(--danger-bg); color: #991b1b; }
.so-sb-cancel { background: var(--surface-alt); color: var(--text-muted); }

/* Date + time + zone row in the timing step */
.so-sched-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.so-sched-preview {
  margin-top: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}
.so-sched-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 8px 10px;
}

@media (max-width: 1080px) {
  .so-layout { grid-template-columns: minmax(0, 1fr); }
  .so-side { position: static; max-height: none; order: -1; }
}

/* ============ SCHEDULED ORDER: EDIT MODE + HISTORY ============ */
/* Editing reuses the normal Send Order form, so this banner is what tells you the
   save will replace an existing order rather than create a second one. */
.so-edit-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md, 8px);
  padding: 11px 14px;
  margin-bottom: 16px;
}
.so-edit-banner-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.5;
  color: #92400e;
  font-weight: 500;
}
.so-edit-banner-btn {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--warning);
  border-radius: 6px;
  background: var(--surface);
  color: #92400e;
  cursor: pointer;
}
.so-edit-banner-btn:hover { background: #fff7ed; }

.so-sched-who {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 6px;
  line-height: 1.4;
}

.so-sched-history-toggle {
  margin-top: 8px;
  background: none;
  border: none;
  padding: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.so-sched-history-toggle:hover { color: var(--text); }

.so-sched-history {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.so-sched-hist-loading { font-size: 11px; color: var(--text-muted); }
.so-sched-hist-row {
  font-size: 11px;
  line-height: 1.45;
  border-left: 2px solid var(--border-strong);
  padding-left: 8px;
}
.so-sched-hist-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.so-sched-hist-action { font-weight: 700; color: var(--text); }
.so-sched-hist-when { color: var(--text-light); white-space: nowrap; }
.so-sched-hist-actor { color: var(--text-muted); }
.so-sched-hist-note { color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.so-sched-hist-changes {
  margin: 3px 0 0;
  padding-left: 15px;
  color: var(--text-muted);
}
.so-sched-hist-changes li { margin-bottom: 2px; overflow-wrap: anywhere; }
.so-sched-hist-changes s { opacity: 0.7; }
.so-sched-hist-changes b { color: var(--text); }
