/* ═══════════════════════════════════════════════
   Approval Workflows — Scoped Styles (awf- prefix)
   ═══════════════════════════════════════════════ */

/* ── Checkbox Grid (replaces <select multiple>) ── */
.awf-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.awf-group-label {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  padding: 6px 4px 2px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 2px;
}

.awf-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: #334155;
  user-select: none;
}

.awf-checkbox-item:hover {
  background: #e8eef6;
}

.awf-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
  flex-shrink: 0;
  cursor: pointer;
}

.awf-checkbox-item span:first-of-type {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.awf-role-tag {
  font-size: 9px;
  font-weight: 700;
  color: #7c3aed;
  background: #ede9fe;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Stage Card in Editor ── */
.awf-stage-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  background: #fafbfc;
  position: relative;
  transition: box-shadow 0.2s;
}

.awf-stage-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.awf-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.awf-stage-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.awf-stage-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
}

.awf-remove-stage {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 20px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.awf-remove-stage:hover {
  background: #fef2f2;
}

.awf-stage-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

/* ── Policy Cards in List ── */
.awf-policy-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}

.awf-policy-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.awf-policy-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 14px;
}

.awf-policy-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.awf-policy-meta {
  font-size: 13px;
  color: #64748b;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.awf-policy-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.awf-stage-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 4px;
}

.awf-stage-pill-number {
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.awf-stage-pill-info {
  flex: 1;
  min-width: 0;
}

.awf-stage-pill-name {
  font-weight: 500;
  font-size: 13px;
  color: #1e293b;
}

.awf-stage-pill-detail {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.awf-active-badge {
  color: #22c55e;
  font-weight: 600;
}

.awf-inactive-badge {
  color: #ef4444;
  font-weight: 600;
}

/* ── Flow Connector between stages ── */
.awf-connector {
  width: 2px;
  height: 10px;
  background: #cbd5e1;
  margin: 0 auto;
}

/* ── PO Status Badge (replaces <select> dropdown) ── */
.po-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.po-status-badge.status-draft {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.po-status-badge.status-pending-approval {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.po-status-badge.status-issued {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.po-status-badge.status-partially-received {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.po-status-badge.status-completed {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #86efac;
}

.po-status-badge.status-cancelled {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.po-status-badge.status-delivered {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #86efac;
}

/* ── Approval Stepper (horizontal progress) ── */
.po-approval-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 20px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
  overflow-x: auto;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  flex-shrink: 0;
}

.stepper-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.3s;
}

.stepper-step.complete .stepper-dot {
  background: #16a34a;
  color: white;
}

.stepper-step.active .stepper-dot {
  background: #f59e0b;
  color: white;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

.stepper-step.pending .stepper-dot {
  background: #e2e8f0;
  color: #94a3b8;
}

.stepper-label {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stepper-step.complete .stepper-label {
  color: #16a34a;
  font-weight: 600;
}

.stepper-step.active .stepper-label {
  color: #d97706;
  font-weight: 600;
}

.stepper-connector {
  flex: 1;
  min-width: 20px;
  height: 3px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 0 4px;
  align-self: flex-start;
  margin-top: 15px;
}

.stepper-step.complete + .stepper-connector {
  background: #16a34a;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.1); }
}

/* ── Pending Approval Cards ── */
.awf-pending-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}

.awf-pending-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.awf-pending-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.awf-pending-po-num {
  font-weight: 700;
  font-size: 16px;
  color: #1e293b;
}

.awf-pending-amount {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.awf-pending-meta {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 14px;
}

.awf-pending-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.awf-btn-approve {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #16a34a;
  color: white;
  transition: background 0.15s;
}

.awf-btn-approve:hover { background: #15803d; }

.awf-btn-reject {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #fecaca;
  background: white;
  color: #dc2626;
  transition: all 0.15s;
}

.awf-btn-reject:hover { background: #fef2f2; }

.awf-btn-delegate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #bfdbfe;
  background: white;
  color: #2563eb;
  transition: all 0.15s;
}

.awf-btn-delegate:hover { background: #eff6ff; }

/* ── Count Badge for Hub Card ── */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}

/* ── Hub icon amber ── */
.hub-icon-amber {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.05));
  color: #d97706;
}

/* ── PO Action buttons styling ── */
.po-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.po-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .awf-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .awf-stage-fields {
    grid-template-columns: 1fr;
  }

  .awf-pending-actions {
    flex-wrap: wrap;
  }

  .po-approval-stepper {
    padding: 12px;
  }
}
