/* =============================================================
   ai.css — Kemotech AI Assistant Page Styles
   Inherits all variables from style.css (loaded first)
   ============================================================= */

/* ── 1. Hero ─────────────────────────────────────────────────── */
.ai-hero {
  position: relative;
  min-height: 540px;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding-top: var(--nav-height);
}
.ai-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.ai-hero-bg-img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.ai-hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(240,237,248,0.93) 0%, rgba(230,223,245,0.88) 100%);
}
.ai-hero-inner {
  position: relative;
  z-index: 1;
  padding: 4rem 0 3.5rem;
  max-width: 680px;
}
.ai-hero-tag { margin-bottom: 1.1rem; }
.ai-hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}
.ai-hero-sub {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}
.ai-hero-desc {
  font-size: 0.97rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 2rem;
}
.ai-hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Hero badge strip */
.ai-hero-badges {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}
.ai-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* ── 2. Chat Section ─────────────────────────────────────────── */
.ai-chat-section { background: var(--bg-primary); }

/* Category Tabs */
.ai-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.ai-tab {
  padding: 0.55rem 1.4rem;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.ai-tab:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.ai-tab.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #ffffff;
}

/* ── 3. Prompt Cards ─────────────────────────────────────────── */
.ai-prompts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.ai-prompt-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  text-align: left;
  font-family: var(--font-main);
}
.ai-prompt-card:hover {
  border-color: rgba(124,58,237,0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(30,27,75,0.10);
}
.ai-prompt-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124,58,237,0.08);
  border-radius: 8px;
}
.ai-prompt-text {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── 4. Chat Container ───────────────────────────────────────── */
.ai-chat-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 4px 24px rgba(30,27,75,0.07);
}
.ai-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.ai-chat-header-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
  animation: ai-pulse-dot 2s infinite;
}
.ai-chat-header-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}
.ai-chat-header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Messages area */
.ai-messages {
  height: 0;
  min-height: 0;
  max-height: 520px;
  overflow-y: auto;
  transition: height 0.2s ease;
}
.ai-messages.has-messages {
  height: 45vh;
  min-height: 260px;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.ai-messages::-webkit-scrollbar { width: 5px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* Empty state */
.ai-empty-state {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: left;
  color: var(--text-muted);
  padding: 0.6rem 1rem;
}
.ai-empty-icon {
  font-size: 1.4rem;
  opacity: 0.6;
  flex-shrink: 0;
}
.ai-empty-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.1rem;
}
.ai-empty-sub {
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 300px;
}

/* Message bubbles */
.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: ai-msg-in 0.28s ease forwards;
}
.ai-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}
.ai-msg--ai {
  align-self: flex-start;
  align-items: flex-start;
}
.ai-msg-bubble {
  padding: 0.85rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.65;
  word-break: break-word;
}
.ai-msg--user .ai-msg-bubble {
  background: var(--accent-purple);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
}
.ai-msg--ai .ai-msg-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
}

/* Markdown inside AI bubbles */
.ai-msg--ai .ai-msg-bubble strong { font-weight: 700; }
.ai-msg--ai .ai-msg-bubble em { font-style: italic; }
.ai-msg--ai .ai-msg-bubble code {
  background: rgba(124,58,237,0.1);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: monospace;
}
.ai-msg--ai .ai-msg-bubble pre {
  background: rgba(30,27,75,0.06);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}
.ai-msg--ai .ai-msg-bubble pre code {
  background: none;
  padding: 0;
}
.ai-msg--ai .ai-msg-bubble h1,
.ai-msg--ai .ai-msg-bubble h2,
.ai-msg--ai .ai-msg-bubble h3 {
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  color: var(--text-primary);
}
.ai-msg--ai .ai-msg-bubble h1 { font-size: 1.05rem; }
.ai-msg--ai .ai-msg-bubble h2 { font-size: 0.97rem; }
.ai-msg--ai .ai-msg-bubble h3 { font-size: 0.92rem; }
.ai-msg--ai .ai-msg-bubble ul,
.ai-msg--ai .ai-msg-bubble ol {
  padding-left: 1.4rem;
  margin: 0.5rem 0;
}
.ai-msg--ai .ai-msg-bubble li { margin-bottom: 0.25rem; }
.ai-msg--ai .ai-msg-bubble p { margin: 0.4rem 0; }
.ai-msg--ai .ai-msg-bubble p:first-child { margin-top: 0; }
.ai-msg--ai .ai-msg-bubble p:last-child { margin-bottom: 0; }

/* AI message actions */
.ai-msg-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0 0.25rem;
}
.ai-msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.ai-msg-action-btn:hover { background: var(--bg-secondary); color: var(--accent-cyan); }
.ai-msg-action-btn.copied { color: #059669; }
.ai-msg-action-btn.liked  { color: #059669; }
.ai-msg-action-btn.disliked { color: #dc2626; }
.ai-msg-action-btn svg { width: 13px; height: 13px; }
.ai-cta-btn { margin-left: 0.25rem; flex-shrink: 0; }

/* ── 5. Typing Indicator ─────────────────────────────────────── */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.9rem 1.1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 18px 18px 18px 4px;
  width: fit-content;
  align-self: flex-start;
  animation: ai-msg-in 0.28s ease forwards;
}
.ai-typing-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-right: 0.35rem; white-space: nowrap; }
.ai-typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: ai-dot-bounce 1.4s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.30s; }

/* ── 6. Input Bar ────────────────────────────────────────────── */
.ai-input-area {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  background: var(--bg-card);
}
.ai-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.65rem 0.6rem 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ai-input-bar:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.ai-textarea {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 0.92rem;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  padding: 0;
  overflow-y: auto;
}
.ai-textarea::placeholder { color: var(--text-muted); }
.ai-send-btn {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--accent-purple);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform 0.15s;
}
.ai-send-btn:hover { background: var(--accent-cyan); transform: scale(1.05); }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.ai-send-btn svg { width: 18px; height: 18px; }

/* Chat controls row */
.ai-chat-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.ai-chat-controls .btn-ghost {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  color: var(--text-muted);
}
.ai-chat-controls .btn-ghost:hover { color: #dc2626; }
.ai-char-count { font-size: 0.72rem; color: var(--text-muted); }
.ai-char-count.warn { color: #f59e0b; }
.ai-char-count.over { color: #dc2626; }

/* ── 7. Error message in chat ────────────────────────────────── */
.ai-msg--error .ai-msg-bubble {
  background: rgba(220,38,38,0.08);
  border-color: rgba(220,38,38,0.2);
  color: #991b1b;
}

/* ── 8. CTA Section ──────────────────────────────────────────── */
.ai-cta {
  background: var(--bg-secondary);
  text-align: center;
}
.ai-cta .section-title { margin-bottom: 0.75rem; }
.ai-cta .section-sub { margin-bottom: 2rem; }
.ai-cta-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── 9. Lead Modal ───────────────────────────────────────────── */
.ai-lead-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(30,27,75,0.55);
}
.ai-lead-modal.open { display: flex; }
.ai-lead-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 20px 60px rgba(30,27,75,0.2);
  animation: ai-msg-in 0.3s ease forwards;
}
.ai-lead-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.ai-lead-close:hover { background: var(--border-color); }
.ai-lead-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}
.ai-lead-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.ai-lead-form .form-group { margin-bottom: 1rem; }
.ai-lead-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.ai-lead-form input,
.ai-lead-form select,
.ai-lead-form textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ai-lead-form input:focus,
.ai-lead-form select:focus,
.ai-lead-form textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.ai-lead-form textarea { min-height: 80px; resize: vertical; }
.ai-lead-success {
  text-align: center;
  padding: 1.5rem 0;
  display: none;
}
.ai-lead-success-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.ai-lead-success h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.35rem; }
.ai-lead-success p { font-size: 0.875rem; color: var(--text-muted); }

/* ── 10. Float Button ────────────────────────────────────────── */
.ai-float-btn {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  width: 54px; height: 54px;
  background: var(--accent-purple);
  color: #ffffff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(30,27,75,0.25);
  z-index: 900;
  text-decoration: none;
  transition: background var(--transition), transform 0.2s;
}
.ai-float-btn:hover {
  background: var(--accent-cyan);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(124,58,237,0.3);
}
.ai-float-btn svg { width: 24px; height: 24px; }
.ai-float-btn .ai-float-tooltip {
  position: absolute;
  right: calc(100% + 0.6rem);
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-purple);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.ai-float-btn:hover .ai-float-tooltip { opacity: 1; }
/* Hide float button on the AI page itself */
body.ai-page .ai-float-btn { display: none; }

/* ── 11. Animations ──────────────────────────────────────────── */
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-7px); }
}
@keyframes ai-pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}
@keyframes ai-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── 12. Responsive ──────────────────────────────────────────── */
@media (min-width: 640px) {
  .ai-prompts-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .ai-prompts-grid { grid-template-columns: repeat(4, 1fr); }
  .ai-messages.has-messages { height: 460px; }
}

@media (max-width: 639px) {
  .ai-hero { min-height: 420px; }
  .ai-hero-inner { padding: 3rem 0 2.5rem; }
  .ai-hero-cta { flex-direction: column; }
  .ai-hero-cta .btn { width: 100%; justify-content: center; }
  .ai-prompts-grid { grid-template-columns: 1fr; }
  .ai-msg { max-width: 92%; }
  .ai-messages.has-messages { height: 40vh; min-height: 220px; }

  /* Tabs: scroll horizontally instead of wrapping */
  .ai-tabs { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .ai-tabs::-webkit-scrollbar { display: none; }
  .ai-tab { flex-shrink: 0; padding: 0.45rem 1rem; font-size: 0.82rem; }

  /* Chat container: softer radius + iOS safe-area bottom padding */
  .ai-chat-container { border-radius: 12px; }
  .ai-input-area { padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }

  /* Lead modal: tighter fit on small screens */
  .ai-lead-modal { padding: 0.75rem; }
  .ai-lead-box { padding: 1.4rem 1.2rem; }

  /* Float button: higher to avoid browser nav bar */
  .ai-float-btn { bottom: 5.5rem; right: 1rem; width: 48px; height: 48px; }

  .ai-cta-actions { flex-direction: column; align-items: center; }
}

/* ── Typewriter cursor ───────────────────────────────────────── */
.ai-cursor {
  display: inline-block;
  width: 2px;
  background: currentColor;
  margin-left: 2px;
  vertical-align: text-bottom;
  line-height: 1;
  animation: ai-blink 0.7s step-end infinite;
}

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