/* Catppuccin Mocha palette — same --ctp-* vars as Tauri app */
:root {
  --ctp-rosewater: #f5e0dc;
  --ctp-flamingo:  #f2cdcd;
  --ctp-pink:      #f5c2e7;
  --ctp-mauve:     #cba6f7;
  --ctp-red:       #f38ba8;
  --ctp-maroon:    #eba0ac;
  --ctp-peach:     #fab387;
  --ctp-yellow:    #f9e2af;
  --ctp-green:     #a6e3a1;
  --ctp-teal:      #94e2d5;
  --ctp-sky:       #89dceb;
  --ctp-sapphire:  #74c7ec;
  --ctp-blue:      #89b4fa;
  --ctp-lavender:  #b4befe;
  --ctp-text:      #cdd6f4;
  --ctp-subtext1:  #bac2de;
  --ctp-subtext0:  #a6adc8;
  --ctp-overlay2:  #9399b2;
  --ctp-overlay1:  #7f849c;
  --ctp-overlay0:  #6c7086;
  --ctp-surface2:  #585b70;
  --ctp-surface1:  #45475a;
  --ctp-surface0:  #313244;
  --ctp-base:      #1e1e2e;
  --ctp-mantle:    #181825;
  --ctp-crust:     #11111b;

  /* Typography */
  --ui-font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-font-size: 0.875rem;
  --term-font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --term-font-size: 0.8125rem;

  /* Layout */
  --sidebar-width: 2.75rem;
  --status-bar-height: 1.75rem;
  --tab-bar-height: 2rem;
  --header-height: 2.5rem;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ctp-base);
  color: var(--ctp-text);
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size);
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── App shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar / icon rail ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--ctp-mantle);
  border-right: 1px solid var(--ctp-surface0);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0;
  gap: 0.25rem;
}

.sidebar-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  color: var(--ctp-overlay1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.sidebar-icon:hover {
  background: var(--ctp-surface0);
  color: var(--ctp-text);
}

.sidebar-icon.active {
  background: var(--ctp-surface1);
  color: var(--ctp-mauve);
}

.sidebar-icon svg {
  width: 1rem;
  height: 1rem;
}

.sidebar-spacer {
  flex: 1;
}

/* ── Project grid (main workspace) ────────────────────────── */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--ctp-crust);
}

/* ── Project card ──────────────────────────────────────────── */
.project-card {
  background: var(--ctp-base);
  border: 1px solid var(--ctp-surface0);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Accent stripe on left edge */
.project-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent, var(--ctp-mauve));
  border-radius: 0.5rem 0 0 0.5rem;
}

.project-card {
  position: relative;
}

/* ── Project header ────────────────────────────────────────── */
.project-header {
  height: var(--header-height);
  background: var(--ctp-mantle);
  border-bottom: 1px solid var(--ctp-surface0);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.625rem 0 0.875rem;
  flex-shrink: 0;
}

.status-dot-wrap {
  flex-shrink: 0;
  width: 0.625rem;
  height: 0.625rem;
  position: relative;
}

/* wgpu placeholder — same dimensions as the dot, GPU surface goes here */
#wgpu-surface,
.wgpu-surface {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--dot-color, var(--ctp-overlay0));
}

/* CSS fallback pulsing dot (compositor-driven, ~0% CPU) */
.status-dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--dot-color, var(--ctp-overlay0));
}

.status-dot.running {
  --dot-color: var(--ctp-green);
  /* No CSS animation — JS timer toggles .blink-off class instead */
}

.status-dot.blink-off {
  opacity: 0.3;
}

.status-dot.idle {
  --dot-color: var(--ctp-overlay1);
}

.status-dot.stalled {
  --dot-color: var(--ctp-peach);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.85); }
}

.project-name {
  font-weight: 600;
  color: var(--ctp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.project-cwd {
  font-size: 0.75rem;
  color: var(--ctp-subtext0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  max-width: 10rem;
  flex-shrink: 0;
}

/* ── Tab bar ───────────────────────────────────────────────── */
.tab-bar {
  height: var(--tab-bar-height);
  background: var(--ctp-mantle);
  border-bottom: 1px solid var(--ctp-surface0);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  padding: 0 0.25rem;
  gap: 0.125rem;
}

.tab-btn {
  padding: 0 0.75rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ctp-subtext0);
  font-family: var(--ui-font-family);
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--ctp-text);
}

.tab-btn.active {
  color: var(--ctp-text);
  border-bottom-color: var(--accent, var(--ctp-mauve));
}

/* ── Tab content area ──────────────────────────────────────── */
.tab-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.625rem;
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* scrollbar */
.tab-pane::-webkit-scrollbar { width: 0.375rem; }
.tab-pane::-webkit-scrollbar-track { background: transparent; }
.tab-pane::-webkit-scrollbar-thumb { background: var(--ctp-surface1); border-radius: 0.25rem; }

/* ── Agent messages ────────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.msg-role {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ctp-overlay1);
}

.msg-role.user  { color: var(--ctp-blue); }
.msg-role.assistant { color: var(--ctp-mauve); }
.msg-role.tool  { color: var(--ctp-peach); }

.msg-body {
  background: var(--ctp-surface0);
  border-radius: 0.3125rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ctp-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-body.tool-call {
  background: color-mix(in srgb, var(--ctp-peach) 8%, var(--ctp-surface0));
  border-left: 2px solid var(--ctp-peach);
  font-family: var(--term-font-family);
  font-size: 0.75rem;
}

.msg-body.tool-result {
  background: color-mix(in srgb, var(--ctp-teal) 6%, var(--ctp-surface0));
  border-left: 2px solid var(--ctp-teal);
  font-family: var(--term-font-family);
  font-size: 0.75rem;
  color: var(--ctp-subtext1);
}

/* ── Docs / Files placeholder ──────────────────────────────── */
.placeholder-pane {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ctp-overlay0);
  font-size: 0.8125rem;
  font-style: italic;
}

/* ── Status bar ────────────────────────────────────────────── */
.status-bar {
  height: var(--status-bar-height);
  background: var(--ctp-crust);
  border-top: 1px solid var(--ctp-surface0);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.75rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--ctp-subtext0);
}

.status-segment {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.status-dot-sm {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-sm.green  { background: var(--ctp-green); }
.status-dot-sm.gray   { background: var(--ctp-overlay0); }
.status-dot-sm.orange { background: var(--ctp-peach); }

.status-bar-spacer { flex: 1; }

.status-value {
  color: var(--ctp-text);
  font-weight: 500;
}

/* ── Terminal section ─────────────────────────────────────── */
.agent-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.terminal-section {
  height: 12rem;
  min-height: 8rem;
  border-top: 1px solid var(--ctp-surface0);
  flex-shrink: 0;
}
