/*
 * Zeyn assistant chat: full page, panel and the floating launcher's side panel.
 * Colors come from the design tokens in zeyn.css, so light, dark and app themes apply.
 */

.z-assistant {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: calc(var(--z-radius) * 2);
  color: var(--z-text);
}

.z-assistant[data-zeyn-assistant="page"] {
  height: calc(100dvh - 9rem);
  min-height: 24rem;
  max-width: 56rem;
}

.z-assistant[data-zeyn-assistant="panel"] {
  height: 32rem;
}

.z-assistant-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--z-border);
}

.z-assistant-head h2 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.z-assistant-mark {
  display: inline-flex;
  color: var(--z-accent);
}

.z-assistant svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
}

.z-assistant-new {
  font-size: var(--z-font-size-sm);
}

.z-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--z-radius);
  background: transparent;
  color: var(--z-text-muted);
  cursor: pointer;
}

.z-icon-button:hover {
  background: var(--z-hover);
  color: var(--z-text);
}

.z-icon-button:focus-visible,
.z-chip:focus-visible,
.z-msg-action:focus-visible,
.z-assistant-launch:focus-visible,
.z-assistant-log:focus-visible {
  outline: 2px solid var(--z-accent);
  outline-offset: 2px;
}

.z-icon-button[aria-pressed="true"] {
  background: color-mix(in oklab, var(--z-danger) var(--z-tint), transparent);
  color: var(--z-danger);
}

.z-assistant-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  overscroll-behavior: contain;
}

.z-assistant-empty {
  margin: auto 0;
  padding: 1rem;
  color: var(--z-text-muted);
  text-align: center;
  line-height: 1.5;
}

.z-msg {
  max-width: 88%;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.z-msg-user {
  align-self: flex-end;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--z-radius) * 3) calc(var(--z-radius) * 3) var(--z-radius) calc(var(--z-radius) * 3);
  background: var(--z-primary);
  color: var(--z-on-primary);
  white-space: pre-wrap;
}

.z-msg-assistant {
  align-self: flex-start;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--z-radius) * 3) calc(var(--z-radius) * 3) calc(var(--z-radius) * 3) var(--z-radius);
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
}

.z-msg-body p,
.z-msg-body ul,
.z-msg-body ol,
.z-msg-body pre {
  margin: 0 0 0.5rem;
}

.z-msg-body > :last-child {
  margin-bottom: 0;
}

.z-msg-body ul,
.z-msg-body ol {
  padding-inline-start: 1.25rem;
}

.z-msg-body code {
  font-family: var(--z-font-mono);
  font-size: 0.9em;
  padding: 0 0.25rem;
  border-radius: var(--z-radius);
  background: var(--z-hover);
}

.z-msg-body pre {
  overflow-x: auto;
  padding: 0.5rem;
  border-radius: var(--z-radius);
  background: var(--z-hover);
}

.z-msg-body pre code {
  padding: 0;
  background: none;
}

.z-msg-typing {
  display: inline-flex;
  gap: 0.25rem;
  min-height: 1.5em;
  align-items: center;
}

.z-msg-typing::before,
.z-msg-typing::after {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--z-text-muted);
  animation: z-assistant-dot 1s infinite alternate;
}

.z-msg-typing::after {
  animation-delay: 0.3s;
}

@keyframes z-assistant-dot {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .z-msg-typing::before,
  .z-msg-typing::after {
    animation: none;
  }
}

.z-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.z-msg-action {
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius);
  background: var(--z-surface);
  color: var(--z-text-muted);
  font: inherit;
  font-size: var(--z-font-size-xs);
  cursor: pointer;
}

.z-msg-action:hover,
.z-msg-action[aria-pressed="true"] {
  color: var(--z-text);
  border-color: var(--z-border-strong);
}

.z-msg-tool,
.z-msg-note {
  margin: 0;
  color: var(--z-text-muted);
  font-size: var(--z-font-size-sm);
}

.z-msg-error {
  margin: 0.25rem 0 0;
  color: var(--z-danger);
  font-size: var(--z-font-size-sm);
}

.z-assistant-confirm {
  align-self: stretch;
  padding: 0.75rem;
  border: 1px solid var(--z-warning);
  border-radius: calc(var(--z-radius) * 2);
  background: color-mix(in oklab, var(--z-warning) var(--z-tint), var(--z-surface));
}

.z-assistant-confirm p {
  margin: 0 0 0.375rem;
}

.z-assistant-confirm-title {
  font-weight: 600;
}

.z-assistant-confirm dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.125rem 0.75rem;
  margin: 0 0 0.5rem;
  font-size: var(--z-font-size-sm);
}

.z-assistant-confirm dt {
  color: var(--z-text-muted);
}

.z-assistant-confirm dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.z-assistant-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.z-assistant-confirm.z-confirmed {
  border-color: var(--z-success);
  background: color-mix(in oklab, var(--z-success) var(--z-tint), var(--z-surface));
}

.z-assistant-confirm.z-declined {
  border-color: var(--z-border);
  background: var(--z-surface-2);
}

.z-assistant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 0.75rem;
}

.z-assistant-chips:not(:empty) {
  padding-bottom: 0.5rem;
}

.z-chip {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--z-border-strong);
  border-radius: 999px;
  background: var(--z-surface);
  color: var(--z-text);
  font: inherit;
  font-size: var(--z-font-size-sm);
  text-align: start;
  cursor: pointer;
}

.z-chip:hover:not(:disabled) {
  background: var(--z-hover);
}

.z-chip:disabled {
  opacity: 0.6;
  cursor: default;
}

.z-assistant-form {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  margin: 0 0.75rem;
  padding: 0.25rem;
  border: 1px solid var(--z-border-strong);
  border-radius: calc(var(--z-radius) * 2);
  background: var(--z-surface);
}

.z-assistant-form:focus-within {
  border-color: var(--z-accent);
  box-shadow: 0 0 0 1px var(--z-accent);
}

.z-assistant-form textarea {
  flex: 1;
  min-height: 2.25rem;
  max-height: 10rem;
  padding: 0.5rem;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--z-text);
  font: inherit;
  line-height: 1.4;
  field-sizing: content;
}

.z-assistant-send {
  color: var(--z-accent);
}

.z-assistant-note {
  margin: 0.375rem 0.75rem 0.625rem;
  color: var(--z-text-muted);
  font-size: var(--z-font-size-xs);
}

.z-assistant-launch {
  position: fixed;
  inset-inline-end: 1.25rem;
  inset-block-end: 1.25rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--z-primary);
  color: var(--z-on-primary);
  box-shadow: 0 6px 18px hsl(var(--z-shadow-color) / var(--z-shadow-strength));
  cursor: pointer;
}

.z-assistant-launch:hover {
  background: var(--z-primary-hover);
}

.z-assistant-launch svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

.z-assistant-launch[aria-expanded="true"] {
  display: none;
}

.z-assistant-dock {
  position: fixed;
  inset-inline-end: 1rem;
  inset-block-end: 1rem;
  z-index: 41;
  display: flex;
  width: min(26rem, calc(100vw - 2rem));
  height: min(40rem, calc(100dvh - 2rem));
  box-shadow: 0 12px 32px hsl(var(--z-shadow-color) / var(--z-shadow-strength));
  border-radius: calc(var(--z-radius) * 2);
}

.z-assistant-dock[hidden] {
  display: none;
}

.z-assistant-dock .z-assistant {
  flex: 1;
}

@media (max-width: 40rem) {
  .z-assistant-dock {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  .z-assistant-dock .z-assistant {
    border-radius: 0;
  }
}

@media (forced-colors: active) {
  .z-msg-user,
  .z-msg-assistant,
  .z-assistant-launch {
    border: 1px solid CanvasText;
  }
}

.z-assistant [hidden],
.z-assistant-launch[hidden] {
  display: none !important;
}
