/* ================================================================
   AI Tool Interface — Universal conversational input layer
   TechStackIPO · 2026
   ================================================================ */

.ati-wrapper {
  margin-bottom: 0;
}

/* ── Mode Toggle ─────────────────────────────────────────────── */
.ati-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.ati-mode-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ati-accent, #7c3aed);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ati-mode-label svg {
  opacity: 0.85;
}

.ati-switch-link {
  font-size: 12px;
  color: var(--ati-muted, #64748b);
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ati-switch-link:hover {
  color: var(--ati-accent, #7c3aed);
}

/* ── Chat Container ──────────────────────────────────────────── */
.ati-chat-box {
  border-radius: 16px;
  overflow: hidden;
  border: 1.5px solid var(--ati-border, rgba(124,58,237,0.25));
  background: var(--ati-bg, #0f172a);
  transition: border-color 0.2s;
}

.ati-chat-box:focus-within {
  border-color: var(--ati-accent, #7c3aed);
}

/* ── Messages Area ───────────────────────────────────────────── */
.ati-messages {
  padding: 20px 20px 12px;
  min-height: 80px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(124,58,237,0.2) transparent;
}

.ati-messages::-webkit-scrollbar { width: 4px; }
.ati-messages::-webkit-scrollbar-track { background: transparent; }
.ati-messages::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.25); border-radius: 4px; }

/* Message bubbles */
.ati-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: atiFadeIn 0.2s ease;
}

@keyframes atiFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ati-msg.ati-msg-user {
  flex-direction: row-reverse;
}

.ati-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.ati-msg-ai .ati-msg-avatar {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
}

.ati-msg-user .ati-msg-avatar {
  background: rgba(255,255,255,0.08);
  color: #94a3b8;
}

.ati-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
}

.ati-msg-ai .ati-msg-bubble {
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.18);
  color: var(--ati-text, #e2e8f0);
  border-bottom-left-radius: 4px;
}

.ati-msg-user .ati-msg-bubble {
  background: rgba(37,99,235,0.18);
  border: 1px solid rgba(37,99,235,0.25);
  color: var(--ati-text, #e2e8f0);
  border-bottom-right-radius: 4px;
}

/* ── Typing Indicator ────────────────────────────────────────── */
.ati-typing {
  display: flex;
  gap: 10px;
  align-items: center;
  animation: atiFadeIn 0.2s ease;
}

.ati-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.18);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.ati-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  opacity: 0.5;
  animation: atiDot 1.2s ease-in-out infinite;
}

.ati-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ati-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes atiDot {
  0%, 60%, 100% { opacity: 0.2; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1.1); }
}

/* ── Confirm Card ────────────────────────────────────────────── */
.ati-confirm-card {
  margin: 8px 0 0;
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}

.ati-confirm-card-title {
  font-weight: 700;
  color: #34d399;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ati-confirm-card-preview {
  color: var(--ati-text, #e2e8f0);
  margin-bottom: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}

.ati-confirm-params {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.ati-param-chip {
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.25);
  color: #a78bfa;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.ati-confirm-actions {
  display: flex;
  gap: 8px;
}

.ati-btn-confirm {
  flex: 1;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ati-btn-confirm:hover { opacity: 0.88; }
.ati-btn-confirm:disabled { opacity: 0.4; cursor: not-allowed; }

.ati-btn-edit {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--ati-muted, #64748b);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.ati-btn-edit:hover {
  border-color: rgba(255,255,255,0.2);
  color: #94a3b8;
}

/* ── Suggestions Chips ───────────────────────────────────────── */
.ati-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ati-suggestion-chip {
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
  color: #a78bfa;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-width: 1px;
  font-family: inherit;
}

.ati-suggestion-chip:hover {
  background: rgba(124,58,237,0.18);
  border-color: rgba(124,58,237,0.4);
  color: #c4b5fd;
}

/* ── Company Disambiguation ──────────────────────────────────── */
.ati-company-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.ati-company-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--ati-text, #e2e8f0);
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

.ati-company-choice:hover {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.3);
}

.ati-company-choice-name {
  font-weight: 600;
  flex: 1;
}

.ati-company-choice-meta {
  font-size: 11.5px;
  color: var(--ati-muted, #64748b);
}

/* ── Input Row ───────────────────────────────────────────────── */
.ati-input-row {
  display: flex;
  gap: 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}

.ati-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-size: 14.5px;
  color: var(--ati-text, #e2e8f0);
  font-family: inherit;
  resize: none;
  min-height: 50px;
  max-height: 120px;
  line-height: 1.5;
}

.ati-input::placeholder {
  color: var(--ati-placeholder, #475569);
}

.ati-send-btn {
  width: 48px;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(255,255,255,0.06);
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ati-send-btn:hover {
  color: #7c3aed;
  background: rgba(124,58,237,0.06);
}

.ati-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ati-send-btn.ati-send-active {
  color: #7c3aed;
}

/* ── Light theme variant (for investment memo page) ────────── */
.ati-theme-light .ati-chat-box {
  background: #ffffff;
  border-color: rgba(79,124,255,0.2);
}

.ati-theme-light .ati-chat-box:focus-within {
  border-color: #4f7cff;
}

.ati-theme-light .ati-msg-ai .ati-msg-bubble {
  background: rgba(79,124,255,0.06);
  border-color: rgba(79,124,255,0.15);
  color: #0f172a;
}

.ati-theme-light .ati-msg-user .ati-msg-bubble {
  background: rgba(79,124,255,0.1);
  border-color: rgba(79,124,255,0.2);
  color: #0f172a;
}

.ati-theme-light .ati-typing-dots {
  background: rgba(79,124,255,0.06);
  border-color: rgba(79,124,255,0.15);
}

.ati-theme-light .ati-typing-dots span {
  background: #4f7cff;
}

.ati-theme-light .ati-msg-ai .ati-msg-avatar {
  background: linear-gradient(135deg, #4f7cff, #7c3aed);
}

.ati-theme-light .ati-input {
  color: #0f172a;
}

.ati-theme-light .ati-input::placeholder {
  color: #94a3b8;
}

.ati-theme-light .ati-input-row {
  border-top-color: #e2e8f0;
  background: #f8fafc;
}

.ati-theme-light .ati-send-btn {
  border-left-color: #e2e8f0;
}

.ati-theme-light .ati-send-btn:hover {
  color: #4f7cff;
  background: rgba(79,124,255,0.06);
}

.ati-theme-light .ati-switch-link {
  color: #94a3b8;
}

.ati-theme-light .ati-switch-link:hover {
  color: #4f7cff;
}

.ati-theme-light .ati-mode-label {
  color: #4f7cff;
}

.ati-theme-light .ati-confirm-card {
  background: rgba(16,185,129,0.04);
  border-color: rgba(16,185,129,0.2);
}

.ati-theme-light .ati-confirm-card-preview {
  color: #1e293b;
}

.ati-theme-light .ati-company-choice {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #0f172a;
}

.ati-theme-light .ati-company-choice:hover {
  background: rgba(79,124,255,0.06);
  border-color: rgba(79,124,255,0.25);
}

.ati-theme-light .ati-company-choice-meta {
  color: #94a3b8;
}

.ati-theme-light .ati-suggestion-chip {
  background: rgba(79,124,255,0.06);
  border-color: rgba(79,124,255,0.18);
  color: #4f7cff;
}

.ati-theme-light .ati-suggestion-chip:hover {
  background: rgba(79,124,255,0.12);
}

.ati-theme-light .ati-param-chip {
  background: rgba(79,124,255,0.08);
  border-color: rgba(79,124,255,0.2);
  color: #4f7cff;
}

/* ── Data Label Badges ───────────────────────────────────────── */
.ati-data-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 4px;
}

.ati-label-verified {
  background: rgba(16,185,129,0.1);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.2);
}

.ati-label-estimate {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.2);
}

.ati-label-expert {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ati-messages { max-height: 220px; }
  .ati-msg-bubble { max-width: 90%; font-size: 13.5px; }
  .ati-input { font-size: 16px; /* Prevent iOS zoom */ }
  .ati-confirm-actions { flex-direction: column; }
}
