/* ABOUTME: Global Tailwind CSS styles for seren-desktop. */
/* ABOUTME: Deep navy dark theme with teal-blue accent; paper-stone light theme on :root.light. */

@import "tailwindcss";

/* The appearance store toggles a `dark` or `light` class on the documentElement
   so Tailwind's `dark:` variant resolves correctly under either palette. The
   default palette below is the dark one; the light palette overrides on
   :root.light. */
@custom-variant dark (&:is(.dark *));

/* Base styles */
html {
  scrollbar-gutter: stable;
}

body {
  font-family:
    "General Sans", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

code {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* CSS Variables - Deep Navy Dark Theme */
:root {
  /* Base colors */
  --background: #0a0e17;
  --background-gradient-start: #111827;
  --background-gradient-mid: #0a0e17;
  --background-gradient-end: #060a12;
  --foreground: #e2e8f0;

  /* Surface depth hierarchy */
  --surface-0: #0f1623;
  --surface-1: #151d2e;
  --surface-2: #1c2640;
  --surface-3: #243049;

  /* Surface colors (mapped for compatibility) */
  --card: var(--surface-1);
  --card-foreground: var(--foreground);
  --popover: var(--surface-2);
  --popover-foreground: var(--foreground);

  /* Interactive colors — teal-blue primary */
  --primary: #38bdf8;
  --primary-foreground: #0a0e17;
  --primary-hover: #7dd3fc;
  --primary-muted: rgba(56, 189, 248, 0.12);
  --secondary: var(--surface-2);
  --secondary-foreground: #cbd5e1;
  --muted: var(--surface-1);
  --muted-foreground: #94a3b8;
  --accent: #38bdf8;
  --accent-foreground: #0a0e17;

  /* Semantic colors */
  --destructive: #f87171;
  --destructive-foreground: #ffffff;
  --success: #34d399;
  --warning: #fbbf24;

  /* Status colors */
  --status-running: #34d399;
  --status-waiting: #fbbf24;
  --status-error: #f87171;
  --status-idle: #7c8798;

  /* Border and input */
  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(148, 163, 184, 0.2);
  --border-subtle: rgba(148, 163, 184, 0.06);
  --border-medium: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.25);
  --input: var(--surface-2);
  --ring: #38bdf8;
  --input-focus-glow:
    0 0 0 3px rgba(56, 189, 248, 0.12), 0 0 16px rgba(56, 189, 248, 0.06);

  /* Sidebar specific */
  --sidebar: var(--surface-0);
  --sidebar-foreground: var(--foreground);
  --sidebar-border: var(--border);
  --sidebar-accent: var(--primary-muted);
  --sidebar-accent-foreground: var(--primary);

  /* Scrollbar */
  --scrollbar-track: var(--surface-0);
  --scrollbar-thumb: rgba(148, 163, 184, 0.15);
  --scrollbar-thumb-hover: rgba(148, 163, 184, 0.25);

  /* Radius */
  --radius: 0.5rem;

  /* Shadows for depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Glow effects */
  --glow-primary: 0 0 20px rgba(56, 189, 248, 0.15);
  --glow-primary-intense: 0 0 30px rgba(56, 189, 248, 0.25);

  /* Transitions */
  --transition-fast: 100ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout dimensions */
  --sidebar-width: 280px;
  --titlebar-height: 40px;
  --statusbar-height: 24px;

  /* Fonts */
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;

  /* Appearance: font sizes (set per-surface, components opt in via .chat-surface
     and .thread-list-surface so base behaviour is unchanged). */
  --chat-font-size: 0.9375rem;
  --thread-list-font-size: 0.8125rem;

  /* Appearance: density. Padding scales on the surfaces below. */
  --density-row-y: 0.5rem;
  --density-row-x: 0.75rem;
  --density-gap: 0.5rem;
  --density-chat-row-y: 1rem;
  --density-chat-row-x: 1.25rem;
  --density-chat-tool-row-y: 0.5rem;
  --density-chat-composer-y: 0.875rem;
  --density-chat-composer-x: 1rem;
  --density-chat-input-y: 0.75rem;
  --density-chat-gap: 0.5rem;
}

/* Paper-stone light theme. Deliberately warm-neutral (off-white background,
   slate text) with a slightly desaturated cyan accent so the same primary
   doesn't glow on a light surface. Twin of the :root block above; everything
   else inherits. */
:root.light {
  --background: #f4f1ea;
  --background-gradient-start: #fbf8f1;
  --background-gradient-mid: #f4f1ea;
  --background-gradient-end: #ece8df;
  --foreground: #1d2433;

  --surface-0: #fbf8f1;
  --surface-1: #f0ece2;
  --surface-2: #e3ddcf;
  --surface-3: #d4ccba;

  --card: var(--surface-1);
  --card-foreground: var(--foreground);
  --popover: var(--surface-0);
  --popover-foreground: var(--foreground);

  /* sky-700/sky-800 instead of sky-600/sky-700: sky-600 lands at 3.6:1 on
     the paper-stone background which fails WCAG AA for body text (links,
     button labels). Darkening the primary one stop fixes link contrast and
     primary-foreground-on-primary contrast in one move. */
  --primary: #0369a1;
  --primary-foreground: #fbf8f1;
  --primary-hover: #075985;
  --primary-muted: rgba(3, 105, 161, 0.1);
  --secondary: var(--surface-2);
  --secondary-foreground: #1d2433;
  --muted: var(--surface-1);
  --muted-foreground: #5b6577;
  --accent: #0369a1;
  --accent-foreground: #fbf8f1;

  --destructive: #be123c;
  --destructive-foreground: #fbf8f1;
  --success: #047857;
  --warning: #92400e;

  --status-running: #047857;
  --status-waiting: #92400e;
  --status-error: #be123c;
  --status-idle: #5b6577;

  --border: rgba(29, 36, 51, 0.12);
  --border-hover: rgba(29, 36, 51, 0.2);
  --border-subtle: rgba(29, 36, 51, 0.06);
  --border-medium: rgba(29, 36, 51, 0.16);
  --border-strong: rgba(29, 36, 51, 0.26);
  --input: var(--surface-0);
  --ring: #0369a1;
  --input-focus-glow:
    0 0 0 3px rgba(3, 105, 161, 0.14), 0 0 16px rgba(3, 105, 161, 0.08);

  --sidebar: var(--surface-1);
  --sidebar-foreground: var(--foreground);
  --sidebar-border: var(--border);
  --sidebar-accent: var(--primary-muted);
  --sidebar-accent-foreground: var(--primary);

  --scrollbar-track: var(--surface-1);
  --scrollbar-thumb: rgba(29, 36, 51, 0.18);
  --scrollbar-thumb-hover: rgba(29, 36, 51, 0.3);

  --shadow-sm: 0 1px 2px rgba(29, 36, 51, 0.08);
  --shadow-md: 0 4px 12px rgba(29, 36, 51, 0.12);
  --shadow-lg: 0 8px 32px rgba(29, 36, 51, 0.18);

  --glow-primary: 0 0 18px rgba(3, 105, 161, 0.18);
  --glow-primary-intense: 0 0 28px rgba(3, 105, 161, 0.28);
}

/* Tailwind theme configuration */
@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-success: var(--success);
  --color-warning: var(--warning);
  --color-border: var(--border);
  --color-border-subtle: var(--border-subtle);
  --color-border-hover: var(--border-hover);
  --color-border-medium: var(--border-medium);
  --color-border-strong: var(--border-strong);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-surface-0: var(--surface-0);
  --color-surface-1: var(--surface-1);
  --color-surface-2: var(--surface-2);
  --color-surface-3: var(--surface-3);
  --color-status-running: var(--status-running);
  --color-status-waiting: var(--status-waiting);
  --color-status-error: var(--status-error);
  --color-status-idle: var(--status-idle);
  --color-primary-hover: var(--primary-hover);
  --color-primary-muted: var(--primary-muted);
  --radius-sm: calc(var(--radius) - 2px);
  --radius-md: var(--radius);
  --radius-lg: calc(var(--radius) + 2px);
  --radius-xl: calc(var(--radius) + 4px);
}

@layer base {
  * {
    @apply border-border;
    box-sizing: border-box;
  }

  html,
  body,
  #root {
    @apply h-full w-full overflow-hidden m-0 p-0;
  }

  body {
    @apply bg-background text-foreground text-[13px] leading-normal;
    background-image: radial-gradient(
      circle at top,
      var(--background-gradient-start),
      var(--background-gradient-mid) 40%,
      var(--background-gradient-end) 100%
    );
  }

  button {
    @apply cursor-pointer;
  }

  /* Form elements - ensure proper dark mode styling */
  select,
  input,
  textarea {
    @apply bg-muted text-foreground;
  }

  select option {
    @apply bg-muted text-foreground;
  }
}

/* Refined status bar - subtle gradient instead of solid block */
footer.status-bar {
  background: linear-gradient(to right, var(--surface-1), var(--surface-0));
  border-top: 1px solid var(--border);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Monaco draws its scrollbars as plain DOM elements. Some Monaco builds
 * leak through a default red slider color when scrollbarSlider.* tokens
 * don't take. Pin the slider to our slate value so a horizontal overflow
 * never paints a thick red bar at the bottom of the editor pane. */
.monaco-scrollable-element > .scrollbar > .slider {
  background: var(--scrollbar-thumb) !important;
  border-radius: 3px;
}
.monaco-scrollable-element > .scrollbar > .slider:hover {
  background: var(--scrollbar-thumb-hover) !important;
}
.monaco-scrollable-element > .scrollbar > .slider.active {
  background: rgba(148, 163, 184, 0.35) !important;
}

/* Loading spinner animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  @apply w-8 h-8 rounded-full;
  border: 3px solid var(--secondary);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

/* Context menu animation */
@keyframes context-menu-appear {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Modal animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat streaming cursor blink */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Thinking dots bounce animation */
@keyframes bounce-dot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.thinking-dot {
  animation: bounce-dot 1.4s infinite ease-in-out;
}

.thinking-dot-1 {
  animation-delay: 0s;
}
.thinking-dot-2 {
  animation-delay: 0.2s;
}
.thinking-dot-3 {
  animation-delay: 0.4s;
}

/* Tool execution pulse */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Permission required indicator - pulsing orange dot */
@keyframes permission-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(251, 146, 60, 0.7);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(251, 146, 60, 0);
  }
}

.permission-indicator {
  @apply w-2 h-2 rounded-full shrink-0;
  background-color: #fb923c;
  animation: permission-pulse 1.5s ease-in-out infinite;
}

/* Updater progress bar shimmer */
@keyframes updater-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.updater-bar-downloading {
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #3b82f6);
  background-size: 200% 100%;
  animation: updater-shimmer 1.5s ease-in-out infinite;
}

.updater-bar-installing {
  background: linear-gradient(90deg, #818cf8, #a78bfa, #818cf8);
  background-size: 200% 100%;
  animation: updater-shimmer 1.5s ease-in-out infinite;
}

/* Live meeting-capture indicator on the titlebar meetings button. Green pulse so
   an active recording stays visible even when the meeting drawer is closed (#2335). */
@keyframes meeting-recording-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  }
  50% {
    box-shadow: 0 0 7px 2px rgba(52, 211, 153, 0.28);
  }
}

.meeting-recording-glow {
  animation: meeting-recording-pulse 1.8s ease-in-out infinite;
}

/* Slide-in from right (SlidePanel) */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Slide-in from top (approval dialogs) */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade-in with slight upward translate */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Voice recording pulse */
@keyframes voicePulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

@keyframes tabPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Active thread left-edge indicator */
@keyframes accentSlide {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

/* Voice auto-submit tooltip via ::after */
.voice-auto-submit-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted-foreground);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

.voice-auto-submit-toggle:hover::after {
  opacity: 1;
}

/* Markdown code block styles (render-markdown.ts injects these class names) */
.code-block-wrapper {
  @apply relative my-4 bg-surface-0 border border-surface-3 rounded-[10px] overflow-hidden shadow-[0_2px_8px_rgba(0,0,0,0.2)];
}

.code-block-header {
  @apply flex justify-between items-center px-3 py-2 bg-background border-b border-surface-2;
}

.code-block-lang {
  @apply text-[11px] font-semibold uppercase text-muted-foreground tracking-[0.5px];
}

.code-copy-btn {
  @apply flex items-center gap-1 px-2 py-1 bg-transparent border border-surface-3 rounded text-muted-foreground text-xs font-[inherit] cursor-pointer transition-all duration-150;
}

.code-copy-btn:hover {
  @apply bg-surface-2 border-status-idle text-foreground;
}

.code-copy-btn:active {
  @apply bg-surface-3;
}

.code-copy-btn.copied {
  @apply text-success border-success;
}

.code-copy-btn svg {
  @apply shrink-0;
}

.code-block-wrapper pre {
  @apply m-0 p-3 bg-transparent border-none rounded-none overflow-x-auto;
}

.code-block-wrapper pre code {
  @apply bg-transparent p-0 text-[13px] leading-relaxed;
}

.external-link {
  @apply text-primary no-underline cursor-pointer;
}

.external-link:hover {
  @apply underline;
}

/* Appearance: surface-scoped font sizes. Components opt in by adding the
   marker class to the outer wrapper; descendants inherit. */
.chat-surface {
  font-size: var(--chat-font-size);
}

.chat-surface .chat-message-content,
.chat-surface textarea {
  font-size: var(--chat-font-size);
}

.chat-surface .chat-message-row {
  padding: var(--density-chat-row-y) var(--density-chat-row-x);
}

.chat-surface .chat-tool-row {
  padding: var(--density-chat-tool-row-y) var(--density-chat-row-x);
}

.chat-surface .chat-composer-form {
  gap: var(--density-chat-gap);
  padding: calc(var(--density-chat-composer-y) * 0.45)
    var(--density-chat-composer-x) var(--density-chat-composer-y);
}

.chat-surface textarea {
  padding-top: var(--density-chat-input-y);
  padding-bottom: var(--density-chat-input-y);
}

.thread-list-surface {
  font-size: var(--thread-list-font-size);
}

.thread-list-surface .thread-list-row {
  gap: var(--density-gap);
  padding: var(--density-row-y) var(--density-row-x);
}

.thread-list-surface .thread-list-subrow {
  padding: calc(var(--density-row-y) * 0.75) var(--density-row-x);
  padding-left: calc(var(--density-row-x) + 1.75rem);
}

.thread-list-surface .thread-list-title {
  font-size: var(--thread-list-font-size);
}

.thread-list-surface .thread-list-meta {
  font-size: max(0.71875rem, calc(var(--thread-list-font-size) - 0.09375rem));
}

/* Appearance: density. The `density-*` class is set on documentElement by the
   appearance effect; surfaces opt in to spacing via the row vars. */
:root.density-compact {
  --density-row-y: 0.3125rem;
  --density-row-x: 0.625rem;
  --density-gap: 0.375rem;
  --density-chat-row-y: 0.625rem;
  --density-chat-row-x: 1rem;
  --density-chat-tool-row-y: 0.375rem;
  --density-chat-composer-y: 0.625rem;
  --density-chat-composer-x: 0.75rem;
  --density-chat-input-y: 0.5625rem;
  --density-chat-gap: 0.375rem;
}

:root.density-spacious {
  --density-row-y: 0.6875rem;
  --density-row-x: 0.875rem;
  --density-gap: 0.625rem;
  --density-chat-row-y: 1.25rem;
  --density-chat-row-x: 1.5rem;
  --density-chat-tool-row-y: 0.75rem;
  --density-chat-composer-y: 1.125rem;
  --density-chat-composer-x: 1.25rem;
  --density-chat-input-y: 0.9375rem;
  --density-chat-gap: 0.625rem;
}

/* Skill invocation chip rendered in chat transcripts when a user message
   begins with /<installed-skill-slug>. Theme-aware via the existing primary
   tokens. Click is handled by event delegation on the chat surface. */
.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.0625rem 0.4375rem 0.0625rem 0.375rem;
  margin: 0;
  background: var(--primary-muted);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 0.375rem;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.85em;
  line-height: 1.4;
  letter-spacing: 0.01em;
  cursor: pointer;
  vertical-align: baseline;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.skill-chip:hover,
.skill-chip:focus-visible {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  outline: none;
}

.skill-chip-icon {
  width: 0.875em;
  height: 0.875em;
  flex-shrink: 0;
}

.skill-chip-label {
  font-weight: 500;
}

.skill-chip-args {
  margin-left: 0.125rem;
  color: var(--muted-foreground);
  font-style: italic;
}
