/* templates.css — Manage → Templates, the template editor and the Save as template dialog
 * (web/templates.js). Theme tokens only (web/style.css). */

.tpl-intro { margin: 0 0 10px; }
.tpl-row-desc { white-space: normal; color: var(--text-dim); }
.tpl-row-actions { flex-wrap: wrap; justify-content: flex-end; }

/* Our modals are appended to <body> after app.js's, so they stack above Manage / Job settings. */
.tpl-backdrop { z-index: 55; }
.tpl-dialog-body { padding: 14px 18px 4px; overflow-y: auto; min-height: 0; }
.tpl-field { margin-bottom: 10px; }
.tpl-desc { resize: vertical; min-height: 44px; font-family: inherit; }
.tpl-saveas-modes { display: flex; gap: 16px; flex-wrap: wrap; }

.tpl-error {
  margin: 6px 0 8px; padding: 8px 10px; border: 1px solid var(--danger-line); border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-size: 12.5px; line-height: 1.45;
  display: flex; flex-direction: column; gap: 3px;
}
.tpl-error-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--text-dim); word-break: break-all; }
.tpl-error.hidden, .tpl-error-path.hidden { display: none; }

.tpl-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 10px 16px 0; padding: 8px 12px; border: 1px solid var(--warn-line); border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-size: 12.5px;
}
.tpl-dialog-body .tpl-banner { margin: 6px 0 8px; }
.tpl-banner.hidden { display: none; }

/* editor */
.tpl-editor { max-width: 900px; width: calc(100vw - 32px); height: min(84vh, 760px); }
.tpl-editor-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-editor-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-editor-sub { font-size: 11.5px; color: var(--text-faint); }
.tpl-readonly { margin: 8px 16px 0; }
.tpl-readonly.hidden { display: none; }
.tpl-editor-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 18px; }
.tpl-editor-footer { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--border-soft); }
.tpl-editor-status-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tpl-editor-status { margin: 0; }
.tpl-ok { color: var(--success); }
.tpl-editor-save.hidden { display: none; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); column-gap: 14px; }
.tpl-grid .hidden { display: none; }
.tpl-readonly-value {
  padding: 8px 11px; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; background: var(--surface);
}
.tpl-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.tpl-row-head .modal-hint { margin: 0; }
.tpl-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5;
  resize: vertical; min-height: 160px; white-space: pre; overflow: auto; tab-size: 2;
}

.tpl-table-scroll { overflow-x: auto; margin-top: 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.tpl-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tpl-table th, .tpl-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.tpl-table th { color: var(--text-faint); font-weight: 600; font-size: 11.5px; background: var(--surface-2); }
.tpl-table tbody tr:last-child td { border-bottom: 0; }

/* files */
.tpl-files { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: start; }
.tpl-files-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tpl-file-list { display: flex; flex-direction: column; gap: 4px; }
.tpl-file-item {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  padding: 7px 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 12.5px; cursor: pointer;
}
.tpl-file-item:hover { border-color: var(--border); }
.tpl-file-item.is-active { border-color: var(--accent-line); background: var(--accent-soft); }
.tpl-file-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-file-item-size { color: var(--text-faint); font-size: 11px; flex-shrink: 0; }
.tpl-file-add-row { display: flex; gap: 6px; }
.tpl-file-add-error { margin: 0; }
.tpl-file-add-error:empty { display: none; }
.tpl-file-editor { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tpl-file-head { display: flex; align-items: center; gap: 8px; }
.tpl-file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-file-head .jobset-spacer { flex: 1 1 auto; }

.tpl-saveas-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; }

@media (max-width: 860px) {
  .tpl-row { flex-direction: column; align-items: stretch; }
  .tpl-row .manage-row-name, .tpl-row .manage-row-meta { white-space: normal; }
  .tpl-row-actions { justify-content: flex-start; }
  .tpl-backdrop { padding: 8px; }
  .tpl-editor { width: 100%; height: 92vh; max-height: 92vh; }
  .tpl-editor-body { padding: 12px; }
  .tpl-files { grid-template-columns: minmax(0, 1fr); }
  .tpl-editor-footer { flex-wrap: wrap; }
  .tpl-row-head { flex-wrap: wrap; }
}
