/*
 * NableU maintainer note
 * Purpose: Defines presentation rules for service agreements. Keep selectors scoped to the owning experience and preserve accessibility states such as focus, contrast and reduced-motion behaviour.
 */

.service-agreement-launch {
  margin-top: 12px;
}

.service-agreement-dialog {
  width: min(880px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border-medium);
  background: var(--surface);
  color: var(--text-main);
}

.service-agreement-dialog::backdrop {
  background: rgb(0 0 0 / 65%);
}

.agreement-dialog-shell {
  padding: 24px;
  overflow: auto;
  max-height: calc(100vh - 24px);
}

.agreement-dialog-shell > header,
.agreement-actions,
.agreement-boundary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.agreement-effective {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 2px solid var(--success, #16836f);
  border-radius: 6px;
  background: color-mix(in srgb, var(--success, #16836f) 10%, var(--panel, #fff));
}

.agreement-dialog-shell > header {
  justify-content: space-between;
  position: sticky;
  top: -24px;
  z-index: 2;
  padding: 18px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-medium);
}

.agreement-dialog-shell h2,
.agreement-dialog-shell h3 {
  margin-top: 0;
}

.agreement-boundary {
  flex-direction: column;
  margin: 18px 0;
  padding: 14px;
  border-left: 4px solid var(--warning);
  background: var(--surface-soft);
}

.agreement-revision {
  display: flex;
  gap: 8px;
  align-items: center;
}

.agreement-summary dl,
.agreement-form {
  display: grid;
  gap: 12px;
}

.agreement-recommendations,
.agreement-participant-details,
.agreement-pricing {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background: var(--surface-soft);
}

.agreement-recommendations {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-left: 4px solid var(--accent);
}

.agreement-recommendations h3,
.agreement-recommendations p,
.agreement-participant-details p,
.agreement-pricing h3,
.agreement-pricing > p,
.agreement-pricing-card > p {
  margin-top: 0;
}

.agreement-pricing {
  display: grid;
  gap: 12px;
  border-left: 4px solid var(--accent);
}

.agreement-pricing label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.agreement-pricing-card,
.agreement-pricing-direct {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background: var(--surface);
}

.agreement-direct-pricing-guide {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 2px solid var(--border-medium);
  border-radius: 6px;
  background: var(--surface);
}

.agreement-direct-pricing-guide[hidden] {
  display: none;
}

.agreement-direct-pricing-guide h4,
.agreement-direct-pricing-guide p {
  margin: 0;
}

.agreement-direct-pricing-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.agreement-direct-pricing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.agreement-direct-pricing-limit {
  padding: 10px 12px;
  border-left: 4px solid var(--warning);
  background: var(--surface-soft);
}

.agreement-pricing-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agreement-pricing-card dl > div {
  padding: 8px;
  background: var(--surface-soft);
}

.agreement-pricing-card dt {
  font-weight: 700;
}

.agreement-pricing-card dd {
  margin: 3px 0 0;
}

.agreement-pricing-provenance {
  color: var(--muted);
  font-size: 0.9rem;
}

.agreement-recommendations-ready {
  color: var(--muted);
  font-weight: 700;
}

.agreement-participant-details {
  display: grid;
  gap: 12px;
}

.agreement-participant-details legend {
  padding: 0 6px;
  font-weight: 800;
}

.agreement-summary dl {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agreement-summary dl > div {
  padding: 12px;
  border: 1px solid var(--border-medium);
  background: var(--surface-soft);
}

.agreement-summary dt {
  font-weight: 700;
}

.agreement-summary dd {
  margin: 4px 0 0;
}

.agreement-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.agreement-form textarea {
  min-height: 82px;
  resize: vertical;
}

.agreement-form :read-only {
  opacity: 1;
  color: var(--text-main);
}

.field-help,
.optional-label,
.agreement-history li span,
.agreement-waiting {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.agreement-history {
  margin: 18px 0;
}

.agreement-history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

.agreement-actions {
  position: sticky;
  bottom: -24px;
  flex-wrap: wrap;
  padding: 14px 0 18px;
  background: var(--surface);
  border-top: 1px solid var(--border-medium);
}

.agreement-exports,
.agreement-ending {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border, #31516c);
  border-radius: 6px;
  background: var(--panel-subtle, var(--panel, #fff));
}

.agreement-exports h3,
.agreement-ending h3,
.agreement-exports p,
.agreement-ending p {
  margin: 0;
}

.agreement-export-actions,
.agreement-ending > div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.agreement-ending {
  border-width: 2px;
  border-color: var(--warning, #b26a00);
}

.agreement-actions .warning,
.agreement-ending .warning {
  border-color: var(--warning, #b26a00);
}

.agreement-ended {
  font-weight: 700;
}

.agreement-active {
  font-weight: 700;
  color: var(--success);
}

@media (max-width: 680px) {
  .agreement-dialog-shell {
    padding: 16px;
  }

  .agreement-dialog-shell > header {
    top: -16px;
  }

  .agreement-summary dl {
    grid-template-columns: 1fr;
  }

  .agreement-pricing-card dl {
    grid-template-columns: 1fr;
  }

  .agreement-direct-pricing-fields {
    grid-template-columns: 1fr;
  }

  .agreement-recommendations {
    flex-direction: column;
  }

  .agreement-actions {
    position: static;
    margin-top: 16px;
    padding-bottom: 0;
  }
}
