@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

/* ─────────────────────────────────────────
   DESIGN TOKENS
───────────────────────────────────────── */
:root {
  /* Brand colors */
  --violet:        #6E22B8;
  --violet-light:  #8B3FD9;
  --violet-dark:   #531A8A;
  --violet-glow:   rgba(110, 34, 184, 0.18);
  --blue:          #286DED;
  --blue-light:    #4D8EF5;
  --gold:          #D4AF37;
  --gold-light:    #E8CB6A;

  /* Semantic - light mode defaults */
  --bg:            #F7F8FB;
  --bg-secondary:  #EEEEF6;
  --surface:       #FFFFFF;
  --surface-raised:#FFFFFF;
  --border:        rgba(110, 34, 184, 0.12);
  --text-primary:  #1A1B2E;
  --text-secondary:#4A4B6A;
  --text-muted:    #8A8BAA;

  /* Typography */
  --font-primary:  'Nunito', sans-serif;
  --font-header:   'Poppins', sans-serif;

  /* Spacing scale */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   40px;
  --space-2xl:  64px;

  /* Radius */
  --radius-sm:  8px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;
  --radius-full:9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(110, 34, 184, 0.08);
  --shadow-md:  0 4px 24px rgba(110, 34, 184, 0.12);
  --shadow-lg:  0 8px 48px rgba(110, 34, 184, 0.18);
  --shadow-glow:0 0 32px rgba(110, 34, 184, 0.25);

  /* Transitions */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms var(--ease);
  --transition-slow: 400ms var(--ease);
}

/* ─────────────────────────────────────────
   DARK MODE
───────────────────────────────────────── */
[data-theme="dark"] {
  --bg:            #1A1B2E;
  --bg-secondary:  #12131F;
  --surface:       #22243A;
  --surface-raised:#2C2E48;
  --border:        rgba(110, 34, 184, 0.25);
  --text-primary:  #F0F0FA;
  --text-secondary:#A0A0C8;
  --text-muted:    #606080;

  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow:0 0 48px rgba(110, 34, 184, 0.35);
}

/* ─────────────────────────────────────────
   RESET
───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
  -webkit-font-smoothing: antialiased;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  font-family: var(--font-primary);
  border: none;
  background: none;
}

input, textarea {
  font-family: var(--font-primary);
  font-size: 1rem;
  outline: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ─────────────────────────────────────────
   TYPOGRAPHY
───────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-header);
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 4vw, 2rem);   font-weight: 600; }
h3 { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 600; }
h4 { font-size: 1rem;                         font-weight: 600; }

p  { color: var(--text-secondary); line-height: 1.7; }

.text-muted    { color: var(--text-muted);     font-size: 0.875rem; }
.text-accent   { color: var(--violet); }
.text-gold     { color: var(--gold); }
.text-small    { font-size: 0.8125rem; }

/* ─────────────────────────────────────────
   IONE LOGO / WORDMARK
───────────────────────────────────────── */
.ione-wordmark {
  font-family: var(--font-header);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--violet) 0%, var(--blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ione-wordmark.large {
  font-size: 3rem;
}

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet) 0%, var(--blue) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

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

.btn-ghost {
  background: transparent;
  color: var(--violet);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: var(--violet-glow);
  border-color: var(--violet);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  color: var(--violet);
  background: var(--violet-glow);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─────────────────────────────────────────
   INPUTS
───────────────────────────────────────── */
.input {
  width: 100%;
  padding: 12px var(--space-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

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

/* ─────────────────────────────────────────
   CARDS
───────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-raised {
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

/* ─────────────────────────────────────────
   INSIGHT CARD — shared base
───────────────────────────────────────── */
.insight-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-slow);
}

.insight-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet), var(--blue), var(--gold));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.insight-card:hover {
  box-shadow: var(--shadow-glow);
}

.insight-headline {
  font-family: var(--font-header);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: var(--space-md);
}

.insight-body {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: var(--space-lg);
}

.insight-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.insight-source {
  color: var(--violet);
  font-weight: 500;
}

/* ─────────────────────────────────────────
   PULSE — hunting indicator
───────────────────────────────────────── */
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--violet);
  position: relative;
  display: inline-block;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--violet);
  opacity: 0.3;
  animation: pulse-ring 1.8s var(--ease) infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.9); opacity: 0.4; }
  60%  { transform: scale(1.8); opacity: 0;   }
  100% { transform: scale(0.9); opacity: 0;   }
}

/* ─────────────────────────────────────────
   DIVIDER
───────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}

/* ─────────────────────────────────────────
   NAV / TOP BAR — shared
───────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
}

[data-theme="dark"] .topbar {
  background: rgba(26, 27, 46, 0.88);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ─────────────────────────────────────────
   CHAT / CONVERSATION THREAD
───────────────────────────────────────── */
.thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.thread-message {
  display: flex;
  gap: var(--space-sm);
  animation: fadeUp 0.3s var(--ease) both;
}

.thread-message.user {
  flex-direction: row-reverse;
}

.thread-bubble {
  max-width: 78%;
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.thread-message.ione .thread-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.thread-message.user .thread-bubble {
  background: linear-gradient(135deg, var(--violet), var(--blue));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.thread-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  font-family: var(--font-header);
}

/* ─────────────────────────────────────────
   INPUT ROW — chat
───────────────────────────────────────── */
.chat-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
  padding: var(--space-md);
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.chat-input-row textarea {
  flex: 1;
  padding: 10px var(--space-md);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-row textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

.chat-input-row textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--violet), var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

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

/* ─────────────────────────────────────────
   LOADING / SKELETON
───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--border) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Typing dots */
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

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

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1;   }
}

/* ─────────────────────────────────────────
   THEME TOGGLE
───────────────────────────────────────── */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-size: 1.1rem;
}

.theme-toggle:hover {
  background: var(--violet-glow);
  color: var(--violet);
  border-color: var(--violet);
}

/* ─────────────────────────────────────────
   BADGE / TAG
───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-violet {
  background: var(--violet-glow);
  color: var(--violet);
}

.badge-gold {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold);
}

/* ─────────────────────────────────────────
   TOAST NOTIFICATION
───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-raised);
  color: var(--text-primary);
  padding: 10px var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  transition: all var(--transition-slow);
  z-index: 999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─────────────────────────────────────────
   UTILITY
───────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm       { gap: var(--space-sm); }
.gap-md       { gap: var(--space-md); }
.w-full       { width: 100%; }
.text-center  { text-align: center; }

/* ─────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.animate-fadeIn  { animation: fadeIn  0.4s var(--ease) both; }
.animate-fadeUp  { animation: fadeUp  0.4s var(--ease) both; }
.animate-scaleIn { animation: scaleIn 0.4s var(--ease) both; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }

/* ─────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--violet); }

/* ─────────────────────────────────────────
   RESPONSIVE — mobile first
───────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --space-lg: 20px;
    --space-xl: 28px;
  }

  .insight-card {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
  }

  .thread-bubble {
    max-width: 88%;
  }
}
