/* ============================================
WAVLENTH — WAVLENTH AI PAGE STYLES
Wavlenth AI-specific only. Shared app-shell lives
in app-shell.css. Tokens live in global.css.
Accent color: AI Blue (#5B7CFA)
============================================ */

.ai-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
}

.ai-subtitle {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 4px;
}

.ai-credits {
  padding: var(--space-xl) 0 var(--space-md);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
  opacity: 0.75;
}

.ai-content .section-heading {
  color: var(--accent-ai);
}

/* ========================================
WELCOME CARD
======================================== */

.ai-welcome {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.ai-welcome:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.ai-welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    var(--accent-ai),
    rgba(91, 124, 250, 0.4)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.ai-welcome-text {
  flex: 1;
  min-width: 0;
}

.ai-welcome-text h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 4px;
}

.ai-welcome-text p {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 8px 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 999px;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: ai-pulse 2s ease-in-out infinite;
}

@keyframes ai-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.ai-status-text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #22c55e;
}

/* ========================================
QUICK ACTIONS
======================================== */

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.quick-action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.quick-action-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-ai);
  box-shadow: var(--shadow-card);
}

.quick-action-icon {
  font-size: 1.75rem;
}

.quick-action-label {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
}

.quick-action-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* ========================================
CHAT SECTION
======================================== */

.ai-chat-section {
  padding: 0;
}

.ai-chat-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 8px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Message Bubbles */
.ai-message {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  max-width: 85%;
  animation: ai-message-in 0.3s ease forwards;
}

@keyframes ai-message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.ai-message-ai {
  align-self: flex-start;
}

.ai-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ai-message-ai .ai-message-avatar {
  background: linear-gradient(
    135deg,
    var(--accent-ai),
    rgba(91, 124, 250, 0.3)
  );
  border-color: var(--accent-ai);
}

.ai-message-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: var(--fs-sm);
  line-height: 1.6;
  word-wrap: break-word;
}

.ai-message-user .ai-message-bubble {
  background: var(--accent-ai);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-message-ai .ai-message-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* ── Markdown rendering inside AI bubbles ── */
.ai-message-bubble .ai-h1,
.ai-message-bubble .ai-h2,
.ai-message-bubble .ai-h3,
.ai-message-bubble .ai-h4,
.ai-message-bubble .ai-h5,
.ai-message-bubble .ai-h6 {
  margin: 10px 0 4px;
  font-family: var(--font-display);
  color: var(--accent-ai);
  line-height: 1.3;
}
.ai-message-bubble .ai-h1 {
  font-size: 1.3rem;
}
.ai-message-bubble .ai-h2 {
  font-size: 1.15rem;
}
.ai-message-bubble .ai-h3 {
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.ai-message-bubble .ai-h4,
.ai-message-bubble .ai-h5,
.ai-message-bubble .ai-h6 {
  font-size: 0.9rem;
}

.ai-message-bubble .ai-ul,
.ai-message-bubble .ai-ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.ai-message-bubble .ai-ul li,
.ai-message-bubble .ai-ol li {
  margin-bottom: 3px;
  line-height: 1.5;
}

.ai-message-bubble .ai-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.ai-message-bubble .ai-inline-code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82em;
}

.ai-message-bubble .ai-code-block {
  background: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82em;
  margin: 8px 0;
  white-space: pre;
}

.ai-message-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.7;
}

.ai-message-user .ai-message-time {
  text-align: right;
}

/* Typing Indicator */
.ai-typing {
  display: flex;
  gap: 4px;
  padding: 18px;
  align-self: flex-start;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-ai);
  animation: ai-typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ai-typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-6px);
  }
}

/* Suggested Prompts */
.ai-suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: rgba(91, 124, 250, 0.03);
}

.ai-prompt-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-ai);
  background: rgba(91, 124, 250, 0.1);
  border: 1px solid rgba(91, 124, 250, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
  white-space: nowrap;
}

.ai-prompt-chip:hover {
  background: var(--accent-ai);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Input Area */
.ai-chat-input-area {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.ai-input-wrap {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.ai-chat-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--text);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

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

.ai-chat-input:focus {
  outline: none;
  border-color: var(--accent-ai);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.15);
}

.ai-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-ai);
  color: #ffffff;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform var(--transition),
    box-shadow var(--transition);
  flex-shrink: 0;
}

.ai-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(91, 124, 250, 0.4);
}

.ai-send-btn:active {
  transform: scale(0.95);
}

.ai-input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.ai-subject-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}

.ai-subject-select:focus {
  outline: none;
  border-color: var(--accent-ai);
}

.ai-subject-select option {
  background: var(--card);
  color: var(--text);
}

.ai-clear-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 10px;
  transition:
    color var(--transition),
    background var(--transition);
}

.ai-clear-btn:hover {
  color: var(--accent-music);
  background: rgba(239, 68, 68, 0.1);
}

/* ========================================
STUDY HISTORY
======================================== */

.ai-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.ai-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-md) var(--space-lg);
  transition:
    transform var(--transition),
    border-color var(--transition);
  cursor: pointer;
}

.ai-history-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-ai);
}

.ai-history-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(91, 124, 250, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ai-history-info {
  flex: 1;
  min-width: 0;
}

.ai-history-subject {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}

.ai-history-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-history-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

/* ========================================
EMPTY STATE
======================================== */

.ai-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}

.ai-empty-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.ai-empty-text {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* ========================================
RESPONSIVE
======================================== */

@media (max-width: 1100px) {
  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .ai-welcome {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-status {
    margin-left: 0;
  }

  .ai-message {
    max-width: 90%;
  }
}

@media (max-width: 700px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .ai-chat-messages {
    min-height: 300px;
    max-height: 450px;
    padding: var(--space-md);
  }

  .ai-suggested-prompts {
    padding: var(--space-sm) var(--space-md);
  }

  .ai-chat-input-area {
    padding: var(--space-sm) var(--space-md);
  }

  .ai-input-meta {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .ai-message {
    max-width: 95%;
  }

  .ai-message-avatar {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  .ai-message-bubble {
    padding: 10px 14px;
    font-size: 14px;
  }
}
