/* =============================================
   AI Integrator — Custom Styles
   Dark Purple/Violet Theme with Glassmorphism
   ============================================= */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 35, 0.6);
  --bg-card-strong: rgba(25, 25, 45, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-strong: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;
  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;
  --gradient-primary: linear-gradient(135deg, #9333ea 0%, #7c3aed 50%, #6d28d9 100%);
  --gradient-accent: linear-gradient(135deg, #a855f7 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-text: linear-gradient(135deg, #c084fc 0%, #a78bfa 40%, #22d3ee 100%);
  --gradient-glow: linear-gradient(135deg, rgba(147, 51, 234, 0.4) 0%, rgba(124, 58, 237, 0.4) 100%);
  --shadow-purple: 0 0 30px rgba(147, 51, 234, 0.15);
  --shadow-glow: 0 0 60px rgba(147, 51, 234, 0.25);
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base Reset & Defaults ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Glassmorphism ---------- */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
}

.glass-strong {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-lg);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-glass-strong);
  box-shadow: var(--shadow-purple);
  transform: translateY(-2px);
}

/* ---------- Gradient Text ---------- */
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-alt {
  background: linear-gradient(135deg, #e879f9 0%, #a78bfa 50%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(147, 51, 234, 0.4);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-glass-strong);
  color: var(--text-primary);
  border: 1px solid var(--border-glass-strong);
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-glow {
  position: relative;
}

.btn-glow::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: var(--gradient-accent);
  z-index: -1;
  opacity: 0;
  filter: blur(12px);
  transition: opacity var(--transition-base);
}

.btn-glow:hover::after {
  opacity: 0.6;
}

/* ---------- Input Fields ---------- */
.input-field {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: all var(--transition-base);
  outline: none;
}

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

.input-field:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- Chat Bubbles ---------- */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.msg-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.55;
  animation: msgSlideIn 0.3s ease-out;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg-user {
  align-self: flex-end;
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 15px rgba(147, 51, 234, 0.3);
}

.msg-bot {
  align-self: flex-start;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

.msg-bot p {
  margin: 0;
}

.msg-bot p + p {
  margin-top: 8px;
}

.msg-bot ul, .msg-bot ol {
  margin: 6px 0;
  padding-left: 20px;
}

.msg-bot strong {
  color: var(--purple-400);
}

.msg-bot code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---------- Typing Indicator ---------- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  align-self: flex-start;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  animation: msgSlideIn 0.3s ease-out;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--purple-400);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ---------- Message Slide In ---------- */
@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Scroll Reveal Animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ---------- Fade In ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

/* ---------- Slide Up ---------- */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.5s ease-out forwards;
}

/* ---------- Float animation for blobs ---------- */
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

@keyframes floatReverse {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-25px, 25px) scale(0.95); }
  66% { transform: translate(25px, -15px) scale(1.05); }
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  pointer-events: none;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.5), transparent 70%);
  animation: float 15s ease-in-out infinite;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.4), transparent 70%);
  animation: floatReverse 18s ease-in-out infinite;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.3), transparent 70%);
  animation: float 20s ease-in-out infinite;
}

/* ---------- Pulse glow ---------- */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(147, 51, 234, 0.2); }
  50% { box-shadow: 0 0 40px rgba(147, 51, 234, 0.4); }
}

.pulse-glow {
  animation: pulseGlow 3s ease-in-out infinite;
}

/* ---------- Glow Border ---------- */
.glow-border {
  position: relative;
}

.glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-accent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.6;
  transition: opacity var(--transition-base);
}

.glow-border:hover::before {
  opacity: 1;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(147, 51, 234, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(147, 51, 234, 0.5);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(147, 51, 234, 0.3) transparent;
}

/* ---------- Paywall Overlay ---------- */
.paywall-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.5s ease-out;
}

.paywall-card {
  background: var(--bg-card-strong);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-glow);
  animation: slideUp 0.5s ease-out;
}

/* ---------- Modal Overlay ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease-out;
}

.modal-card {
  background: var(--bg-card-strong);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-glow);
  animation: slideUp 0.3s ease-out;
}

/* ---------- Status Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}

.badge-ready {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-scraping {
  background: rgba(234, 179, 8, 0.12);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.badge-error {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-ready .badge-dot { background: #4ade80; }
.badge-scraping .badge-dot { background: #facc15; animation: typingBounce 1s infinite; }
.badge-error .badge-dot { background: #f87171; }

/* ---------- Copy feedback ---------- */
.copy-feedback {
  position: relative;
}

.copy-feedback .copy-tooltip {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(34, 197, 94, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.copy-feedback.copied .copy-tooltip {
  opacity: 1;
}

/* ---------- Code block ---------- */
.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  color: #e2e8f0;
  overflow-x: auto;
  word-break: break-all;
  line-height: 1.6;
}

/* ---------- Loading Spinner ---------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Collapsible ---------- */
.collapsible-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: color var(--transition-fast);
  user-select: none;
}

.collapsible-header:hover {
  color: var(--text-primary);
}

.collapsible-header .chevron {
  transition: transform var(--transition-base);
  font-size: 0.7rem;
}

.collapsible-header.open .chevron {
  transform: rotate(90deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out;
}

.collapsible-body.open {
  max-height: 600px;
}

/* ---------- Widget / Embedded Mode ---------- */
body.embedded {
  background: transparent;
}

body.embedded .widget-header-hidden {
  display: none !important;
}

body.embedded .chat-wrapper {
  height: 100vh;
  border-radius: 0;
  border: none;
}

/* ---------- Tooltip ---------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  background: var(--bg-card-strong);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border-glass);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ---------- Error Alert ---------- */
.error-alert {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fca5a5;
  font-size: 0.88rem;
  animation: slideUp 0.3s ease-out;
}

.success-alert {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  color: #86efac;
  font-size: 0.88rem;
  animation: slideUp 0.3s ease-out;
}

/* ---------- Misc ---------- */
.no-select {
  user-select: none;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a {
  color: var(--purple-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--cyan-400);
}

/* ---------- Nav highlight ---------- */
.nav-link {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: 1px;
  transition: width var(--transition-base);
}

.nav-link:hover::after {
  width: 100%;
}

/* ---------- Media Queries ---------- */
@media (max-width: 768px) {
  .msg-bubble {
    max-width: 90%;
  }

  .blob {
    opacity: 0.15;
  }

  .paywall-card {
    padding: 28px 20px;
  }
}
