/* ── Change of Major entry display ordering ──────────────────────────────────
   Move the whole approval workflow panel to the top and push status to the
   bottom. Targets .gfcom-approval-workflow — the actual direct grid child of
   .gfed-fields. Uses :has() so this only applies on Change of Major entries,
   leaving the default gf_admin ordering intact for all other forms.
   ──────────────────────────────────────────────────────────────────────────── */
.gfcom-approval-workflow {
  order: -3; /* before status (-2) and notes (-1) */
  grid-column: 1 / -1; /* always span full width in the outer grid */
}

.gfed-fields:has(.gfcom-approval-workflow) .gfed-field-status {
  order: 1; /* push status after all normal fields */
}
/* Hide descriptions for fields */
.gfed-section-description,
.gfed-field-description {
  display: none;
}
/* ── Internal layout: action left 2/3 · timeline right 1/3 ─────────────────── */
/* DOM order now matches visual order, so no explicit grid-column needed.
   The h3 + action section sit in col 1 naturally; timeline flows into col 2. */
.gfcom-approval-workflow {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0 24px;
  align-items: start;
}

.gfcom-approval-workflow > h3 {
  margin-bottom: 12px;
}

/* Use .gfcom-approval-workflow prefix to beat entry-display.css's
   .gfcom-action-section { grid-column: 1 / -1 } rule (higher specificity) */
.gfcom-approval-workflow .gfcom-action-section {
  margin-top: 0 !important;
}

/* When no action section is present (non-approver view), timeline spans full width */
.gfcom-approval-workflow:not(:has(.gfcom-action-section)) .gfcom-timeline {
  grid-column: 1 / -1;
}

/* ── Print: hide the workflow panel and site header ─────────────────────────── */
@media print {
  .gfcom-approval-workflow,
  #intHeader,
  .open-button {
    display: none !important;
  }
}

/* ── Autocomplete field spinner ─────────────────────────────────────────────── */
.gfcom-ac-spinner,
.gfcom-submit-spinner {
  display: inline-block !important;
  width: 14px !important;
  height: 14px !important ;
  margin-left: 8px !important;
  border: 2px solid rgba(0, 0, 0, 0.12) !important;
  border-top-color: #555 !important;
  border-radius: 50% !important;
  vertical-align: middle;
  opacity: 0;
  animation: gfcom-ac-spin 0.7s linear infinite;
  transition: opacity 0.15s;
  pointer-events: none;
}
.gfcom-submit-spinner {
  width: 18px !important;
  height: 18px !important;
}

.gfcom-ac-spinner--active,
.gfcom-submit-spinner--active {
  opacity: 1 !important;
}

@keyframes gfcom-ac-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Decision icons — ✓ approved  ✗ denied  – pending/N/A */
.gfcom-decision-icon {
  display: inline-block;
  font-weight: 700;
  font-size: 1em;
  line-height: 1;
  min-width: 1.1em;
  text-align: center;
}

.gfcom-decision-icon.approved {
  color: #4caf50;
}
.gfcom-decision-icon.denied {
  color: #f44336;
}
.gfcom-decision-icon.pending {
  color: #bdbdbd;
}
.gfcom-decision-icon.na {
  color: #bdbdbd;
}

/* Approver name / date shown after the decision label */
.gfcom-decision-meta {
  font-size: 0.85em;
  color: #757575;
  font-weight: 400;
}

/* Context banner — tells the approver what they are deciding */
.gfcom-action-context {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #f0f4ff;
  border-left: 4px solid #2196f3;
  border-radius: 0 4px 4px 0;
  font-size: 14px;
  color: #333;
}

.gfcom-action-context .gfcom-step-label {
  color: #1565c0;
  font-weight: 600;
}

/* Action Buttons */
.gfcom-action-buttons {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.gfcom-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: white !important;
}

.gfcom-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gfcom-btn-approve,
.gfcom-btn-approve-with-adviser {
  background-color: #4caf50;
}

.gfcom-btn-approve:hover,
.gfcom-btn-approve-with-adviser:hover {
  background-color: #45a049;
}

.gfcom-btn-deny {
  background-color: #f44336;
}

.gfcom-btn-deny:hover {
  background-color: #da190b;
}

.gfcom-btn-cancel {
  background-color: #757575;
}

.gfcom-btn-cancel:hover {
  background-color: #616161;
}

.gfcom-btn-approve-confirm {
  background-color: #4caf50;
}

.gfcom-btn-approve-confirm:hover {
  background-color: #45a049;
}

.gfcom-btn-deny-confirm {
  background-color: #f44336;
}

.gfcom-btn-deny-confirm:hover {
  background-color: #da190b;
}

.gfcom-action-status {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 600;
}

.gfcom-action-status.success {
  color: #4caf50;
}

.gfcom-action-status.error {
  color: #f44336;
}

.gfcom-action-status.loading {
  color: #2196f3 !important;
}

.gfcom-step-current {
  border: 2px solid #2196f3;
  background: #f0f8ff;
}

/* Modal Styles */
.gfcom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gfcom-modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gfcom-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gfcom-modal-header h3 {
  margin: 0;
  color: #333;
}

.gfcom-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gfcom-modal-close:hover {
  color: #333;
}

.gfcom-modal-body {
  padding: 20px;
}

.gfcom-modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.gfcom-form-field {
  margin-bottom: 20px;
}

.gfcom-form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
}

.gfcom-form-field input,
.gfcom-form-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.gfcom-form-field input:focus,
.gfcom-form-field textarea:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

/* ── Print styles ── */
@media print {
  /* Hide everything interactive — no point printing buttons, forms, modals */
  .gfcom-action-section,
  .gfcom-modal {
    display: none !important;
  }

  /* Approval workflow container: compact */
  .gfcom-approval-workflow {
    margin-top: 8pt !important;
  }

  .gfcom-approval-workflow h3 {
    font-size: 13pt !important;
    margin-bottom: 6pt !important;
  }

  /* Timeline: tighten up */
  .gfcom-timeline {
    margin: 0 !important;
    padding: 0 !important;
  }

  .gfcom-step {
    font-size: 11pt !important;
    padding: 4pt 0 2pt !important;
    margin: 0 !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .gfcom-dept-item {
    font-size: 10pt !important;
    padding: 2pt 0 2pt 14pt !important;
    margin: 0 !important;
  }

  /* Force decision icon colours to print */
  .gfcom-decision-icon {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .gfcom-decision-icon.approved {
    color: #2e7d32 !important;
  } /* darker for print legibility */
  .gfcom-decision-icon.denied {
    color: #c62828 !important;
  }
  .gfcom-decision-icon.pending {
    color: #757575 !important;
  }

  .gfcom-decision-meta {
    font-size: 9pt !important;
  }

  /* Step current highlight: simpler border for print */
  .gfcom-step-current {
    border: 1pt solid #333 !important;
    background: none !important;
  }
}
