/* Input area */
.chat-input-wrapper {
  flex-shrink: 0;
  padding: 0 var(--space-4) var(--space-3);
  background: var(--chat-bg);
  transition: background 0.2s;
  position: relative;
  z-index: 200;
}

.chat-input-container {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--chat-input-bg);
  border: var(--border-width-1) solid var(--chat-border);
  border-radius: 1.5rem;
  padding: 0.375rem;
  transition:
    border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-container.multiline {
  border-radius: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding-top: 8px;
  padding-bottom: 8px;
}

.chat-input-container.multiline .chat-input {
  flex-basis: 100%;
  padding: var(--space-1) var(--space-2) 0;
}

.chat-input-container.multiline .chat-input-plus-wrap {
  order: 1;
}

.chat-input-container.multiline .chat-mic-wrap {
  order: 2;
  margin-left: auto;
}

.chat-input-container.multiline .chat-send-btn {
  order: 3;
}

.chat-input-container:focus-within {
  border-color: var(--chat-accent);
}

/* Context mode: wrap layout — textarea full-width on top, controls row below */
.chat-input-container.has-context {
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-2);
  border-radius: 1.5rem;
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Pill mode: chip row hidden */
.chat-input-bottom-row {
  display: none;
}

/* Context mode: chip row shown, fills the second flex line */
.chat-input-container.has-context .chat-input-bottom-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
}

/* Textarea: full-width in context mode so it sits alone on the first row */
.chat-input-container.has-context .chat-input {
  flex-basis: 100%;
  padding: var(--space-2) var(--space-2) 0;
}

/* Send button: move to end of second row in context mode (after mic btn order 3) */
.chat-input-container.has-context .chat-send-btn {
  order: 4;
}

/* + button: move to start of second row in context mode */
.chat-input-container.has-context .chat-input-plus-wrap {
  order: 1;
}

.chat-input-container.has-context .chat-input-plus-btn {
  width: 36px;
  height: 36px;
}

/* Chip row fills between + and send */
.chat-input-container.has-context .chat-input-bottom-row {
  order: 2;
  flex: 1;
}

/* Chip: hidden until context active */
.chat-context-chip {
  display: none;
}
.chat-input-container.has-context .chat-context-chip {
  display: flex;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--chat-text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  overflow-y: auto;
  text-align: left;
  transition: none;
}
.chat-input::placeholder {
  color: var(--chat-text-dim);
}

.chat-stop-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chat-send-icon);
  position: absolute;
  right: 0.375rem;
  bottom: 0.375rem;
  transition:
    background 0.2s,
    opacity 0.2s;
  z-index: 2;
}

.chat-input-container.has-context .chat-stop-btn {
  order: 5;
  position: static;
  margin-left: auto;
}

.chat-stop-btn:hover {
  background: var(--chat-accent-hover);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chat-send-icon);
  transition:
    background 0.2s,
    opacity 0.2s;
}

.chat-send-btn:hover {
  background: var(--chat-accent-hover);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-input-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--chat-text-dim);
  margin-top: var(--space-2);
}

/* Error state */
.chat-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--chat-error-bg);
  border: var(--border-width-1) solid var(--chat-error-border);
  color: var(--chat-error-text);
  border-radius: var(--radius-lg);
  padding: 0.875rem var(--space-4);
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* Scrollbar for textarea */
.chat-input::-webkit-scrollbar {
  width: 3px;
}
.chat-input::-webkit-scrollbar-thumb {
  background: var(--chat-scrollbar);
}
