/* Modal de formulário (executar / testar / novo registro) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.modal-overlay:has(.modal-run--with-preview) {
  padding: 12px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text, #111827);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text, #111827);
}

.modal-run.modal {
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-run.modal-run--with-preview {
  max-width: min(1320px, calc(100vw - 24px));
  width: min(1320px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  min-height: min(820px, calc(100vh - 24px));
  height: calc(100vh - 24px);
}

.modal-run .modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  gap: 0;
}

.modal-run .modal-form-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-run.modal-run--with-preview .modal-form-body {
  overflow: hidden;
  padding: 0;
  gap: 0;
}

.modal-run.modal-run--with-preview .modal-desc {
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.run-modal-layout {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal-run.modal-run--with-preview .run-modal-layout {
  flex-direction: row;
  align-items: stretch;
  min-height: 0;
  flex: 1;
}

.run-modal-layout-preview {
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f8fafc;
  border-right: 1px solid var(--border);
}

.run-modal-layout-preview:not(.hidden) {
  display: flex;
}

.modal-run.modal-run--with-preview .run-modal-layout-preview {
  flex: 1.25;
  padding: 24px;
}

.run-modal-layout-main {
  min-width: 0;
  min-height: 0;
}

.modal-run.modal-run--with-preview .run-modal-layout-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 16px;
}

.run-modal-file-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.run-modal-file-preview-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.run-modal-file-preview-frame {
  width: 100%;
  flex: 1;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
}

.run-modal-file-preview-image {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 360px;
  max-height: none;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
}

@media (max-width: 720px) {
  .modal-run.modal-run--with-preview .run-modal-layout {
    flex-direction: column;
  }

  .modal-run.modal-run--with-preview .run-modal-layout-preview {
    flex: none;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .modal-run.modal-run--with-preview .run-modal-file-preview-frame {
    min-height: 280px;
  }
}

.modal-notify-task .modal-form-body {
  gap: 12px;
}

.modal-notify-task .task-notify-message {
  flex: 1;
  min-height: 80px;
}

.modal-run .modal-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-run .modal-desc:empty {
  display: none;
}

.modal-run .modal-form-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-run .form-empty {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm, 4px);
}

.modal-run .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

.modal-run .modal-footer .toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text, #111827);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.modal-run .modal-footer .toolbar-btn:hover:not(:disabled) {
  background: var(--bg);
}

.modal-run .modal-footer .toolbar-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal-run .modal-footer .toolbar-btn.modal-btn-primary {
  background: var(--purple);
  color: var(--white);
  border-color: var(--purple);
}

.modal-run .modal-footer .toolbar-btn.modal-btn-primary:hover:not(:disabled) {
  background: var(--purple-dark);
  border-color: var(--purple-dark);
}

.modal-run .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-run .form-label,
.modal-run .form-label-row .form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
}

.modal-run .form-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.modal-run .form-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border-light, #F3F4F6);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.modal-run .form-field-desc {
  display: block;
  margin-top: -2px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 400;
}

.modal-run .form-field-checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-run .form-field-checkbox-text .form-field-desc {
  margin-top: 0;
}

.modal-run .form-field input,
.modal-run .form-field textarea,
.modal-run .form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  font: inherit;
  font-size: 14px;
  color: var(--text, #111827);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-run .form-field input:focus,
.modal-run .form-field textarea:focus,
.modal-run .form-field select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-light, #E6EEF7);
}

.modal-run .form-field textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-run .form-field select {
  cursor: pointer;
}

.modal-run .form-field-checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.modal-run .form-field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
}

.modal-run .form-field-checkbox .form-label {
  margin: 0;
  font-weight: 600;
  color: var(--text, #111827);
}

.modal-run .form-field-radio .form-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-run .form-field-radio--horizontal .form-radio-group {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.modal-run .form-radio-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text, #111827);
  cursor: pointer;
}

.modal-run .form-radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
}

.run-modal-state--running,
.run-modal-state--confirm {
  padding: 8px 0 4px;
}

.run-modal-running {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 120px;
  text-align: center;
}

.run-modal-running-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary, #6B7280);
}

.run-modal-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border, #E5E7EB);
  border-top-color: var(--purple, #1B3A6B);
  border-radius: 50%;
  animation: run-modal-spin 0.8s linear infinite;
}

@keyframes run-modal-spin {
  to {
    transform: rotate(360deg);
  }
}

.run-modal-confirm-message {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text, #111827);
  white-space: pre-wrap;
}

.run-modal-confirm-comment {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.run-modal-confirm-comment.hidden {
  display: none;
}

.run-modal-confirm-comment-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6B7280);
}

.run-modal-confirm-comment-input {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 4px);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.modal-run .modal-footer.hidden {
  display: none;
}

/* Database record picker (modal executar / testar) */
.db-record-picker {
  position: relative;
}

.db-record-picker.is-disabled .db-record-picker-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-run .db-record-picker-trigger,
.db-record-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 4px);
  background: var(--white, #ffffff);
  font: inherit;
  font-size: 14px;
  color: var(--text, #111827);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-run .db-record-picker-trigger:hover:not(:disabled),
.db-record-picker-trigger:hover:not(:disabled) {
  border-color: #c4c9d4;
}

.modal-run .db-record-picker-trigger:focus,
.db-record-picker-trigger:focus {
  outline: none;
  border-color: var(--purple, #1B3A6B);
  box-shadow: 0 0 0 3px var(--purple-light, #E6EEF7);
}

.db-record-picker-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-record-picker-trigger svg {
  flex-shrink: 0;
  color: var(--text-secondary, #6B7280);
}

.modal-run .db-record-picker-dropdown,
.db-record-picker-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white, #ffffff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.db-record-picker-dropdown.is-floating {
  position: fixed;
  right: auto;
  z-index: 300;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.db-record-picker-dropdown.hidden {
  display: none;
}

.db-record-picker-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #E5E7EB);
  background: var(--bg, #f9fafb);
}

.db-record-picker-search-wrap svg {
  flex-shrink: 0;
  color: var(--text-secondary, #6B7280);
}

.db-record-picker-search {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text, #111827);
  outline: none;
}

.db-record-picker-search::placeholder {
  color: var(--text-secondary, #6B7280);
}

.db-record-picker-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 240px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: var(--white, #ffffff);
}

.db-record-picker-option {
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s;
  background: var(--white, #ffffff);
}

.db-record-picker-option:hover,
.db-record-picker-option.selected {
  background: var(--purple-light, #E6EEF7);
}

.db-record-picker-option.selected {
  border-left-color: var(--purple, #1B3A6B);
}

.db-record-picker-option[hidden] {
  display: none;
}

.db-record-picker-option-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.db-record-picker-option-title-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-record-picker-option-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--purple, #1B3A6B);
  background: var(--purple-light, #E6EEF7);
}

.db-record-picker-option-preview {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary, #6B7280);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.db-record-picker-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-secondary, #6B7280);
  text-align: center;
  background: var(--white, #ffffff);
}

.db-record-picker-empty.hidden {
  display: none;
}

/* Modal de confirmação de exclusão */
.modal-delete .modal-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-delete .modal-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary, #6B7280);
  line-height: 1.5;
}

.modal-desc-danger {
  color: var(--text, #111827);
  font-weight: 500;
}

.modal-delete-warning {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #991B1B;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm, 4px);
}

.modal-delete-warning.hidden {
  display: none;
}

.modal-delete .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-delete .form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
}

.modal-delete .form-field input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 4px);
  font-size: 14px;
  font-family: inherit;
  color: var(--text, #111827);
  background: var(--white, #ffffff);
}

.modal-delete .form-field input:focus {
  outline: none;
  border-color: var(--purple, #7C3AED);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.modal-delete .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  border-top: none;
  background: transparent;
}

.modal-delete .modal-footer .toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 4px);
  background: var(--white, #ffffff);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text, #111827);
  cursor: pointer;
}

.modal-delete .modal-footer .toolbar-btn:hover:not(:disabled) {
  background: var(--bg, #F9FAFB);
}

.modal-delete .modal-footer .modal-btn-danger {
  background: #DC2626;
  color: var(--white, #ffffff);
  border-color: #DC2626;
}

.modal-delete .modal-footer .modal-btn-danger:hover:not(:disabled) {
  background: #B91C1C;
  border-color: #B91C1C;
}

.modal-delete .modal-footer .modal-btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

