@import "tailwindcss";

@theme {
  --color-bg: var(--bg);
  --color-bg-panel: var(--bg-panel);
  --color-bg-hover: var(--bg-hover);
  --color-bg-selected: var(--bg-selected);
  --color-border: var(--border);
  --color-text: var(--text);
  --color-text-muted: var(--text-muted);
  --color-text-dim: var(--text-dim);
  --color-accent: var(--accent);
  --color-accent-hover: var(--accent-hover);
  --color-user-bg: var(--user-bg);
  --color-assistant-bg: var(--assistant-bg);
  --color-tool-bg: var(--tool-bg);
  --color-bg-subtle: var(--bg-subtle);
  --font-mono-font: var(--font-mono);
}

:root {
  --bg: #ffffff;
  --bg-panel: #f5f5f5;
  --bg-hover: #eeeeee;
  --bg-selected: #e8e8e8;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --user-bg: #eff6ff;
  --assistant-bg: #ffffff;
  --tool-bg: #f9fafb;
  --bg-subtle: rgba(0,0,0,0.03);
}

html.dark {
  --bg: #1a1a1a;
  --bg-panel: #242424;
  --bg-hover: #2e2e2e;
  --bg-selected: #383838;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --user-bg: #1e293b;
  --assistant-bg: #1a1a1a;
  --tool-bg: #1f2937;
  --bg-subtle: rgba(255,255,255,0.04);
}

/* Theme toggle: circular wipe via View Transitions API.
   Disable the UA cross-fade; the actual clip-path animation is driven by
   Element.animate() in hooks/useTheme.ts after transition.ready resolves. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 2;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

:root {
  --font-mono: var(--font-noto-mono), 'JetBrains Mono', 'Fira Code', 'Consolas', ui-monospace, 'PingFang SC', 'Microsoft YaHei', monospace;
}

pre, code {
  font-family: var(--font-mono);
}

/* react-markdown output styles */
.markdown-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}
.markdown-body p { margin: 0 0 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text);
}
.markdown-body h1 { font-size: 1.15em; }
.markdown-body h2 { font-size: 1.05em; }
.markdown-body h3 { font-size: 0.95em; }
.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
  margin: 4px 0 8px;
  list-style-position: outside;
}
.markdown-body li { margin: 2px 0; }
.markdown-body ul > li { list-style-type: disc; }
.markdown-body ol > li { list-style-type: decimal; }
.markdown-body li > p { margin: 0; }
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-body blockquote {
  border-left: 3px solid var(--border);
  margin: 4px 0;
  padding: 2px 10px;
  color: var(--text-muted);
}
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
}
.markdown-body th { background: var(--bg-panel); font-weight: 600; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.markdown-body .katex-display {
  margin: 0.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.markdown-body .katex {
  font-size: 1.05em;
}
.markdown-user-message p {
  white-space: pre-wrap;
}

.mermaid-block {
  padding: 12px;
  overflow-x: auto;
  background: var(--bg);
}
.mermaid-block svg {
  display: block;
  max-width: none;
}
.mermaid-block-loading {
  min-height: 120px;
}
.mermaid-block-error {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* File viewer markdown preview — larger headings */
.markdown-file-preview h1 { font-size: 1.8em; }
.markdown-file-preview h2 { font-size: 1.4em; }
.markdown-file-preview h3 { font-size: 1.15em; }
.markdown-file-preview p { margin: 0 0 12px; }
.markdown-file-preview pre {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 12px 0;
}
.markdown-file-preview code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-panel);
  padding: 1px 5px;
  border-radius: 3px;
}
.markdown-file-preview pre code {
  background: none;
  padding: 0;
}

/* syntax highlighter line numbers */
.markdown-body span.linenumber,
span.linenumber {
  color: var(--text-dim) !important;
  font-style: normal !important;
}

@keyframes drop-zone-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes drop-icon-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}

@keyframes drop-ring-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.06); }
}

@keyframes drop-ripple {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes saved-pop {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  40%  { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.25); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@keyframes saved-check-draw {
  from { stroke-dashoffset: 18; opacity: 0; }
  to   { stroke-dashoffset: 0;  opacity: 1; }
}

/* Desktop sidebar: animate width */
@media (min-width: 641px) {
  .sidebar-overlay-backdrop {
    display: none !important;
  }
  .sidebar-container {
    position: relative;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
  }
  .sidebar-container.sidebar-open {
    width: 260px;
    min-width: 260px;
  }
  .sidebar-container.sidebar-closed {
    width: 0;
    min-width: 0;
    border-right: none !important;
  }
  /* keep inner content at fixed width so it doesn't reflow during animation */
  .sidebar-container > * {
    width: 260px;
    min-width: 260px;
  }
}


/* Right panel: animate width */
@media (min-width: 641px) {
  .right-panel-container {
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    flex-shrink: 0;
  }
  .right-panel-container.right-panel-open {
    width: 42%;
    min-width: 300px;
  }
  .right-panel-container.right-panel-closed {
    width: 0;
    min-width: 0;
    border-left: none !important;
  }
  /* keep inner content at fixed width so it doesn't reflow during animation */
  .right-panel-container > * {
    width: 42vw;
    min-width: 300px;
  }
}

/* Mobile sidebar: slide in/out as overlay */
@media (max-width: 640px) {
  .chat-stats-center {
    display: none !important;
  }
  .sidebar-container {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }
  .sidebar-container.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar-container.sidebar-closed {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .right-panel-container {
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    flex-shrink: 0;
  }
  .right-panel-container.right-panel-open {
    width: 100%;
    min-width: 0;
  }
  .right-panel-container.right-panel-closed {
    width: 0 !important;
    min-width: 0 !important;
    border-left: none !important;
    display: none !important;
  }
}
