/* ─── AIInput Universal Component Styles ──────────────────────────────────── */

.ai-input-root {
  width: 100%;
}

.ai-input-panel {
  background: #0f1117;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.08), 0 4px 24px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s;
}

.ai-input-panel:focus-within {
  border-color: rgba(99, 102, 241, 0.6);
}

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

.ai-input-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(99, 102, 241, 0.04);
}

.ai-input-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  text-transform: uppercase;
}

.ai-input-badge svg {
  flex-shrink: 0;
}

.ai-input-title {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  flex: 1;
}

.ai-input-manual-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  text-decoration: underline;
  text-decoration-color: transparent;
}

.ai-input-manual-link:hover {
  color: rgba(255, 255, 255, 0.6);
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

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

.ai-input-messages {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.ai-input-messages::-webkit-scrollbar {
  width: 4px;
}

.ai-input-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-input-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.ai-msg {
  display: flex;
  max-width: 90%;
}

.ai-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg--assistant {
  align-self: flex-start;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg--assistant .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  border-bottom-left-radius: 4px;
}

.ai-msg--user .ai-msg-bubble {
  background: rgba(99, 102, 241, 0.2);
  color: #e0e7ff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* ─── Typing indicator ────────────────────────────────────────────────────── */

.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-typing-dots span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: ai-typing-bounce 1.2s infinite;
}

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

@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ─── Composer ────────────────────────────────────────────────────────────── */

.ai-input-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-input-textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  padding: 9px 12px;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  min-height: 40px;
  max-height: 120px;
}

.ai-input-textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.ai-input-textarea:focus {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

.ai-input-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-input-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.8);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.ai-input-send:hover:not(:disabled) {
  background: rgba(99, 102, 241, 1);
}

.ai-input-send:active:not(:disabled) {
  transform: scale(0.95);
}

.ai-input-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Ready bar ───────────────────────────────────────────────────────────── */

.ai-input-ready-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.08);
  border-top: 1px solid rgba(99, 102, 241, 0.25);
  animation: ai-ready-slide-in 0.3s ease;
}

@keyframes ai-ready-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-input-ready-text {
  font-size: 13px;
  color: rgba(165, 180, 252, 0.9);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-input-ready-text::before {
  content: '✓';
  display: inline-flex;
  width: 18px;
  height: 18px;
  background: rgba(99, 102, 241, 0.3);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #a5b4fc;
}

.ai-input-run-btn {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.ai-input-run-btn:hover {
  opacity: 0.9;
}

.ai-input-run-btn:active {
  transform: scale(0.97);
}

/* ─── Section divider (used on tool pages between AI and form) ────────────── */

.ai-or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ai-or-divider::before,
.ai-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

/* ─── Form toggle section ─────────────────────────────────────────────────── */

.ai-form-section {
  display: none;
}

.ai-form-section.ai-form-section--visible {
  display: block;
  animation: ai-fade-in 0.2s ease;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .ai-input-ready-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .ai-input-run-btn {
    width: 100%;
    text-align: center;
  }
}
