/*
 * Workspace form surfaces.
 *
 * Shared form scaffolding for admin/client/partner operational screens.
 * Keeps field rhythm, checkbox groups and textarea controls consistent.
 */

.workspace-form-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-surface-200, #e2e8f0);
  border-radius: 0.5rem;
  background: var(--color-surface, #fff);
  padding: 1.25rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
}

.workspace-form-card > .form-actions-span-full,
.workspace-form-card > .workspace-form-actions {
  grid-column: 1;
}

@media (min-width: 768px) {
  .workspace-form-card {
    padding: 1.5rem;
  }
}

.workspace-field-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.375rem;
}

.workspace-field-label {
  display: block;
  margin: 0;
  color: var(--color-text-primary, #0f172a);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.25rem;
}

.workspace-field-hint {
  display: block;
  color: var(--color-text-secondary, #64748b);
  font-size: 0.8125rem;
  line-height: 1.35;
}

.workspace-textarea {
  width: 100%;
  min-width: 0;
  min-height: 7rem;
  resize: vertical;
  border: 1px solid var(--color-surface-200, #e2e8f0);
  border-radius: 0.5rem;
  background: var(--color-surface, #fff);
  color: var(--color-text-primary, #0f172a);
  font: inherit;
  line-height: 1.45;
  padding: 0.75rem 0.875rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.workspace-textarea:focus {
  border-color: var(--theme-primary, #111827);
  box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.14);
  outline: none;
}

.workspace-checkbox-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .workspace-checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.workspace-checkbox-group {
  min-width: 0;
  border: 1px solid var(--color-surface-200, #e2e8f0);
  border-radius: 0.5rem;
  background: rgba(248, 250, 252, 0.72);
  padding: 0.875rem;
}

.workspace-checkbox-group-title {
  display: block;
  margin: 0 0 0.625rem;
  color: var(--color-text-primary, #0f172a);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.workspace-checkbox-label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.5rem;
  row-gap: 0.125rem;
  align-items: start;
  min-width: 0;
  border-radius: 0.375rem;
  padding: 0.375rem;
  color: var(--color-text-primary, #0f172a);
}

.workspace-checkbox-label + .workspace-checkbox-label {
  margin-top: 0.25rem;
}

.workspace-checkbox-label input[type="checkbox"] {
  grid-row: 1 / span 2;
  width: 1rem;
  height: 1rem;
  margin-top: 0.125rem;
  accent-color: var(--theme-primary, #111827);
}

.workspace-checkbox-label span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.25rem;
}

.workspace-checkbox-hint {
  grid-column: 2;
  min-width: 0;
  color: var(--color-text-secondary, #64748b);
  font-size: 0.8125rem;
  line-height: 1.3;
}

.workspace-observedby-selector {
  display: grid;
  gap: 0.875rem;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-surface-200, #e2e8f0);
  border-radius: 0.75rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.7), rgba(255, 255, 255, 0.98));
  padding: 1rem;
}

.workspace-observedby-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.workspace-observedby-search {
  flex: 1 1 18rem;
  min-width: 0;
  max-width: 32rem;
}

.workspace-observedby-search .form-input {
  width: 100%;
}

.workspace-observedby-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem 1rem;
  min-width: 0;
}

.workspace-observedby-toggle {
  min-height: 2.5rem;
}

.workspace-observedby-counter {
  color: var(--color-text-secondary, #64748b);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.workspace-observedby-counter strong {
  color: var(--color-text-primary, #0f172a);
}

.workspace-observedby-summary {
  min-width: 0;
}

.workspace-observedby-summary-chip {
  max-width: 100%;
}

.workspace-observedby-summary-chip-text {
  display: inline-block;
  max-width: min(28rem, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.workspace-observedby-table-shell {
  max-height: 24rem;
  overflow: auto;
  border: 1px solid var(--color-surface-200, #e2e8f0);
  border-radius: 0.625rem;
  background: var(--color-surface, #fff);
}

.workspace-observedby-table {
  width: 100%;
  min-width: 46rem;
  border-collapse: separate;
  border-spacing: 0;
}

.workspace-observedby-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface, #fff);
}

.workspace-observedby-table th,
.workspace-observedby-table td {
  border-bottom: 1px solid var(--color-surface-200, #e2e8f0);
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.workspace-observedby-table tbody tr:hover {
  background: rgba(var(--theme-primary-rgb), 0.03);
}

.workspace-observedby-table tbody tr.is-selected {
  background: rgba(var(--theme-primary-rgb), 0.06);
}

.workspace-observedby-select-col {
  width: 3rem;
  text-align: center;
}

.workspace-observedby-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--theme-primary, #111827);
}

.workspace-observedby-code {
  min-width: 8rem;
  color: var(--color-text-secondary, #475569);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.workspace-observedby-name {
  min-width: 18rem;
  color: var(--color-text-primary, #0f172a);
  font-weight: 600;
}

.workspace-observedby-type {
  min-width: 10rem;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
}

.workspace-observedby-empty-row td {
  color: var(--color-text-secondary, #64748b);
  text-align: center;
  font-size: 0.875rem;
}

.workspace-observedby-empty-row[hidden] {
  display: none;
}

.workspace-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  color: var(--color-text-primary, #0f172a);
  font-size: 0.875rem;
  font-weight: 600;
}

.workspace-toggle-label input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--theme-primary, #111827);
}

.workspace-danger-zone {
  margin-top: 1rem;
  border: 1px solid rgba(185, 28, 28, 0.18);
  border-radius: 0.5rem;
  background: rgba(254, 242, 242, 0.65);
  padding: 1rem;
}

.workspace-danger-zone h4 {
  margin: 0 0 0.75rem;
  color: rgb(127 29 29);
  font-size: 0.9375rem;
  font-weight: 700;
}

.workspace-danger-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.workspace-danger-actions > form {
  display: inline-flex;
  margin: 0;
}

@media (max-width: 639px) {
  .workspace-danger-actions,
  .workspace-danger-actions > form,
  .workspace-danger-actions .btn-canonical {
    width: 100%;
  }
}
