/* ── AI Chat Screen ─────────────────────────────────────────────────────────
   Mirrors the structural patterns of compiling_screen.css:
   same header height, same sc-toolbar, same scrollbar styling.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Screen layout ─────────────────────────────────────────────────────────── */

#ai-chat-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.aic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 12px;
  height: var(--screen-header-h, 65px);
  border-bottom: 1px solid var(--border, #e2e8f0);
  flex-shrink: 0;
  user-select: none;
  box-sizing: border-box;
}

.aic-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
}

/* ── Persona selector button ─────────────────────────────────────────────────── */

.aic-persona-btn {
  flex: 1;
  text-align: left;
  padding: 2px 8px;
  margin-left: 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted, #94a3b8);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  white-space: nowrap;
}

.aic-persona-btn:hover {
  border-color: var(--border, #e2e8f0);
  background: var(--bg-2, rgba(0,0,0,0.04));
  color: var(--text, #1e293b);
}

.aic-persona-btn[data-persona-id="boby"] {
  color: #a78bfa;
}

.aic-persona-btn[data-persona-id="boby"]:hover {
  border-color: rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.08);
  color: #a78bfa;
}

/* ── Messages area ──────────────────────────────────────────────────────────── */

.aic-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 6px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #cbd5e1) transparent;
}

.aic-messages::-webkit-scrollbar       { width: 4px; }
.aic-messages::-webkit-scrollbar-thumb { background: var(--border, #cbd5e1); border-radius: 4px; }

/* ── Chat bubbles ────────────────────────────────────────────────────────────── */

.aic-bubble {
  display: flex;
  max-width: 88%;
}

.aic-bubble--user {
  align-self: flex-end;
  justify-content: flex-end;
}

.aic-bubble--assistant {
  align-self: flex-start;
  justify-content: flex-start;
}

.aic-bubble-inner {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.aic-bubble--user .aic-bubble-inner {
  background: var(--aic-user-bg, #0ea5e9);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.aic-bubble--assistant .aic-bubble-inner {
  background: var(--aic-bot-bg, #f1f5f9);
  color: var(--text, #0f172a);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border, #e2e8f0);
}

.aic-thinking .aic-bubble-inner {
  opacity: 0.5;
  font-style: italic;
}

.aic-bubble--error .aic-bubble-inner {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ── Typewriter cursor ──────────────────────────────────────────────────────── */

.aic-cursor {
  display: inline-block;
  width: 2px;
  height: 0.85em;
  background: var(--text-muted, #94a3b8);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: aic-blink 0.65s step-end infinite;
}

@keyframes aic-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Input bar ──────────────────────────────────────────────────────────────── */

.aic-input-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border, #e2e8f0);
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface, #fff);
}

.aic-token-row {
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
  letter-spacing: 0.02em;
  padding: 0 2px;
}

.aic-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.aic-textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--bg, #f8fafc);
  color: var(--text, #0f172a);
  font-size: 0.83rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.aic-textarea:focus {
  border-color: var(--aic-accent, #0ea5e9);
  box-shadow: 0 0 0 2px rgba(14,165,233,0.12);
}

.aic-textarea::placeholder { color: var(--text-muted, #94a3b8); opacity: 0.6; }

.aic-send-btn {
  height: 40px;
  width: 40px;
  border: none;
  border-radius: 8px;
  background: var(--aic-accent, #0ea5e9);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(14,165,233,0.3);
}

.aic-send-btn:hover  { background: #0284c7; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(14,165,233,0.4); }
.aic-send-btn:active { transform: translateY(0); box-shadow: none; }
.aic-send-btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }


/* ── Theme overrides ────────────────────────────────────────────────────────── */

[data-theme="dark"],
[data-theme="grey"] {
  --aic-user-bg:  #1d4ed8;
  --aic-bot-bg:   rgba(255,255,255,0.06);
  --aic-accent:   #3b82f6;
}

[data-theme="dark"]  .aic-bubble--assistant .aic-bubble-inner { color: rgba(255,255,255,0.88); }
[data-theme="grey"]  .aic-bubble--assistant .aic-bubble-inner { color: rgba(255,255,255,0.88); }

[data-theme="aurora"] {
  --aic-user-bg:  #7c3aed;
  --aic-bot-bg:   rgba(192,132,252,0.07);
  --aic-accent:   #c084fc;
}

[data-theme="aurora"] .aic-bubble--assistant .aic-bubble-inner { color: rgba(255,255,255,0.88); }
[data-theme="aurora"] .aic-textarea:focus {
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(192,132,252,0.15);
}
