@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
}

html {
  color-scheme: dark;
}

body {
  background: theme('colors.rp-bg');
  color: theme('colors.rp-text');
  line-height: 1.65;
}

/* ── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: theme('colors.rp-border');
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: theme('colors.rp-muted');
}

/* ── Tab bar (Notion-style) ───────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 0;
}
.tab-btn {
  position: relative;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-sm);
  color: theme('colors.rp-faint');
  transition: color 0.15s;
  cursor: pointer;
  background: none;
  border: none;
}
.tab-btn:hover {
  color: theme('colors.rp-muted');
}
.tab-btn.active {
  color: theme('colors.rp-text');
  font-weight: 500;
}
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0.75rem;
  right: 0.75rem;
  height: 2px;
  background: theme('colors.rp-accent');
  border-radius: 1px;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn-accent {
  @apply inline-flex items-center gap-2 px-4 py-2 rounded-md text-r-sm font-medium;
  @apply bg-rp-accent text-white transition-colors hover:bg-rp-accent-hover;
}
.btn-ghost {
  @apply inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-r-sm;
  @apply text-rp-muted transition-colors hover:bg-rp-hover hover:text-rp-text;
}

/* ── Tool call card ───────────────────────────────────────── */

.tool-card {
  @apply border border-rp-border/40 rounded-lg overflow-hidden my-1;
  transition: border-color 0.2s;
}
.tool-card.active {
  @apply border-rp-border/70;
}
.tool-card-header {
  @apply w-full flex items-center gap-2 px-3 py-2 text-left transition-colors;
  @apply hover:bg-rp-surface/50;
}
.tool-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
}
.tool-card-body.expanded {
  max-height: 400px;
  overflow-y: auto;
}

/* Agent tool card with nested sub-agent tools */
.agent-tool-card {
  @apply border-rp-border/50;
}
.agent-tool-card .tool-card {
  @apply bg-rp-surface-alt/50;
}

/* ── Sidebar ──────────────────────────────────────────────── */

/* Mobile sidebar */
.sidebar-overlay {
  @apply fixed inset-0 bg-black/40 z-40;
}
.sidebar-panel {
  @apply fixed top-0 left-0 bottom-0 z-50;
}

/* ── Message animations ──────────────────────────────────── */

.message-enter {
  opacity: 0;
  animation: fade-in 0.15s ease forwards;
}
@keyframes fade-in {
  to { opacity: 1; }
}

/* ── Typing dots ─────────────────────────────────────────── */

.typing-dots span {
  @apply inline-block;
  opacity: 0.4;
}
.typing-dots span:nth-child(1) { opacity: 0.8; }
.typing-dots span:nth-child(2) { opacity: 0.6; }

/* ── Notion-style prose (shared base) ───────────────────── */

.notion-prose {
  color: rgba(255, 255, 255, 0.81);
  font-size: 1rem;
  line-height: 1.7;
  letter-spacing: -0.003em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Paragraphs — Notion has clear separation between blocks */
.notion-prose p {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
  min-height: 1em;
}
.notion-prose p + p {
  margin-top: 0.75em;
}

/* Headings — Notion: bold, tight letter-spacing, generous top margin */
.notion-prose h1 {
  font-size: 1.875em;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.2;
  margin-top: 2em;
  margin-bottom: 0.25em;
  color: rgba(255, 255, 255, 0.9);
}
.notion-prose h2 {
  font-size: 1.5em;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.3;
  margin-top: 1.75em;
  margin-bottom: 0.25em;
  color: rgba(255, 255, 255, 0.9);
}
.notion-prose h3 {
  font-size: 1.25em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin-top: 1.5em;
  margin-bottom: 0.125em;
  color: rgba(255, 255, 255, 0.9);
}
.notion-prose h1:first-child,
.notion-prose h2:first-child,
.notion-prose h3:first-child {
  margin-top: 0;
}

/* Lists — Notion: disc → circle → square for nesting, generous indent */
.notion-prose ul, .notion-prose ol {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
  padding-left: 1.6em;
}
.notion-prose ul { list-style-type: disc; }
.notion-prose ul ul { list-style-type: circle; }
.notion-prose ul ul ul { list-style-type: square; }
.notion-prose ol { list-style-type: decimal; }
.notion-prose ol ol { list-style-type: lower-alpha; }
.notion-prose li {
  padding: 0.2em 0;
  overflow-wrap: anywhere;
}
.notion-prose li > p {
  margin: 0;
}
.notion-prose li > ul, .notion-prose li > ol {
  margin-top: 0;
  margin-bottom: 0;
}

/* Links — Notion: subtle underline, inherit color */
.notion-prose a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.25);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s;
}
.notion-prose a:hover {
  text-decoration-color: rgba(255, 255, 255, 0.6);
}

/* Bold / italic — Notion makes bold very prominent */
.notion-prose strong {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}
.notion-prose em { font-style: italic; }

/* Inline code — Notion: red tint on dark bg */
.notion-prose code:not(pre code) {
  background: rgba(135, 131, 120, 0.15);
  border-radius: 3px;
  padding: 0.2em 0.4em;
  font-family: "SFMono-Regular", Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;
  font-size: 0.85em;
  color: theme('colors.rp-error');
}

/* Code blocks — Notion: flat bg, no border */
.notion-prose pre {
  background: rgba(135, 131, 120, 0.15);
  border-radius: 4px;
  overflow-x: auto;
  padding: 2em 1.25em;
  margin: 0.5em 0;
  font-size: 0.85em;
  line-height: 1.6;
  tab-size: 2;
}
.notion-prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

/* Blockquote — Notion: thick left border, no bg */
.notion-prose blockquote {
  border-left: 3px solid rgba(255, 255, 255, 0.2);
  padding-left: 1em;
  margin: 0.5em 0;
  font-style: normal;
  color: inherit;
}
.notion-prose blockquote p { margin: 0; }

/* Horizontal rule */
.notion-prose hr {
  border: none;
  margin: 1.5em 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

/* Tables — Notion: simple grid lines */
.notion-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.9375em;
}
.notion-prose th {
  text-align: left;
  font-weight: 600;
  padding: 0.5em 0.75em;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(135, 131, 120, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875em;
}
.notion-prose td {
  padding: 0.5em 0.75em;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Images */
.notion-prose img {
  border-radius: 4px;
  margin: 0.5em 0;
  max-width: 100%;
}

/* Task list checkboxes (GFM) */
.notion-prose input[type="checkbox"] {
  margin-right: 0.5em;
  accent-color: theme('colors.rp-accent');
}

/* ── Assistant message (inherits notion-prose) ──────────── */
.assistant-message { /* applied alongside notion-prose */ }

/* ── Wiki content (inherits notion-prose) ───────────────── */
.wiki-content { /* applied alongside notion-prose */ }
