@import '@fontsource/geist/300.css';
@import '@fontsource/geist/400.css';
@import '@fontsource/geist/500.css';
@import '@fontsource/geist/600.css';
@import '@fontsource/geist/700.css';

@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@plugin "@tailwindcss/typography";

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

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

:root {
  --radius: 0.625rem;

  /* #f1eaf1 @ 0.93 - Light Pinkish-White Canvas */
  --background: oklch(0.937 0.008 328.5);
  /* #040404 - Almost Black Text */
  --foreground: oklch(0.145 0 0);
  
  --card: oklch(0.945 0.012 328.5);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(0.945 0.012 328.5);
  --popover-foreground: oklch(0.145 0 0);
  
  /* #fbc881 - Golden Yellow Accent */
  --primary: oklch(0.838 0.117 76.8);
  --primary-foreground: oklch(0.145 0 0);
  
  /* #8a8ea9 - Slate Blue/Gray */
  --secondary: oklch(0.627 0.041 274.5);
  --secondary-foreground: oklch(0.945 0.012 328.5);
  
  /* #c8c3cd - Light Gray/Purple */
  --muted: oklch(0.811 0.014 300.2);
  --muted-foreground: oklch(0.627 0.041 274.5);
  
  --accent: oklch(0.811 0.014 300.2);
  --accent-foreground: oklch(0.145 0 0);
  
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  
  --border: oklch(0.811 0.014 300.2);
  --input: oklch(0.811 0.014 300.2);
  --ring: oklch(0.838 0.117 76.8);
  
  /* Kept your original chart colors */
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --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 uses the custom palette */
  --sidebar: oklch(0.945 0.012 328.5);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.838 0.117 76.8);
  --sidebar-primary-foreground: oklch(0.145 0 0);
  --sidebar-accent: oklch(0.811 0.014 300.2);
  --sidebar-accent-foreground: oklch(0.145 0 0);
  --sidebar-border: oklch(0.811 0.014 300.2);
  --sidebar-ring: oklch(0.838 0.117 76.8);
}

.dark {
  /* #0c0c0c - Deepest black for the main canvas */
  --background: oklch(0.15 0 0);
  /* #fbfbfb - Crisp white for primary text */
  --foreground: oklch(0.985 0 0);
  
  /* Cards use the main background but are defined by borders */
  --card: oklch(0.15 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.15 0 0);
  --popover-foreground: oklch(0.985 0 0);
  
  /* #fbfbfb - Primary actions (like the active white circle menu item) */
  --primary: oklch(0.985 0 0);
  /* #0c0c0c - Dark text/icons inside primary buttons */
  --primary-foreground: oklch(0.15 0 0);
  
  /* #323232 - Dark gray for secondary surfaces and button backgrounds */
  --secondary: oklch(0.335 0 0);
  /* #fbfbfb - White text on secondary surfaces */
  --secondary-foreground: oklch(0.985 0 0);
  
  /* #323232 - Dark gray for muted backgrounds */
  --muted: oklch(0.335 0 0);
  /* #77797b - Mid gray for muted/secondary text (like "ELEVATE YOUR...") */
  --muted-foreground: oklch(0.555 0 0);
  
  /* #323232 - Hover states */
  --accent: oklch(0.335 0 0);
  --accent-foreground: oklch(0.985 0 0);
  
  --destructive: oklch(0.704 0.191 22.216); /* Kept original dark red */
  --destructive-foreground: oklch(0.985 0 0);
  
  /* #323232 - Distinct dark gray borders for the cards/panels */
  --border: oklch(0.335 0 0);
  --input: oklch(0.335 0 0);
  /* #bab7ba - Lighter gray for focus rings to stand out against dark borders */
  --ring: oklch(0.765 0 0);
  
  /* Kept your original chart colors */
  --chart-1: oklch(0.488 0.243 264.376);
  --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 mapped to the new sleek dark palette */
  --sidebar: oklch(0.15 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.985 0 0);
  --sidebar-primary-foreground: oklch(0.15 0 0);
  --sidebar-accent: oklch(0.335 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(0.335 0 0);
  --sidebar-ring: oklch(0.765 0 0);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  html {
    background-color: var(--background);
  }
  body {
    @apply text-foreground;
    position: relative;
    background-color: transparent;
  }
  body::before,
  body::after {
    content: '';
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
  }
  /* Ellipse 4 — golden, top-left */
  body::before {
    left: -24.08%;
    right: 98.54%;
    top: -6.56%;
    bottom: 12.85%;
    background: rgba(245, 192, 110, 0.3);
    filter: blur(175px);
    transform: matrix(0.99, 0.15, -0.14, 0.99, 0, 0);
  }
  /* Ellipse 6 — slate, top-right */
  body::after {
    left: 80.04%;
    right: -12.11%;
    top: -14.9%;
    bottom: -33.88%;
    background: rgba(128, 135, 162, 0.3);
    filter: blur(150px);
    transform: matrix(-0.97, -0.24, 0.25, -0.97, 0, 0);
  }
}

.dark html {
  background: var(--background);
}
.dark body {
  background: var(--background);
}
.dark body::before,
.dark body::after {
  display: none;
}

body {
  font-family: 'Geist', 'Inter', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
  margin: 0;
  overflow: hidden; /* Electron: no OS scrollbars */
}

#root {
  height: 100vh;
  width: 100vw;
  display: flex;
  overflow: hidden;
}

/* ---- Glass Surface (ReactBits-style) ---- */
/*
 * Gradient border via padding-box/border-box background split —
 * most reliable technique in Chromium/Electron; no pseudo-element mask needed.
 */
.glass-surface {
  border: 1px solid transparent;
  background:
    /* glass fill — clips to padding-box (inside the border) */
    rgba(255, 255, 255, 0.55) padding-box,
    /* gradient border — clips to border-box (the 1px border strip) */
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.90) 0%,
      rgba(200, 195, 205, 0.40) 40%,
      rgba(200, 195, 205, 0.20) 100%
    ) border-box;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow:
    0 4px 48px rgba(0, 0, 0, 0.10),
    0 1px 2px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.80);
}

.dark .glass-surface {
  background:
    rgba(255, 255, 255, 0.05) padding-box,
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.04) 40%,
      rgba(255, 255, 255, 0.08) 100%
    ) border-box;
  box-shadow:
    0 4px 48px rgba(0, 0, 0, 0.50),
    0 1px 2px rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* Subtle variant — same gradient border, much more transparent fill */
.glass-surface-subtle {
  border: 1px solid transparent;
  background:
    rgba(255, 255, 255, 0.20) padding-box,
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.70) 0%,
      rgba(200, 195, 205, 0.25) 40%,
      rgba(200, 195, 205, 0.10) 100%
    ) border-box;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.60);
}

.dark .glass-surface-subtle {
  background:
    rgba(255, 255, 255, 0.03) padding-box,
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.12) 0%,
      rgba(255, 255, 255, 0.02) 40%,
      rgba(255, 255, 255, 0.05) 100%
    ) border-box;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* Native scrollbar — matches shadcn ScrollBar style */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted-foreground);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Crepe editor layout */
.milkdown-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.milkdown-container .milkdown {
  flex: 1;
  min-height: 0;
  --crepe-color-background: var(--background);
  --crepe-font-default: 'Geist', 'Inter', system-ui, sans-serif;
  --crepe-font-title: 'Geist', 'Inter', system-ui, sans-serif;
}

/* Override Crepe's default 60px 120px padding for panel use.
   Left padding >=72px to leave room for the block handle (plus + drag buttons). */
.milkdown-container .milkdown .ProseMirror {
  @apply pr-6 pl-18 py-0;
  flex: 1;
  overflow-y: auto;
}

/* Dark theme: scope nord-dark variables under .dark class */
.dark .milkdown {
  --crepe-color-on-background: #f8f9ff;
  --crepe-color-surface: #111418;
  --crepe-color-surface-low: #191c20;
  --crepe-color-on-surface: #e1e2e8;
  --crepe-color-on-surface-variant: #c3c6cf;
  --crepe-color-outline: #8d9199;
  --crepe-color-primary: #a1c9fd;
  --crepe-color-secondary: #3c4858;
  --crepe-color-on-secondary: #d7e3f8;
  --crepe-color-inverse: #e1e2e8;
  --crepe-color-on-inverse: #2e3135;
  --crepe-color-inline-code: #ffb4ab;
  --crepe-color-error: #ffb4ab;
  --crepe-color-hover: #1d2024;
  --crepe-color-selected: #32353a;
  --crepe-color-inline-area: #111418;
  --crepe-shadow-1: 0px 1px 2px 0px rgba(255, 255, 255, 0.3), 0px 1px 3px 1px rgba(255, 255, 255, 0.15);
  --crepe-shadow-2: 0px 1px 2px 0px rgba(255, 255, 255, 0.3), 0px 2px 6px 2px rgba(255, 255, 255, 0.15);
}
