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

/* AI Chat Markdown Styles */
.ai-markdown {
  line-height: 1.6;
  color: #0f172a;
  font-size: 0.875rem;
}
.ai-markdown p {
  margin: 0.5rem 0;
}
.ai-markdown h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
  color: #1e293b;
}
.ai-markdown h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0.875rem 0 0.5rem;
  color: #1e293b;
}
.ai-markdown h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.75rem 0 0.375rem;
  color: #334155;
}
.ai-markdown ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}
.ai-markdown ol {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}
.ai-markdown li {
  margin: 0.25rem 0;
}
.ai-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.75rem;
}
.ai-markdown th {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.5rem;
  text-align: left;
  font-weight: 600;
}
.ai-markdown td {
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.5rem;
}
.ai-markdown pre {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}
.ai-markdown code {
  background: #f1f5f9;
  border-radius: 0.25rem;
  padding: 0.125rem 0.25rem;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}
.ai-markdown pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.ai-markdown blockquote {
  border-left: 3px solid #cbd5e1;
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  color: #64748b;
  font-style: italic;
}
.ai-markdown strong {
  font-weight: 700;
}
.ai-markdown em {
  font-style: italic;
}
.ai-markdown a {
  color: #2563eb;
  text-decoration: underline;
}
.ai-markdown a:hover {
  color: #1d4ed8;
}
.ai-markdown hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 1rem 0;
}
.ai-markdown img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

:root {
  /* Design tokens from prototype */
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1d4ed8;
  --color-secondary: #64748b;
  --color-accent: #d946ef;
  --color-danger: #dc2626;
  --color-warning: #f59e0b;
  --color-success: #16a34a;
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #f1f5f9;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --touch-target: 44px;
}

.dark {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: #334155;
  --color-border: #334155;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-light: #64748b;
}

@layer base {
  * {
    @apply border-secondary-200;
  }
  body {
    @apply bg-secondary-50 text-secondary-900 font-sans antialiased;
    margin: 0;
    min-height: 100vh;
  }
  #root {
    min-height: 100vh;
  }
}

@layer components {
  .btn-touch {
    @apply min-h-touch min-w-touch;
  }
  .focus-ring {
    @apply focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2;
  }
  .sr-only-focusable:not(:focus):not(:focus-within) {
    @apply sr-only;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* TipTap editor placeholder */
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #94a3b8;
  pointer-events: none;
  height: 0;
}

/* TipTap editor base styles */
.ProseMirror {
  outline: none;
}
.ProseMirror ul,
.ProseMirror ol {
  padding-left: 1.5rem;
}
.ProseMirror ul {
  list-style-type: disc;
}
.ProseMirror ol {
  list-style-type: decimal;
}
.ProseMirror blockquote {
  padding-left: 1rem;
  border-left: 3px solid #e2e8f0;
  margin-left: 0;
  color: #64748b;
  font-style: italic;
}
.ProseMirror pre {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  font-family: monospace;
  font-size: 0.875rem;
  overflow-x: auto;
}
.ProseMirror code {
  background: #f1f5f9;
  border-radius: 0.25rem;
  padding: 0.125rem 0.25rem;
  font-size: 0.875em;
}
.ProseMirror pre code {
  background: none;
  padding: 0;
}
.ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
}
.ProseMirror a {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
}
.ProseMirror h1 { font-size: 1.5em; font-weight: 700; margin: 0.5em 0; }
.ProseMirror h2 { font-size: 1.25em; font-weight: 700; margin: 0.5em 0; }
.ProseMirror h3 { font-size: 1.1em; font-weight: 600; margin: 0.5em 0; }
