/* ============================================================
   ANTIPHASE TECHNOLOGIES — AI PAGE STYLES
   Premium AI Chat Interface
   ============================================================ */

.ai-page {
  display: flex;
  flex-direction: column;
  height: 100svh;
  background-color: var(--color-bg);
  padding-top: var(--nav-height);
  overflow: hidden;
}

.ai-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════
   CHAT SCROLL AREA
════════════════════════════════════════ */
.ai-chat-area {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: var(--space-6) var(--space-4) 140px;
}

.ai-chat-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════
   EMPTY STATE & SUGGESTIONS
════════════════════════════════════════ */
.ai-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  margin-top: 10vh;
  animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-empty-state__avatar {
  width: 64px;
  height: 64px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  animation: gentlePulse 4s ease-in-out infinite;
}

.ai-empty-state__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}

.ai-empty-state__subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.ai-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  width: 100%;
  max-width: 600px;
}

.ai-suggestion-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-in-out);
}

.ai-suggestion-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-suggestion-btn__icon {
  color: var(--color-accent);
  font-size: var(--text-lg);
}

.ai-suggestion-btn__text {
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

@media (max-width: 600px) {
  .ai-suggestions {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════
   CHAT BUBBLES
════════════════════════════════════════ */
.ai-message-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  animation: fadeUp 0.4s var(--ease-out-expo) forwards;
}

.ai-bubble {
  max-width: 85%;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

/* User Message */
.ai-bubble--user {
  align-self: flex-end;
  background-color: var(--color-surface-2);
  color: var(--color-text-primary);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-xl);
  border-bottom-right-radius: var(--space-1);
}

/* Assistant Message */
.ai-bubble--ai {
  align-self: flex-start;
  color: var(--color-text-primary);
  padding: var(--space-2) 0;
  max-width: 100%;
  display: flex;
  gap: var(--space-4);
}

.ai-bubble--ai::before {
  content: '⬡';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-accent);
  font-size: 18px;
}

.ai-bubble-content {
  flex: 1;
  min-width: 0; /* allows text wrapping properly */
}

/* Markdown Styles inside AI bubble */
.ai-bubble-content p {
  margin-bottom: var(--space-4);
}
.ai-bubble-content p:last-child {
  margin-bottom: 0;
}
.ai-bubble-content strong {
  font-weight: var(--weight-semibold);
  color: #fff;
}
.ai-bubble-content code {
  font-family: monospace;
  background-color: rgba(255, 255, 255, 0.1);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}
.ai-bubble-content pre {
  background-color: #111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}
.ai-bubble-content pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  color: #e5e5e5;
}
.ai-bubble-content ul, .ai-bubble-content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-5);
}
.ai-bubble-content li {
  margin-bottom: var(--space-2);
}

/* Citations */
.ai-sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-left: 48px; /* Align with text, offset by avatar */
}
.ai-sources__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
}
.ai-sources__tag {
  font-size: var(--text-xs);
  padding: 2px 8px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
}

/* ════════════════════════════════════════
   STICKY DOCK & INPUT
════════════════════════════════════════ */
.ai-dock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4);
  background: linear-gradient(0deg, var(--color-bg) 60%, transparent);
  pointer-events: none; /* Let clicks pass through gradient */
}

.ai-dock__inner {
  max-width: 700px;
  margin: 0 auto;
  pointer-events: auto; /* Re-enable clicks */
}

.ai-input-wrapper {
  display: flex;
  align-items: flex-end;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.ai-input-wrapper:focus-within {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.ai-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  line-height: 1.5;
  padding: var(--space-2) 0;
  resize: none;
  max-height: 200px;
  outline: none;
  margin-right: var(--space-2);
}

.ai-input-field::placeholder {
  color: var(--color-text-muted);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--color-text-primary);
  color: var(--color-bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: all var(--duration-fast) ease;
}

.ai-send-btn:disabled {
  background-color: var(--color-surface-3);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.ai-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.ai-dock__footer {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

/* ════════════════════════════════════════
   LOADING STATE
════════════════════════════════════════ */
.ai-bubble--loading .ai-bubble-content {
  display: flex;
  align-items: center;
  height: 24px;
}

.ai-loading-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-accent);
  animation: gentlePulse 1.5s ease-in-out infinite;
}

/* ════════════════════════════════════════
   ERROR STATE
════════════════════════════════════════ */
.ai-bubble--error .ai-bubble-content {
  color: var(--color-error);
  background-color: rgba(255, 80, 80, 0.1);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 80, 80, 0.2);
}

/* ════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes gentlePulse {
  0% { opacity: 0.6; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ════════════════════════════════════════
   INTERACTION & CURSOR OVERRIDES
════════════════════════════════════════ */
/* 1. Override global.css custom cursor and restore default pointer behavior */
html, body, .ai-page {
  cursor: auto !important;
}

/* 2. Hide the custom cursor element entirely if it was created */
.custom-cursor {
  display: none !important;
}

/* 3. Ensure text inputs and textareas show the text selection I-beam */
.ai-input-field, textarea, input {
  cursor: text !important;
}

/* 4. Ensure buttons, links, and suggested prompts show the pointer hand */
.ai-suggestion-btn, .ai-send-btn, button, a {
  cursor: pointer !important;
}
