.workflow-agent {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--text-primary);
  font: 400 0.9em / 1.6 var(--primary-font);
  user-select: text;
  -webkit-user-select: text;
}

.agent-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.65em;
  padding: 0.8em var(--panel-padding);
  border-bottom: 1px solid var(--border-subtle-color);

  h2 {
    flex: 1;
    margin: 0;
    font: 600 1em / 1.4 var(--display-font);
  }

  .status-indicator {
    font-size: 0.75em;
  }
}

.agent-icon {
  color: var(--power-primary-color);
  font-size: 1.3em;
}

.agent-scroll {
  overflow-wrap: anywhere;
}

.agent-turn {
  margin-bottom: 1.65em;
}

.agent-turn-heading {
  margin-bottom: 0.65em;
  opacity: 0.55;
  font-size: 0.75em;

  .agent-turn.user & {
    text-align: right;
  }
}

.agent-message {
  white-space: pre-wrap;

  &,
  *:not(span, .agent-roadmap *, .agent-results *) {
    user-select: text;
    -moz-user-select: text;
    -webkit-user-select: text;
    -ms-user-select: text;
    &::selection {
      color: var(--text-selection-color);
      background-color: var(--text-selection-bg);
    }
  }

  &.user {
    width: fit-content;
    max-width: 92%;
    margin-left: auto;
    padding: 0.75em 1em;
    border-radius: 1em 1em 0.25em 1em;
    background: var(--power-primary-color);
    color: var(--text-on-accent);
    box-shadow:
      0 0.25em 0.25em #00000000,
      0 0.5em 0.75em light-dark(rgb(0 0 0 / 6%), #00000024);
  }
}

.agent-finished {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 1em;
  opacity: 0.45;
  font-size: 0.75em;

  .material-symbols-outlined {
    font-size: 1.2em;
  }
}

.agent-results {
  margin-block: 1em;
}

.agent-roadmap {
  list-style: none;
  margin: 2.35em 0 1.25em;
  padding: 0;
}

.agent-step {
  position: relative;
  padding: 0 0 1.15em 1.5em;

  &:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 0.25em;
    top: 1.1em;
    bottom: 0.15em;
    border-left: 1px solid var(--border-subtle-color);
  }

  .status-indicator {
    color: inherit;
    font-size: 0.9em;
    line-height: 1.5;
  }

  .status-indicator-dot {
    position: absolute;
    left: 0;
    top: 0.5em;
    background: var(--status-color);
  }

  &[data-status='completed'] .status-indicator-dot {
    border-radius: 0;
    width: 0.65em;
    height: 0.35em;
    background: none;
    border: solid var(--status-color);
    border-width: 0 0 1.5px 1.5px;
    transform: rotate(-45deg);
  }

  &[data-status='pending'],
  &[data-status='skipped'] {
    opacity: 0.4;
  }
}

.agent-step-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75em;
}

.agent-step-duration,
.agent-step-detail {
  opacity: 0.5;
  font-size: 0.8em;
}

.agent-step-duration {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.agent-step-detail {
  margin: 0.3em 0 0;
  line-height: 1.5;
}

.agent-thinking {
  margin-block: 1em;
}

.agent-composer-wrap {
  flex-shrink: 0;
  padding: 0.65em;
}

.agent-composer {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin: 0;
  padding: 0.85em;
  border: 1px solid var(--border-main-color);
  border-radius: 0.85em;
  background: color-mix(in srgb, currentColor 3%, transparent);
  box-shadow:
    0 0.25em 0.25em #00000000,
    0 0.5em 0.75em light-dark(rgb(0 0 0 / 6%), #00000024),
    inset 0 0 1.25em light-dark(rgb(0 0 0 / 5%), #08111a3d);
  transition: border-color var(--spd-insp) ease;

  &::selection {
    color: var(--text-selection-color);
    background-color: var(--text-selection-bg);
  }

  &:focus-within {
    border-color: var(--power-primary-color);
  }

  textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 2.5lh;
    max-height: 8lh;
    field-sizing: content;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    box-shadow: none;
    resize: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;

    &::placeholder {
      color: inherit;
      opacity: 0.4;
    }
  }
}

.agent-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.agent-composer-hint {
  opacity: 0.35;
  font-size: 0.75em;
}

.agent-send {
  display: grid;
  place-items: center;
  width: 2.4em;
  height: 2.4em;
  border-radius: var(--grid-corners-radius);
  background: var(--power-primary-color);
  color: var(--text-on-accent);
  cursor: pointer;
  transition: opacity var(--spd-insp) ease;

  &:hover:not(:disabled) {
    opacity: 0.85;
  }

  &:disabled {
    opacity: 0.25;
    cursor: default;
  }

  &:focus-visible {
    outline: 2px solid var(--power-primary-color);
    outline-offset: 3px;
  }

  .material-symbols-outlined {
    font-size: 1.25em;
  }
}

.agent-error {
  color: var(--red-bad);
  margin-block: 1em;
}

.agent-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 60%;
  padding-block: 2em;

  > .material-symbols-outlined {
    color: var(--power-primary-color);
    font-size: 2em;
    margin-bottom: 0.75em;
  }

  h3 {
    margin: 0 0 0.5em;
    font: 500 1.25em / 1.5 var(--display-font);
  }

  p {
    margin: 0;
    opacity: 0.5;
  }
}

.agent-references {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-block: 0.65em;
}

.agent-reference {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  max-width: 100%;
  padding: 0.5em;
  border: 1px solid var(--border-main-color);
  border-radius: 0.65em;
  background: color-mix(in srgb, currentColor 5%, transparent);
  font-size: 0.9em;

  .material-symbols-outlined {
    font-size: 1.3em;
  }

  button {
    color: inherit;
    cursor: pointer;
  }

  img {
    width: 5em;
    max-height: 5em;
    height: auto;
    object-fit: contain;
    border-radius: 0.25em;
    background: black;
  }
}

.agent-reference-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
