/* Chat and preview workspace. Tokens come from admin-base.css (.wpagently-admin);
   this file must not define colours of its own. */

.wpagently-preview-toolbar,
.wpagently-chat-form {
  align-items: center;
  display: flex;
  gap: 10px;
}

.wpagently-chat-heading {
  margin-bottom: 18px;
  max-width: 1480px;
  padding-right: 210px;
  position: relative;
}

.wpagently-chat-heading > .button {
  position: absolute;
  right: 0;
  top: 30px;
}

.wpagently-chat-heading h1 {
  color: var(--wpa-text);
  margin-bottom: 4px;
}

.wpagently-chat-heading p {
  color: var(--wpa-muted);
  margin: 0;
}

.wpagently-chat-eyebrow {
  color: var(--wpa-accent) !important;
  font-family: var(--wpa-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.wpagently-workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 2fr) minmax(480px, 3fr);
  margin-top: 18px;
  max-width: 1480px;
}

.wpagently-chat-panel,
.wpagently-preview-panel {
  background: var(--wpa-surface);
  border: 1px solid var(--wpa-border);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.wpagently-chat-panel {
  display: flex;
  flex-direction: column;
  height: 720px;
}

.wpagently-chat-log {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

.wpagently-message,
.wpagently-action {
  border-radius: 6px;
  line-height: 1.5;
  margin: 0 0 12px;
  max-width: 88%;
  padding: 11px 13px;
  white-space: pre-wrap;
}

.wpagently-message-assistant {
  background: var(--wpa-surface-2);
  color: var(--wpa-text);
}

.wpagently-message-user {
  background: var(--wpa-term-surface);
  color: var(--wpa-term-text);
  margin-left: auto;
}

.wpagently-message-status {
  color: var(--wpa-muted);
  font-style: italic;
}

.wpagently-message.has-error,
.wpagently-action.has-error {
  color: var(--wpa-risk);
}

.wpagently-action {
  background: var(--wpa-surface);
  border: 1px solid var(--wpa-border);
  max-width: none;
}

.wpagently-action > code,
.wpagently-action > strong {
  display: block;
  margin-bottom: 8px;
}

.wpagently-action pre {
  background: var(--wpa-term-bg);
  border-radius: var(--wpa-radius-sm);
  color: var(--wpa-term-text);
  font-family: var(--wpa-font-mono);
  max-height: 180px;
  overflow: auto;
  padding: var(--wpa-space-3);
  white-space: pre-wrap;
}

.wpagently-action.is-completed {
  border-left: 4px solid var(--wpa-safe);
}

.wpagently-action-status {
  color: var(--wpa-muted);
  margin-bottom: 0;
}

.wpagently-chat-form {
  align-items: stretch;
  border-top: 1px solid var(--wpa-border);
  flex-direction: column;
  padding: 16px;
}

.wpagently-chat-form label {
  font-weight: 600;
}

.wpagently-chat-form textarea {
  resize: vertical;
}

.wpagently-preview-panel {
  display: flex;
  flex-direction: column;
  height: 720px;
}

.wpagently-preview-toolbar {
  border-bottom: 1px solid var(--wpa-border);
  flex-wrap: wrap;
  padding: 10px;
}

.wpagently-preview-toolbar input {
  flex: 1 1 180px;
  min-width: 120px;
}

.wpagently-preview-toolbar .button[hidden] {
  display: none;
}

.wpagently-preview-error {
  color: var(--wpa-risk);
  min-height: 0;
  padding: 0 10px;
}

.wpagently-preview-selection {
  background: var(--wpa-surface-2);
  border-left: 4px solid var(--wpa-accent);
  color: var(--wpa-text);
  margin: 8px 10px 0;
  max-height: 70px;
  overflow: auto;
  padding: 8px 10px;
  white-space: pre-wrap;
}

.wpagently-preview-panel > .description {
  margin: 8px 10px;
}

#wpagently-preview {
  background: var(--wpa-surface);
  border: 0;
  flex: 1;
  min-height: 0;
  width: 100%;
}

@media (max-width: 1050px) {
  .wpagently-workspace {
    grid-template-columns: 1fr;
  }

  .wpagently-chat-panel,
  .wpagently-preview-panel {
    height: 640px;
  }
}

@media (max-width: 782px) {
  .wpagently-chat-heading {
    padding-right: 0;
  }

  .wpagently-chat-heading > .button {
    display: inline-block;
    margin-top: 12px;
    position: static;
  }

  .wpagently-preview-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .wpagently-preview-toolbar input {
    flex-basis: 100%;
  }
}
