/* ==========================================================================
   Universal agent-format export modal (js/agent-export-ui.js)
   Tokens only — no hardcoded colors (theme guard). BEM-ish `.agent-export-*`.
   ========================================================================== */

.agent-export-modal .agent-export-content {
  width: min(92vw, 920px);
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Header ------------------------------------------------------------------ */

.agent-export-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.agent-export-heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.agent-export-heading h3 {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.agent-export-subtitle {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.agent-export-close {
  flex-shrink: 0;
}

/* Layout: format list + preview ------------------------------------------- */

.agent-export-layout {
  display: grid;
  grid-template-columns: minmax(260px, 5fr) minmax(280px, 6fr);
  gap: var(--space-4);
  min-height: 0;
}

/* Format list --------------------------------------------------------------- */

.agent-export-formats {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: min(52vh, 460px);
  overflow-y: auto;
  padding-right: var(--space-1);
  scrollbar-gutter: stable;
}

.agent-export-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1_5);
}

.agent-export-group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding-inline: var(--space-1);
}

.agent-export-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--surface-primary);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.agent-export-option:hover {
  border-color: var(--brand-500);
}

.agent-export-option.is-selected {
  border-color: var(--brand-500);
  background: var(--primary-light);
}

.agent-export-option:has(input:focus-visible) {
  outline: 2px solid var(--brand-500);
  outline-offset: 1px;
}

.agent-export-option input[type="radio"] {
  margin-top: 0.2em;
  accent-color: var(--brand-500);
  flex-shrink: 0;
}

.agent-export-option-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.agent-export-option-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.agent-export-option-file {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.agent-export-option-notes {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.agent-export-option.is-selected .agent-export-option-notes {
  color: var(--text-secondary);
}

/* Preview ------------------------------------------------------------------- */

.agent-export-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  min-height: 0;
}

.agent-export-preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 1.25rem;
}

.agent-export-preview-path {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.agent-export-preview-count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.agent-export-preview-pane {
  margin: 0;
  padding: var(--space-3);
  flex: 1;
  min-height: 200px;
  max-height: min(52vh, 460px);
  overflow: auto;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--surface-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.agent-export-preview-pane code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
}

/* Options row ----------------------------------------------------------------- */

.agent-export-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--surface-secondary);
}

.agent-export-option-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  width: fit-content;
}

.agent-export-option-toggle input[type="checkbox"] {
  accent-color: var(--brand-500);
}

.agent-export-option-hint {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Actions ----------------------------------------------------------------------- */

.agent-export-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.agent-export-pro-badge {
  margin-left: var(--space-2);
}

/* Dark mode: tonal layering so list/preview wells read against the dialog ------- */

:root[data-theme="dark"] .agent-export-option {
  background: var(--surface-secondary);
}

:root[data-theme="dark"] .agent-export-option.is-selected {
  background: var(--primary-light);
}

:root[data-theme="dark"] .agent-export-preview-pane,
:root[data-theme="dark"] .agent-export-options {
  background: var(--surface-tertiary);
  border-color: var(--border-primary);
}

/* Responsive: stack preview under format list ----------------------------------- */

@media (max-width: 760px) {
  .agent-export-layout {
    grid-template-columns: 1fr;
  }

  .agent-export-formats {
    max-height: 36vh;
  }

  .agent-export-preview-pane {
    min-height: 140px;
    max-height: 32vh;
  }
}

/* Reduced motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .agent-export-option {
    transition: none;
  }
}
