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

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

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --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);
  --radius: 0.75rem;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
  --app-canvas: oklch(0.97 0.01 255);
  --app-sidebar: oklch(0.94 0.012 255);
  --app-drawer: oklch(0.945 0.01 255);
  --app-chrome: oklch(0.96 0.008 255 / 95%);
  --app-terminal: oklch(0.925 0.012 255);
  --app-menu: oklch(0.97 0.006 255 / 96%);
  --app-surface: oklch(0.995 0.004 255 / 82%);
  --app-surface-muted: oklch(0.985 0.006 255 / 68%);
  --app-surface-hover: oklch(0.91 0.014 255 / 62%);
  --app-surface-active: oklch(0.88 0.018 255 / 78%);
  --app-border: oklch(0.8 0.01 255 / 45%);
  --app-border-strong: oklch(0.72 0.012 255 / 60%);
  --app-foreground: oklch(0.24 0.015 255);
  --app-muted: oklch(0.47 0.014 255);
  --app-subtle: oklch(0.6 0.012 255);
  --app-code: oklch(0.93 0.01 255 / 90%);
  --app-code-panel: oklch(0.992 0.004 255 / 96%);
  --app-code-panel-muted: oklch(0.976 0.006 255 / 88%);
  --app-code-border: oklch(0.78 0.012 255 / 24%);
  --app-code-border-strong: oklch(0.72 0.014 255 / 36%);
  --app-code-button: oklch(0.968 0.008 255 / 92%);
  --app-overlay: oklch(0.97 0.01 255 / 78%);
  --app-success: oklch(0.62 0.17 155);
  --app-warning: oklch(0.74 0.15 82);
  --app-danger: oklch(0.58 0.22 26);
  --app-info: oklch(0.63 0.13 240);
}

.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.922 0 0);
  --primary-foreground: oklch(0.205 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);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --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: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --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);
  --app-canvas: oklch(0.145 0.006 260);
  --app-sidebar: oklch(0.185 0.008 260);
  --app-drawer: oklch(0.17 0.007 260);
  --app-chrome: oklch(0.16 0.006 260 / 95%);
  --app-terminal: oklch(0.11 0.006 260);
  --app-menu: oklch(0.2 0.008 260 / 96%);
  --app-surface: oklch(0.23 0.008 260 / 86%);
  --app-surface-muted: oklch(0.2 0.008 260 / 66%);
  --app-surface-hover: oklch(0.29 0.01 260 / 78%);
  --app-surface-active: oklch(0.33 0.01 260 / 84%);
  --app-border: oklch(1 0 0 / 10%);
  --app-border-strong: oklch(1 0 0 / 16%);
  --app-foreground: oklch(0.97 0 0);
  --app-muted: oklch(0.78 0.006 260);
  --app-subtle: oklch(0.63 0.006 260);
  --app-code: oklch(0.16 0.006 260 / 88%);
  --app-code-panel: oklch(0.18 0.007 260 / 96%);
  --app-code-panel-muted: oklch(0.205 0.008 260 / 92%);
  --app-code-border: oklch(1 0 0 / 9%);
  --app-code-border-strong: oklch(1 0 0 / 16%);
  --app-code-button: oklch(0.235 0.009 260 / 82%);
  --app-overlay: oklch(0.145 0.006 260 / 78%);
  --app-success: oklch(0.76 0.18 155);
  --app-warning: oklch(0.82 0.14 85);
  --app-danger: oklch(0.7 0.19 24);
  --app-info: oklch(0.74 0.13 240);
}

@theme inline {
  --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);
  --color-app-canvas: var(--app-canvas);
  --color-app-sidebar: var(--app-sidebar);
  --color-app-drawer: var(--app-drawer);
  --color-app-chrome: var(--app-chrome);
  --color-app-terminal: var(--app-terminal);
  --color-app-menu: var(--app-menu);
  --color-app-surface: var(--app-surface);
  --color-app-surface-muted: var(--app-surface-muted);
  --color-app-surface-hover: var(--app-surface-hover);
  --color-app-surface-active: var(--app-surface-active);
  --color-app-border: var(--app-border);
  --color-app-border-strong: var(--app-border-strong);
  --color-app-foreground: var(--app-foreground);
  --color-app-muted: var(--app-muted);
  --color-app-subtle: var(--app-subtle);
  --color-app-code: var(--app-code);
  --color-app-overlay: var(--app-overlay);
  --color-app-success: var(--app-success);
  --color-app-warning: var(--app-warning);
  --color-app-danger: var(--app-danger);
  --color-app-info: var(--app-info);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  *:hover {
    scrollbar-color: oklch(0.5 0 0 / 35%) transparent;
  }

  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

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

  ::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
  }

  *:hover::-webkit-scrollbar-thumb {
    background: oklch(0.5 0 0 / 35%);
  }

  *:hover::-webkit-scrollbar-thumb:hover {
    background: oklch(0.5 0 0 / 55%);
  }

  html,
  body,
  #root {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    @apply bg-background text-foreground antialiased;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  #root {
    @apply min-h-screen;
  }

  button:not(:disabled),
  [role="button"]:not(:disabled),
  a[href] {
    cursor: pointer;
  }

  button:disabled,
  [role="button"][aria-disabled="true"] {
    cursor: default;
  }
}

@layer components {
  [data-streamdown="code-block"] {
    position: relative;
    gap: 0 !important;
    margin-block: 1rem !important;
    overflow: hidden;
    border-radius: calc(var(--radius) + 0.1rem) !important;
    border-color: var(--app-code-border) !important;
    background: var(--app-code-panel) !important;
    contain-intrinsic-size: auto !important;
    content-visibility: visible !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  [data-streamdown="code-block-header"] {
    display: flex !important;
    align-items: center;
    min-height: 0 !important;
    padding: 0.875rem 1rem 0.125rem !important;
    color: color-mix(in oklab, var(--app-subtle) 90%, transparent) !important;
    font-size: 12px !important;
    letter-spacing: 0.18em;
    text-transform: lowercase;
  }

  [data-streamdown="code-block-header"] span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  [data-streamdown="code-block"] > div:nth-child(2) {
    position: absolute !important;
    top: 0.65rem;
    right: 0.75rem;
    z-index: 2;
    margin: 0 !important;
    display: block !important;
    height: 0 !important;
    width: auto !important;
    overflow: visible !important;
    pointer-events: none !important;
  }

  [data-streamdown="code-block"] [data-streamdown="code-block-actions"] {
    border: 0 !important;
    background: transparent !important;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    padding: 0 !important;
    opacity: 0.34;
    transform: none;
    transition: opacity 180ms ease;
    pointer-events: auto !important;
  }

  [data-streamdown="code-block"]:hover [data-streamdown="code-block-actions"],
  [data-streamdown="code-block"]:focus-within [data-streamdown="code-block-actions"] {
    opacity: 1;
  }

  [data-streamdown="code-block"] [data-streamdown="code-block-actions"] button {
    height: 1.75rem;
    width: 1.75rem;
    border: 0 !important;
    border-radius: 0.5rem;
    color: color-mix(in oklab, var(--app-subtle) 88%, transparent);
    transition: background-color 180ms ease, color 180ms ease;
  }

  [data-streamdown="code-block"] [data-streamdown="code-block-actions"] button:hover,
  [data-streamdown="code-block"] [data-streamdown="code-block-actions"] button:focus-visible {
    background: var(--app-code-button);
    color: var(--app-foreground);
  }

  [data-streamdown="code-block-body"] {
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
  }

  [data-streamdown="code-block-body"] pre {
    margin: 0 !important;
    background: transparent !important;
    padding: 0 1rem 0.875rem !important;
    font-size: 13px;
    line-height: 1.72;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word;
  }

  [data-streamdown="code-block-body"] pre code {
    white-space: inherit !important;
    overflow-wrap: inherit !important;
    word-break: inherit;
  }

  [data-streamdown="code-block-body"] pre code > span::before {
    width: 1.75rem !important;
    margin-right: 0.875rem !important;
    color: color-mix(in oklab, var(--app-subtle) 58%, transparent) !important;
    font-size: 11px !important;
  }

  .collapsible-content-accordion {
    overflow: hidden;
  }

  .collapsible-content-accordion[data-state="open"] {
    animation: collapsible-content-open 1000ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .collapsible-content-accordion[data-state="closed"] {
    animation: collapsible-content-close 1000ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .file-editor-codemirror .cm-editor {
    height: 100%;
    width: 100%;
  }

  .file-editor-codemirror .cm-scroller {
    min-height: 0;
    overflow: auto;
  }

  .file-editor-codemirror .cm-content {
    min-height: 100%;
  }
}

:root {
  --file-type-icon-filter: grayscale(1) brightness(0.42);
  --file-type-icon-opacity: 0.84;
  --file-type-icon-folder-opacity: 0.9;
  --file-type-icon-muted-opacity: 0.42;
}

.dark {
  --file-type-icon-filter: grayscale(1) brightness(0) invert(0.98) contrast(1.04);
  --file-type-icon-opacity: 0.94;
  --file-type-icon-folder-opacity: 1;
  --file-type-icon-muted-opacity: 0.58;
}

/* ── File type icons: monochrome + theme-adaptive ───────────────── */
.file-type-icon {
  filter: var(--file-type-icon-filter);
  opacity: var(--file-type-icon-opacity);
}
.file-type-icon--folder {
  opacity: var(--file-type-icon-folder-opacity);
}
.file-type-icon--muted {
  opacity: var(--file-type-icon-muted-opacity);
}

@keyframes collapsible-content-open {
  from {
    height: 0;
    opacity: 0.72;
  }
  to {
    height: var(--radix-collapsible-content-height);
    opacity: 1;
  }
}

@keyframes collapsible-content-close {
  from {
    height: var(--radix-collapsible-content-height);
    opacity: 1;
  }
  to {
    height: 0;
    opacity: 0.72;
  }
}
