@import "tailwindcss";
@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));

@utility container {
  @media (width >= 1360px) {
    max-width: 1360px;
  }
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-inter);
  --font-mono: var(--font-geist-mono);
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --radius-4xl: calc(var(--radius) + 16px);
}

:root {
  --radius: 1rem;
  --background: oklch(0.97 0 0); /* #F4F6F8 approx */
  --foreground: oklch(0.2 0 0); /* #212B36 approx */
  --card: oklch(1 0 0); /* #FFFFFF */
  --card-foreground: oklch(0.2 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.2 0 0);
  --primary: oklch(0.55 0.2 250); /* #2065D1 */
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.2 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.55 0 0); /* #637381 */
  --accent: oklch(0.95 0.04 250 / 0.12); /* Light blue tint */
  --accent-foreground: oklch(0.55 0.2 250);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.55 0.2 250);
  --chart-1: oklch(0.55 0.2 250); /* Blue */
  --chart-2: oklch(0.7 0.15 80); /* Yellow/Orange */
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --sidebar: oklch(1 0 0);
  --sidebar-foreground: oklch(0.4 0 0);
  --sidebar-primary: oklch(0.55 0.2 250);
  --sidebar-primary-foreground: oklch(1 0 0);
  --sidebar-accent: oklch(0.95 0.04 250 / 0.12);
  --sidebar-accent-foreground: oklch(0.55 0.2 250);
  --sidebar-border: oklch(0.922 0 0 / 0.5);
  --sidebar-ring: oklch(0.55 0.2 250);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.55 0.2 250);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.55 0.2 250);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.55 0.2 250);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);
}

.store-surface {
  --background: oklch(1 0 0);
}

.dark .store-surface {
  --background: oklch(0.145 0 0);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  *,
  *::before,
  *::after {
    transition-property: background-color, color, border-color, fill, stroke,
      box-shadow;
    transition-duration: 0.3s;
    transition-timing-function: ease;
  }
  body {
    @apply bg-background text-foreground;
  }
}

/* High Contrast Mode */
.high-contrast {
  --background: oklch(1 0 0);
  --card: oklch(1 0 0);
  --foreground: oklch(0 0 0);
  --card-foreground: oklch(0 0 0);
  --muted-foreground: oklch(0.3 0 0);
  --border: oklch(0 0 0);
}
.high-contrast.dark {
  --background: oklch(0 0 0);
  --card: oklch(0.1 0 0);
  --foreground: oklch(1 0 0);
  --card-foreground: oklch(1 0 0);
  --muted-foreground: oklch(0.7 0 0);
  --border: oklch(1 0 0);
}

/* Settings Icon Animation */
@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.animate-spin-slow:hover svg {
  animation: spin-slow 2s linear infinite;
}

.scrollbar-hide {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Matches the dashboard sidebar's scrollbar (see SidebarContent in components/ui/sidebar.tsx). */
html {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--border) 50%, transparent) transparent;
}
html::-webkit-scrollbar {
  width: 0.375rem;
  height: 0.375rem;
}
html::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb {
  border-radius: 9999px;
  background-color: color-mix(in oklab, var(--border) 50%, transparent);
}
html::-webkit-scrollbar-thumb:hover {
  background-color: var(--border);
}

.rich-text-content {
  overflow-wrap: anywhere;
}

.rich-text-content :where(p, h1, h2, h3, h4, ul, ol, blockquote, figure, pre) {
  margin: 0;
}

.rich-text-content
  :where(p, h1, h2, h3, h4, ul, ol, blockquote, figure, pre, hr)
  + :where(p, h1, h2, h3, h4, ul, ol, blockquote, figure, pre, hr) {
  margin-top: 0.875rem;
}

.rich-text-content :where(p:empty:not(.is-editor-empty))::before {
  content: "\00a0";
}

.rich-text-content :where(h1, h2, h3, h4) {
  color: var(--foreground);
  font-weight: 650;
  line-height: 1.25;
}

.rich-text-content :where(h1) {
  font-size: 1.75rem;
  letter-spacing: 0;
}

.rich-text-content :where(h2) {
  font-size: 1.35rem;
  letter-spacing: 0;
}

.rich-text-content :where(h3, h4) {
  font-size: 1.1rem;
  letter-spacing: 0;
}

.rich-text-content :where(p, li) {
  line-height: 1.75;
}

.rich-text-content :where(strong) {
  color: var(--foreground);
  font-weight: 650;
}

.rich-text-content :where(ul, ol) {
  padding-inline-start: 1.5rem;
}

.rich-text-content :where(ul) {
  list-style-type: disc;
}

.rich-text-content :where(ol) {
  list-style-type: decimal;
}

.rich-text-content :where(li) {
  margin-top: 0.35rem;
  padding-inline-start: 0.25rem;
}

.rich-text-content :where(li)::marker {
  color: var(--foreground);
  font-weight: 600;
}

.rich-text-content :where(li > p) {
  margin: 0;
}

.rich-text-content :where(li > p + p) {
  margin-top: 0.35rem;
}

.rich-text-content :where(a) {
  color: var(--primary);
  text-decoration-line: underline;
  text-underline-offset: 3px;
}

.rich-text-content :where(blockquote) {
  border-inline-start: 3px solid var(--border);
  color: var(--muted-foreground);
  padding-inline-start: 1rem;
}

.rich-text-content :where(code) {
  background: var(--muted);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15rem 0.35rem;
}

.rich-text-content :where(pre) {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--foreground);
  overflow-x: auto;
  padding: 0.875rem 1rem;
}

.rich-text-content :where(pre code) {
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.rich-text-content :where(hr) {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: 1.25rem;
}

.rich-text-content :where(img, figure) {
  margin-block: 1.25rem;
}

/* ============================================
   Toast Notifications (Sonner)
   Minimal, Vercel/Linear-inspired design
   ============================================ */

[data-sonner-toaster] [data-sonner-toast] {
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-inline-start-width: 3px;
  border-radius: var(--radius-md);
  box-shadow:
    0 1px 3px 0 rgb(0 0 0 / 0.08),
    0 1px 2px -1px rgb(0 0 0 / 0.08);
  font-size: 0.875rem;
  line-height: 1.25rem;
  padding: 12px 16px;
}

/* Reset Sonner's built-in typed background colors */
[data-sonner-toaster] [data-sonner-toast][data-type="success"],
[data-sonner-toaster] [data-sonner-toast][data-type="error"],
[data-sonner-toaster] [data-sonner-toast][data-type="warning"],
[data-sonner-toaster] [data-sonner-toast][data-type="info"] {
  background: var(--popover);
  color: var(--popover-foreground);
  border-color: var(--border);
}

/* Colored inline-start border per variant (auto RTL via logical properties) */
[data-sonner-toaster] .toast-success {
  border-inline-start-color: oklch(0.72 0.19 155); /* emerald-500 */
}
[data-sonner-toaster] .toast-error {
  border-inline-start-color: oklch(0.64 0.25 25); /* red-500 */
}
[data-sonner-toaster] .toast-warning {
  border-inline-start-color: oklch(0.77 0.17 75); /* amber-500 */
}
[data-sonner-toaster] .toast-info {
  border-inline-start-color: oklch(0.62 0.21 255); /* blue-500 */
}
[data-sonner-toaster] .toast-loading {
  border-inline-start-color: var(--primary);
}

/* Description text */
[data-sonner-toaster] [data-sonner-toast] [data-description] {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

/* Action button (Undo, etc.) */
[data-sonner-toaster] [data-sonner-toast] [data-button] {
  background: transparent;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  transition: background-color 150ms;
}
[data-sonner-toaster] [data-sonner-toast] [data-button]:hover {
  background: var(--accent);
}

/* Close button */
[data-sonner-toaster] [data-sonner-toast] [data-close-button] {
  color: var(--muted-foreground);
  border-color: var(--border);
  background: var(--popover);
}
[data-sonner-toaster] [data-sonner-toast] [data-close-button]:hover {
  color: var(--foreground);
  background: var(--accent);
}
