@import "tailwindcss";

@theme {
  --color-surface-0: #09090b;
  --color-surface-1: #18181b;
  --color-surface-2: #27272a;
  --color-surface-3: #3f3f46;
  --color-border: #27272a;
  --color-border-subtle: #1e1e22;
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-muted: rgba(99, 102, 241, 0.15);
  --text-pill: 0.6875rem;
  --text-pill--line-height: 1.2;
}

:root {
  color-scheme: dark;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Light mode colour overrides ────────────────────────────── */

[data-theme="light"] {
  color-scheme: light;

  /* Remap semantic surface tokens */
  --color-surface-0: #ffffff;
  --color-surface-1: #f4f4f5;
  --color-surface-2: #e4e4e7;
  --color-surface-3: #d4d4d8;
  --color-border: #e4e4e7;
  --color-border-subtle: #f0f0f2;
  --color-accent-muted: rgba(99, 102, 241, 0.10);

  /* Swap zinc scale: dark values become light equivalents.
     Tailwind v4 exposes these as --color-zinc-{step}. */
  --color-zinc-50: #18181b;
  --color-zinc-100: #27272a;
  --color-zinc-200: #3f3f46;
  --color-zinc-300: #52525b;
  --color-zinc-400: #71717a;
  --color-zinc-500: #71717a;
  --color-zinc-600: #a1a1aa;
  --color-zinc-700: #d4d4d8;
  --color-zinc-800: #e4e4e7;
  --color-zinc-900: #f4f4f5;
  --color-zinc-950: #ffffff;

  /* Keep black/white correct for light mode */
  --color-black: #000000;
  --color-white: #ffffff;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-surface-0);
}

#root {
  min-height: 100vh;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-surface-3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover, #52525b);
}

[data-theme="light"] {
  --scrollbar-hover: #a1a1aa;
}

/* Window drag regions for custom title bar */
.drag-region {
  -webkit-app-region: drag;
}

.no-drag {
  -webkit-app-region: no-drag;
}

/* Thinking dots animation */
@keyframes thinking-dot {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

.thinking-dot {
  animation: thinking-dot 1.4s ease-in-out infinite;
}

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

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

/* Auto-resize textarea helper */
.auto-resize-textarea {
  field-sizing: content;
  min-height: 44px;
  max-height: 200px;
}

/* ── Markdown composer (Lexical) ────────────────────────── */

.markdown-composer-content {
  position: relative;
}

.markdown-composer-editable {
  min-height: 52px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 48px 10px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #f4f4f5;
  outline: none;
  cursor: text;
}

.markdown-composer-editable[contenteditable="false"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.markdown-composer-placeholder {
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #52525b;
  pointer-events: none;
  user-select: none;
}

/* Paragraphs */
.mc-p {
  margin: 0;
}

/* Headings */
.mc-h1, .mc-h2, .mc-h3 {
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
}
.mc-h1 { font-size: 1.1em; }
.mc-h2 { font-size: 1.05em; }
.mc-h3 { font-size: 1em; }

/* Inline formatting */
.mc-bold { font-weight: 600; }
.mc-italic { font-style: italic; }
.mc-strikethrough { text-decoration: line-through; }
.mc-underline { text-decoration: underline; }
.mc-inline-code {
  background: rgba(63, 63, 70, 0.6);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}

/* Lists */
.mc-ul {
  list-style-type: disc;
  padding-left: 1.5em;
  margin: 2px 0;
}
.mc-ol {
  list-style-type: decimal;
  padding-left: 1.5em;
  margin: 2px 0;
}
.mc-li {
  margin: 1px 0;
}

/* Blockquote */
.mc-blockquote {
  border-left: 3px solid #3f3f46;
  padding-left: 0.75em;
  color: #a1a1aa;
  margin: 2px 0;
}

/* Code block */
.mc-code-block {
  display: block;
  background: rgba(24, 24, 27, 0.8);
  border: 1px solid #27272a;
  border-radius: 6px;
  padding: 26px 10px 6px 10px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
  white-space: pre-wrap;
  tab-size: 2;
  margin: 4px 0;
  overflow-x: auto;
}

/* Language selector overlays positioned outside Lexical-managed DOM */
.mc-code-overlays-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.mc-code-lang-overlay {
  position: absolute;
  pointer-events: auto;
  user-select: none;
}

.mc-code-lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(39, 39, 42, 0.9);
  border: 1px solid #3f3f46;
  border-radius: 4px;
  color: #a1a1aa;
  font-family: inherit;
  font-size: 10px;
  padding: 2px 18px 2px 6px;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 3px center;
  background-size: 10px;
}

.mc-code-lang-select:hover {
  border-color: #52525b;
  color: #d4d4d8;
}

.mc-code-lang-select:focus {
  border-color: rgba(99, 102, 241, 0.5);
}

/* Link */
.mc-link {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Syntax highlighting tokens (dark theme) */
.mc-tok-comment   { color: #6b7280; font-style: italic; }
.mc-tok-keyword   { color: #c084fc; }
.mc-tok-string    { color: #86efac; }
.mc-tok-number    { color: #fbbf24; }
.mc-tok-boolean   { color: #fbbf24; }
.mc-tok-constant  { color: #fbbf24; }
.mc-tok-function  { color: #93c5fd; }
.mc-tok-builtin   { color: #67e8f9; }
.mc-tok-operator  { color: #f9a8d4; }
.mc-tok-punctuation { color: #a1a1aa; }
.mc-tok-property  { color: #7dd3fc; }
.mc-tok-variable  { color: #fca5a5; }
.mc-tok-tag       { color: #f87171; }
.mc-tok-attr      { color: #fdba74; }
.mc-tok-atrule    { color: #c084fc; }
.mc-tok-selector  { color: #86efac; }
.mc-tok-regex     { color: #fcd34d; }
.mc-tok-symbol    { color: #fbbf24; }
.mc-tok-namespace { color: #f87171; opacity: 0.8; }
.mc-tok-deleted   { color: #fca5a5; text-decoration: line-through; }
.mc-tok-inserted  { color: #86efac; }

/* React Flow dark theme overrides */
.react-flow__node {
  font-family: inherit;
}

.react-flow__edge-path {
  stroke: #52525b;
  stroke-width: 1.5;
}

.react-flow__edge.selected .react-flow__edge-path {
  stroke: #818cf8;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(129, 140, 248, 0.4));
}

.react-flow__edge.animated .react-flow__edge-path {
  stroke-dasharray: 5;
  animation: reactflow-dash 0.5s linear infinite;
}

@keyframes reactflow-dash {
  to {
    stroke-dashoffset: -10;
  }
}

.react-flow__controls {
  border: 1px solid #27272a;
  background: #18181b;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.react-flow__controls button {
  background: #18181b;
  border-color: #27272a;
  color: #a1a1aa;
  width: 28px;
  height: 28px;
}

.react-flow__controls button:hover {
  background: #27272a;
  color: #e4e4e7;
}

.react-flow__minimap {
  background: #09090b;
  border: 1px solid #27272a;
  border-radius: 8px;
}

/* Sidebar running-session pulse animation */
@keyframes sidebar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-pulse {
  animation: sidebar-pulse 2s ease-in-out infinite;
}

/* Markdown prose styles for chat messages */
.markdown-content {
  line-height: 1.7;
  word-break: break-word;
}

.markdown-content > *:first-child {
  margin-top: 0;
}

.markdown-content > *:last-child {
  margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-weight: 600;
  color: var(--color-zinc-200);
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  line-height: 1.4;
}

.markdown-content h1 { font-size: 1.125rem; }
.markdown-content h2 { font-size: 1rem; }
.markdown-content h3 { font-size: 0.9375rem; }

.markdown-content p {
  margin-top: 0.625em;
  margin-bottom: 0.625em;
}

.markdown-content ul,
.markdown-content ol {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  padding-left: 1.5em;
}

.markdown-content ul { list-style-type: disc; }
.markdown-content ol { list-style-type: decimal; }

.markdown-content li {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.markdown-content li > p {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.markdown-content blockquote {
  border-left: 3px solid var(--color-surface-3);
  padding-left: 1em;
  color: var(--color-zinc-400);
  margin-top: 0.75em;
  margin-bottom: 0.75em;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75em;
  margin-bottom: 0.75em;
  font-size: 0.875rem;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.75em;
  text-align: left;
}

.markdown-content th {
  background: var(--color-surface-1);
  font-weight: 600;
  color: var(--color-zinc-300);
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5em 0;
}

.markdown-content strong {
  font-weight: 600;
  color: var(--color-zinc-200);
}

.markdown-content em {
  font-style: italic;
}

.markdown-content img {
  max-width: 100%;
  border-radius: 0.5rem;
}
