/*
 * Internal audit UI refinements.
 * Keeps long template builders inside one predictable scroll region and
 * makes the five-step audit workflow easier to navigate.
 */

.workspace-dialog.template-dialog {
  overflow: hidden;
}

.template-dialog > .dialog-form {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100%;
  height: min(840px, calc(100vh - 38px));
  height: min(840px, calc(100dvh - 38px));
  max-height: calc(100vh - 38px);
  max-height: calc(100dvh - 38px);
  overflow: hidden;
}

.template-dialog .template-dialog-layout {
  min-height: 0;
  overflow: hidden;
}

.template-dialog .template-list-panel,
.template-dialog .template-builder-panel {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #88a9af transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.template-dialog .template-list-panel::-webkit-scrollbar,
.template-dialog .template-builder-panel::-webkit-scrollbar {
  width: 10px;
}

.template-dialog .template-list-panel::-webkit-scrollbar-thumb,
.template-dialog .template-builder-panel::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #88a9af;
  background-clip: padding-box;
}

.template-dialog .template-list-item[aria-current="true"] {
  border-color: rgba(8, 127, 133, 0.4);
  background: var(--pw-surface-tint, #edf7f7);
  box-shadow: inset 3px 0 var(--pw-brand, #078b91);
}

.template-dialog .dialog-actions {
  position: relative;
  z-index: 4;
  box-shadow: 0 -10px 24px rgba(16, 39, 49, 0.08);
}

.internal-audit-dialog .dialog-actions {
  justify-content: space-between;
}

.internal-audit-step-navigation,
.internal-audit-primary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.internal-audit-step-navigation {
  min-width: 0;
}

.internal-audit-step-status {
  min-width: 132px;
  color: var(--pw-ink-muted, #657985);
  font-size: 0.8rem;
  font-weight: 750;
  text-align: center;
}

.internal-audit-step-navigation button:disabled {
  opacity: 0.48;
  cursor: default;
}

@media (max-width: 900px) {
  .template-dialog .template-dialog-layout {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .template-dialog .template-list-panel,
  .template-dialog .template-builder-panel {
    overflow: visible;
    scrollbar-gutter: auto;
  }
}

@media (max-width: 700px) {
  .template-dialog > .dialog-form {
    height: 100dvh;
    max-height: 100dvh;
  }

  .internal-audit-dialog .dialog-actions {
    display: grid;
    gap: 10px;
  }

  .internal-audit-step-navigation,
  .internal-audit-primary-actions {
    justify-content: space-between;
    width: 100%;
  }

  .internal-audit-step-navigation button,
  .internal-audit-primary-actions button {
    flex: 1 1 0;
  }

  .internal-audit-step-status {
    min-width: 0;
  }
}
