/* ===========================================================
   Aruken AI CHAT — Custom styles (complements Tailwind CDN)
   Premium UI: glassmorphism, gradients, smooth animations.
   =========================================================== */

:root {
  /* Monochrome (black & white) palette — accents flip with the theme:
     dark accents on light mode, light accents on dark mode. */
  --brand-1: #18181b;   /* near-black */
  --brand-2: #3f3f46;   /* dark gray  */
  --brand-3: #71717a;   /* mid gray   */
  --accent: #18181b;            /* icon / accent color (light mode) */
  --accent-soft: rgba(0,0,0,.06);
  --radius: 16px;
}
.dark {
  --brand-1: #fafafa;
  --brand-2: #d4d4d8;
  --brand-3: #a1a1aa;
  --accent: #e4e4e7;            /* icon / accent color (dark mode) */
  --accent-soft: rgba(255,255,255,.08);
}

* { -webkit-tap-highlight-color: transparent; }

/* ---------- Icons (Lucide) ---------- */
.lucide, svg.lucide {
  stroke-width: 2;
  vertical-align: middle;
  flex-shrink: 0;
}
/* Placeholder before lucide swaps it for an <svg> (prevents layout jump) */
i[data-lucide] { display: inline-block; width: 1.15em; height: 1.15em; }
/* Default size when no explicit width/height utility is provided */
svg.lucide:not([class*="w-"]):not([width]) { width: 1.15em; height: 1.15em; }
.icon-btn { display: inline-grid; place-items: center; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Background (refined monochrome) ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(125% 90% at 50% -20%, #ffffff 0%, #eef0f4 48%, #e6e8ee 100%);
}
.dark .aurora {
  background: radial-gradient(125% 90% at 50% -20%, #17171d 0%, #0c0c11 52%, #070709 100%);
}
/* One soft, static ambient glow for depth — no muddy gray blobs. */
.aurora::before {
  content: '';
  position: absolute;
  width: 72vmax;
  height: 72vmax;
  border-radius: 50%;
  top: -28vmax;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.045), transparent 60%);
  filter: blur(50px);
}
.dark .aurora::before {
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.05), transparent 60%);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(6vmax, 4vmax) scale(1.15); }
}

/* ---------- Glass panels ---------- */
.glass {
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(17, 17, 17, 0.06);
}
.dark .glass {
  background: rgba(22, 22, 27, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gradient-text {
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn-gradient {
  /* Sleek black button (white content) in both themes. */
  background: linear-gradient(135deg, #27272a, #09090b);
  color: #fff;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.dark .btn-gradient {
  background: linear-gradient(135deg, #3f3f46, #18181b);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.btn-gradient:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.18); }
.btn-gradient:active:not(:disabled) { transform: translateY(0); }
.btn-gradient:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Scrollbars ---------- */
.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }
.scroll-thin::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 140, 0.35);
  border-radius: 99px;
}
.scroll-thin::-webkit-scrollbar-thumb:hover { background: rgba(120, 120, 140, 0.6); }

/* ---------- Entrance animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.anim-fade-up { animation: fadeUp .45s cubic-bezier(.2,.7,.2,1) both; }
.anim-fade-in { animation: fadeIn .4s ease both; }
.anim-pop { animation: pop .3s cubic-bezier(.2,.8,.2,1) both; }

/* Message bubble entrance */
.msg-enter { animation: fadeUp .35s cubic-bezier(.2,.7,.2,1) both; }

/* ---------- Typing / thinking indicator ---------- */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .5;
  animation: blink 1.2s infinite both;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Streaming caret */
.stream-caret::after {
  content: '▋';
  margin-left: 1px;
  animation: caret 1s steps(1) infinite;
  color: var(--brand-2);
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------- Loading skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, rgba(140,140,160,.12) 25%, rgba(140,140,160,.22) 37%, rgba(140,140,160,.12) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Markdown rendering inside AI bubbles ---------- */
.prose-chat { line-height: 1.7; word-wrap: break-word; }
.prose-chat p { margin: 0 0 .85rem; }
.prose-chat p:last-child { margin-bottom: 0; }
.prose-chat h1, .prose-chat h2, .prose-chat h3 { font-weight: 700; margin: 1.2rem 0 .6rem; line-height: 1.3; }
.prose-chat h1 { font-size: 1.4rem; }
.prose-chat h2 { font-size: 1.2rem; }
.prose-chat h3 { font-size: 1.05rem; }
.prose-chat ul, .prose-chat ol { margin: .4rem 0 .9rem; padding-left: 1.4rem; }
.prose-chat li { margin: .25rem 0; }
.prose-chat a { color: var(--brand-1); text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.prose-chat blockquote {
  border-left: 3px solid var(--brand-2);
  padding-left: .9rem; margin: .8rem 0; opacity: .9; font-style: italic;
}
.prose-chat table { border-collapse: collapse; margin: .8rem 0; width: 100%; font-size: .9em; }
.prose-chat th, .prose-chat td { border: 1px solid rgba(120,120,140,.3); padding: .45rem .7rem; text-align: left; }
.prose-chat th { background: rgba(120,120,140,.12); font-weight: 600; }
.prose-chat hr { border: none; border-top: 1px solid rgba(120,120,140,.25); margin: 1rem 0; }

/* Inline code */
.prose-chat :not(pre) > code {
  background: rgba(120,120,140,.16);
  padding: .15em .4em; border-radius: 6px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88em;
}

/* Code block wrapper — sleek pure black & white */
.code-block {
  margin: .8rem 0; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 30px -14px rgba(0,0,0,.7);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem .8rem; font-size: .72rem; letter-spacing: .06em;
  background: #000; color: #fff; text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.code-head .lang { font-weight: 700; color: #fff; }
.code-head button {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 6px; font-size: .7rem;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.16);
  transition: background .15s, transform .1s;
}
.code-head button:hover { background: rgba(255,255,255,.24); }
.code-head button:active { transform: scale(.95); }
.prose-chat pre {
  margin: 0; padding: 1rem; overflow-x: auto;
  background: #0a0a0a !important;
  color: #e8e8e8 !important;          /* keep code light on the dark block in BOTH themes */
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .85rem; line-height: 1.6;
}
.prose-chat pre code { background: transparent !important; padding: 0; color: #e8e8e8; }

/* Monochrome syntax theme — overrides the CDN highlight.js colors with grays */
.prose-chat .hljs { color: #e8e8e8; background: transparent; }
.prose-chat .hljs-keyword, .prose-chat .hljs-selector-tag, .prose-chat .hljs-built_in,
.prose-chat .hljs-name, .prose-chat .hljs-tag, .prose-chat .hljs-section,
.prose-chat .hljs-doctag, .prose-chat .hljs-strong { color: #ffffff; font-weight: 600; }
.prose-chat .hljs-string, .prose-chat .hljs-attr, .prose-chat .hljs-attribute,
.prose-chat .hljs-symbol, .prose-chat .hljs-template-tag, .prose-chat .hljs-quote,
.prose-chat .hljs-meta-string, .prose-chat .hljs-regexp { color: #c2c2c2; }
.prose-chat .hljs-comment, .prose-chat .hljs-meta { color: #6b6b6b; font-style: italic; }
.prose-chat .hljs-number, .prose-chat .hljs-literal, .prose-chat .hljs-variable,
.prose-chat .hljs-title, .prose-chat .hljs-type, .prose-chat .hljs-class .hljs-title,
.prose-chat .hljs-function .hljs-title, .prose-chat .hljs-params { color: #d6d6d6; }
.prose-chat .hljs-bullet, .prose-chat .hljs-link, .prose-chat .hljs-selector-id,
.prose-chat .hljs-selector-class, .prose-chat .hljs-property { color: #aaaaaa; }
.prose-chat .hljs-emphasis { font-style: italic; }

/* ============================================================
   Monochrome accent overrides — remap every colored utility
   class used in the app to the theme accent (black / white).
   ============================================================ */
.text-indigo-600, .text-indigo-500, .text-indigo-400, .text-indigo-300,
.text-violet-400, .text-violet-500, .text-amber-400, .text-amber-500,
.text-sky-400, .text-sky-500, .text-emerald-400, .text-emerald-500,
.text-rose-400, .text-rose-500, .text-rose-600,
.dark .dark\:text-indigo-300,
.hover\:text-indigo-500:hover, .hover\:text-rose-600:hover { color: var(--accent) !important; }

.bg-indigo-500, .bg-violet-500, .bg-pink-500, .bg-emerald-500,
.bg-sky-500, .bg-amber-500, .bg-rose-500, .bg-teal-500 { background-color: var(--accent) !important; }

.hover\:bg-rose-500\/20:hover, .hover\:bg-rose-500\/15:hover,
.hover\:bg-rose-500\/10:hover, .hover\:bg-amber-500\/15:hover { background-color: var(--accent-soft) !important; }

.fill-amber-400 { fill: var(--accent) !important; }
.border-amber-500, .border-indigo-400 { border-color: var(--accent) !important; }
.accent-indigo-500 { accent-color: var(--accent) !important; }

/* ---------- Form controls ---------- */
.field {
  width: 100%;
  padding: .7rem .9rem;
  border-radius: 12px;
  border: 1px solid rgba(120,120,140,.28);
  background: rgba(255,255,255,.6);
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.dark .field { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: #e5e7eb; }
.field:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(255,255,255,.85);
}
.dark .field:focus { background: rgba(255,255,255,.08); }

/* Native <select> dropdown — keep options readable in both themes */
select.field { color-scheme: light; }
.dark select.field { color-scheme: dark; }
select.field option { background-color: #ffffff; color: #111827; }
.dark select.field option { background-color: #1b1b20; color: #f1f1f1; }

/* Range slider */
input[type="range"] { -webkit-appearance: none; height: 6px; border-radius: 99px; background: rgba(120,120,140,.3); outline: none; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-1);
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4); transition: transform .1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 99px;
  background: rgba(120,120,140,.4); transition: .25s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + .slider { background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Sidebar item hover */
.chat-item { transition: background .15s, transform .1s; }
.chat-item:hover { background: rgba(120,120,140,.12); }
.chat-item.active { background: var(--accent-soft); border-left: 2px solid var(--brand-1); }

/* Toast */
.toast {
  animation: fadeUp .3s ease both;
}

/* Drag overlay */
.drag-over { outline: 3px dashed var(--brand-2); outline-offset: -10px; background: rgba(99,102,241,.06); }

/* Hide scrollbar but keep scroll for textarea autosize */
textarea { resize: none; }

/* Utility */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
