/*
 * Modernized page styles for Settings and Evaluation flows.
 * Scoped under .app-modern so the rest of the app's legacy styles are untouched.
 */

.app-modern {
  --bg-page:        #F8FAFC;
  --bg-card:        #FFFFFF;
  --text-primary:   #0F172A;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;
  --border-subtle:  #E2E8F0;
  --border-strong:  #CBD5E1;
  --accent:         #8A38F5;
  --accent-hover:   #7A28E5;
  --accent-active:  #6A1ECF;
  --accent-soft:    #F1F5F9;  /* neutral wash used for chips, secondary hover */
  --accent-tint:    #F4ECFE;  /* light purple wash for primary-family hover */
  --accent-ring:    rgba(138, 56, 245, 0.22);
  --success:        #047857;
  --success-bg:     #ECFDF5;
  --danger:         #B91C1C;
  --danger-bg:      #FEF2F2;
  --info:           #1D4ED8;
  --info-bg:        #EFF6FF;
  --shadow-card:    0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-primary);
  font-feature-settings: "cv11";

  /* Breathing room below forms so submit buttons aren't flush with the viewport. */
  padding-bottom: 64px;
}

/* Override the layout-level `h1,h2,h3,h4,h5 { font-family: Poppins }` rule
   so headings inside our modern shell pick up Inter from the wrapper. */
.app-modern h1,
.app-modern h2,
.app-modern h3,
.app-modern h4,
.app-modern h5,
.app-modern h6 {
  font-family: inherit;
}

.app-modern .page-header {
  margin: 8px 0 24px 0;
}
.app-modern .page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}
.app-modern .page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.app-modern .card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.app-modern .card--compact { padding: 14px 18px; }
.app-modern .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -2px 0 18px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.app-modern .card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}
.app-modern .card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 2px 0 0 0;
}

.app-modern .section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 24px 0 12px 0;
}

.app-modern .form-row { margin-bottom: 14px; }
.app-modern .form-row:last-child { margin-bottom: 0; }
.app-modern .form-row--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.app-modern .form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.app-modern .form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}
.app-modern .form-input,
.app-modern input[type="text"].form-input,
.app-modern input[type="password"].form-input,
.app-modern input[type="number"].form-input,
.app-modern textarea.form-input,
.app-modern select.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  box-sizing: border-box;
}
.app-modern .form-input:focus,
.app-modern textarea.form-input:focus,
.app-modern select.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.app-modern textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }
.app-modern .form-input--mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.app-modern .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
  line-height: 1;
  -webkit-user-select: none;
          user-select: none;
}
.app-modern .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.app-modern .btn:disabled,
.app-modern .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-modern .btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.app-modern .btn-primary:hover  { background: var(--accent-hover);  border-color: var(--accent-hover);  color: #fff; }
.app-modern .btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); color: #fff; transform: translateY(1px); }

.app-modern .btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.app-modern .btn-secondary:hover  { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.app-modern .btn-secondary:active { background: #E9DAFB; border-color: var(--accent-active); color: var(--accent-active); transform: translateY(1px); }

.app-modern .btn-link {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 6px;
  font-size: 13px;
}
.app-modern .btn-link:hover  { color: var(--accent); }
.app-modern .btn-link:active { color: var(--accent-active); }

.app-modern .btn-link-danger {
  background: transparent;
  color: var(--danger);
  padding: 4px 6px;
  font-size: 13px;
}
.app-modern .btn-link-danger:hover  { color: #7F1D1D; }
.app-modern .btn-link-danger:active { color: #5A1010; }

.app-modern .btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}
.app-modern .btn-danger:hover  { background: var(--danger);   color: #fff; border-color: var(--danger); }
.app-modern .btn-danger:active { background: #7F1D1D; color: #fff; border-color: #7F1D1D; transform: translateY(1px); }

/* ── Native HTML5 <dialog> modal (used for provisioning from /agents/new) ── */
dialog.bam-modal {
  width: 100%;
  max-width: 680px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #0F172A;
}
dialog.bam-modal::backdrop { background: rgba(15, 23, 42, 0.55); }
dialog.bam-modal[open] { animation: bam-modal-pop 140ms ease-out; }
@keyframes bam-modal-pop {
  from { transform: translateY(-8px); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}
dialog.bam-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E2E8F0;
}
dialog.bam-modal .modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
dialog.bam-modal .modal-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: #64748B;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
dialog.bam-modal .modal-close:hover { background: #F1F5F9; color: #0F172A; }
dialog.bam-modal .modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
dialog.bam-modal .modal-tab-list {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid #E2E8F0;
}
dialog.bam-modal .modal-tab {
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: #64748B;
  font-weight: 500;
}
dialog.bam-modal .modal-tab[aria-selected="true"] {
  color: #8A38F5;
  border-bottom-color: #8A38F5;
}
dialog.bam-modal .modal-tab:hover:not([aria-selected="true"]) { color: #0F172A; }
dialog.bam-modal .modal-panel { display: none; }
dialog.bam-modal .modal-panel[data-active="true"] { display: block; }

/* Right-aligned form action area with breathing room. */
.app-modern .form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 16px;
}
.app-modern .form-actions .commit { margin-bottom: 0; }
.app-modern .form-actions .commit input[type="submit"] { width: auto; }

.app-modern .badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.app-modern .badge--success { background: var(--success-bg); color: var(--success); }
.app-modern .badge--neutral { background: var(--accent-soft); color: var(--text-secondary); }
.app-modern .badge--info    { background: var(--info-bg);    color: var(--info); }

.app-modern .alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
}
.app-modern .alert-success { background: var(--success-bg); color: var(--success); }
.app-modern .alert-info    { background: var(--info-bg);    color: var(--info); }

/* ── Settings page specifics ── */
.app-modern .settings-provider-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.app-modern .settings-provider-row .provider-label { font-weight: 600; font-size: 15px; }
.app-modern .settings-provider-row .provider-help { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.app-modern .key-hint { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text-secondary); font-size: 12px; }

/* ── Evaluation form: experiments as cards ── */
.app-modern .experiments-list,
.app-modern .models-list { display: flex; flex-direction: column; gap: 12px; }
.app-modern .experiment-card,
.app-modern .model-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.app-modern .experiment-card-header,
.app-modern .model-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.app-modern .experiment-card-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.app-modern .add-association {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
}
.app-modern .add-association:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--text-primary); }

/* ── Attachments ── */
.app-modern .attachment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.app-modern .attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.app-modern .attachment-name { font-weight: 500; color: var(--text-primary); }
.app-modern .attachment-meta { color: var(--text-secondary); font-size: 12px; flex: 1; }
.app-modern .attachment-remove { color: var(--danger); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.app-modern .attachment-input {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
}
.app-modern .attachment-input::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}
.app-modern .attachment-input::file-selector-button:hover { background: var(--accent-soft); }

/* ── Formtastic compatibility: align semantic_form_for output with the new system ── */
.app-modern .formtastic > ol,
.app-modern .formtastic ol { padding: 0; margin: 0; list-style: none; }
.app-modern .formtastic li { list-style: none; margin-bottom: 14px; }
.app-modern .formtastic li:last-child { margin-bottom: 0; }
.app-modern .formtastic label,
.app-modern .formtastic .label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.app-modern .formtastic input[type="text"],
.app-modern .formtastic input[type="password"],
.app-modern .formtastic input[type="email"],
.app-modern .formtastic input[type="number"],
.app-modern .formtastic textarea,
.app-modern .formtastic select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  box-sizing: border-box;
}
.app-modern .formtastic input:focus,
.app-modern .formtastic textarea:focus,
.app-modern .formtastic select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.app-modern .formtastic textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.app-modern .formtastic .commit input[type="submit"],
.app-modern .formtastic input[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: auto;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.app-modern .formtastic input[type="submit"]:hover  { background: var(--accent-hover);  border-color: var(--accent-hover); }
.app-modern .formtastic input[type="submit"]:active { background: var(--accent-active); border-color: var(--accent-active); transform: translateY(1px); }
.app-modern .formtastic input[type="submit"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* ── Status pill (used on evaluation show + agentic eval show) ── */
.app-modern .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}
.app-modern .status-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.app-modern .status-pill--processing {
  background: var(--accent-tint);
  color: var(--accent);
}
.app-modern .status-pill--processing::before { animation: pulse-dot 1.4s ease-in-out infinite; }
.app-modern .status-pill--complete { background: var(--success-bg); color: var(--success); }
.app-modern .status-pill--draft    { background: var(--accent-soft); color: var(--text-secondary); }
.app-modern .status-pill--failed   { background: var(--danger-bg); color: var(--danger); }
@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ── Thin progress bar ── */
.app-modern .progress-bar {
  width: 100%;
  height: 6px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.app-modern .progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 300ms ease;
}

/* ── Metric grid ── */
.app-modern .metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.app-modern .metric-tile {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.app-modern .metric-tile-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 4px 0;
}
.app-modern .metric-tile-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.app-modern .metric-tile-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Horizontally scrollable table wrap ── */
.app-modern .table-scroll {
  overflow-x: auto;
  margin: 0 -8px;
  padding: 0 8px;
  border-radius: var(--radius-md);
}
.app-modern .table-scroll table.table { min-width: 720px; }
.app-modern table.table tbody tr:hover { background: var(--accent-soft); }
.app-modern table.table tbody tr:last-child td { border-bottom: 0; }
.app-modern table.table td.numeric,
.app-modern table.table th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.app-modern table.table td.muted { color: var(--text-secondary); font-size: 13px; }
.app-modern .empty-state {
  text-align: center;
  padding: 36px 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Tables that remain — softer borders */
.app-modern table.table { border-collapse: collapse; width: 100%; }
.app-modern table.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.app-modern table.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
