/* ============================================
   AIT — Agent Issue Tracker
   Cool neutrals + soft blue accent
   ============================================ */

:root {
  /* Light theme — slate-tinted */
  --bg: oklch(0.99 0.004 250);
  --bg-elevated: oklch(1 0 0);
  --bg-subtle: oklch(0.975 0.006 250);
  --bg-hover: oklch(0.955 0.008 250);
  --bg-active: oklch(0.93 0.012 250);

  --border: oklch(0.92 0.008 250);
  --border-strong: oklch(0.86 0.012 250);

  --fg: oklch(0.22 0.015 250);
  --fg-muted: oklch(0.5 0.012 250);
  --fg-subtle: oklch(0.65 0.01 250);

  --accent: oklch(0.62 0.13 250);
  --accent-hover: oklch(0.56 0.14 250);
  --accent-soft: oklch(0.95 0.03 250);
  --accent-fg: oklch(0.99 0.004 250);

  /* Priority */
  --pri-high: oklch(0.6 0.18 25);
  --pri-high-bg: oklch(0.96 0.025 25);
  --pri-med: oklch(0.65 0.13 70);
  --pri-med-bg: oklch(0.97 0.03 80);
  --pri-low: oklch(0.62 0.09 200);
  --pri-low-bg: oklch(0.96 0.018 220);

  /* Status */
  --st-open: oklch(0.62 0.12 250);
  --st-progress: oklch(0.65 0.13 70);
  --st-resolved: oklch(0.62 0.14 155);
  --st-closed: oklch(0.55 0.012 250);

  /* Density */
  --row-py: 14px;
  --row-px: 18px;
  --gap: 12px;
  --radius: 8px;
  --radius-sm: 5px;

  /* Type */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px oklch(0.5 0.02 250 / 0.05);
  --shadow-md: 0 4px 12px oklch(0.4 0.02 250 / 0.08), 0 1px 3px oklch(0.4 0.02 250 / 0.04);
  --shadow-lg: 0 16px 40px oklch(0.3 0.02 250 / 0.12), 0 4px 12px oklch(0.3 0.02 250 / 0.06);
}

[data-theme="dark"] {
  --bg: oklch(0.18 0.012 250);
  --bg-elevated: oklch(0.22 0.014 250);
  --bg-subtle: oklch(0.21 0.013 250);
  --bg-hover: oklch(0.255 0.014 250);
  --bg-active: oklch(0.29 0.016 250);

  --border: oklch(0.3 0.014 250);
  --border-strong: oklch(0.38 0.016 250);

  --fg: oklch(0.95 0.006 250);
  --fg-muted: oklch(0.7 0.012 250);
  --fg-subtle: oklch(0.55 0.012 250);

  --accent: oklch(0.7 0.13 250);
  --accent-hover: oklch(0.76 0.14 250);
  --accent-soft: oklch(0.3 0.05 250);
  --accent-fg: oklch(0.18 0.012 250);

  --pri-high: oklch(0.72 0.17 25);
  --pri-high-bg: oklch(0.3 0.05 25);
  --pri-med: oklch(0.78 0.14 75);
  --pri-med-bg: oklch(0.3 0.05 75);
  --pri-low: oklch(0.74 0.1 220);
  --pri-low-bg: oklch(0.28 0.04 220);

  --st-open: oklch(0.72 0.12 250);
  --st-progress: oklch(0.78 0.13 70);
  --st-resolved: oklch(0.72 0.14 155);
  --st-closed: oklch(0.65 0.012 250);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.4), 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5), 0 4px 12px oklch(0 0 0 / 0.3);
}

[data-density="compact"] {
  --row-py: 8px;
  --row-px: 14px;
  --gap: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

#root { height: 100%; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection { background: var(--accent-soft); color: var(--fg); }

/* ===== App shell ===== */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-name {
  font-size: 14px;
  color: var(--fg);
}

.brand-sub {
  font-size: 12px;
  color: var(--fg-subtle);
  font-weight: 400;
  margin-left: 2px;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: background 120ms, border-color 120ms;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-active); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
}

.btn svg { width: 14px; height: 14px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-label {
  font-size: 12px;
  color: var(--fg-subtle);
  margin-right: 2px;
}

.select {
  height: 28px;
  padding: 0 26px 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2.5 4L5 6.5L7.5 4' stroke='%2364748b' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.select:hover { background-color: var(--bg-hover); }
.select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  min-width: 220px;
}
.search:focus-within {
  background: var(--bg-elevated);
  border-color: var(--accent);
}
.search svg { width: 13px; height: 13px; color: var(--fg-subtle); flex-shrink: 0; }
.search input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
}
.search input::placeholder { color: var(--fg-subtle); }

.view-switch {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 0;
}
.view-switch button {
  height: 24px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.view-switch button.active {
  background: var(--bg-elevated);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}
.view-switch svg { width: 12px; height: 12px; }

/* ===== Main content ===== */
.main {
  overflow: hidden;
  position: relative;
}

/* ===== Issue list ===== */
.list-view {
  height: 100%;
  overflow-y: auto;
}

.list-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: 0.01em;
}
.list-section-count {
  font-weight: 400;
  color: var(--fg-subtle);
}

.issue-row {
  display: grid;
  grid-template-columns: minmax(110px, auto) auto 1fr auto auto auto;
  align-items: center;
  gap: var(--gap);
  padding: var(--row-py) var(--row-px);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 80ms;
}
.issue-row:hover { background: var(--bg-hover); }
.issue-row.selected { background: var(--accent-soft); }

.issue-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-subtle);
  font-weight: 500;
}

.issue-title {
  font-size: 14px;
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-density="compact"] .issue-title { font-size: 13px; }

.issue-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.issue-row-labels {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ===== Status, priority, difficulty pills ===== */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 500;
  white-space: nowrap;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status[data-status="open"] .status-dot { background: var(--st-open); }
.status[data-status="in-progress"] .status-dot {
  background: conic-gradient(var(--st-progress) 0% 50%, transparent 50% 100%);
  border: 1.5px solid var(--st-progress);
}
.status[data-status="resolved"] .status-dot { background: var(--st-resolved); }
.status[data-status="closed"] .status-dot {
  background: var(--st-closed);
  opacity: 0.5;
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.priority[data-priority="high"] { color: var(--pri-high); background: var(--pri-high-bg); }
.priority[data-priority="medium"] { color: var(--pri-med); background: var(--pri-med-bg); }
.priority[data-priority="low"] { color: var(--pri-low); background: var(--pri-low-bg); }

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}
.difficulty-bars {
  display: inline-flex;
  gap: 2px;
}
.difficulty-bar {
  width: 3px;
  height: 10px;
  border-radius: 1px;
  background: var(--border-strong);
}
.difficulty-bar.filled { background: var(--fg-muted); }

.label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.label-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== Split view ===== */
.split-view {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.4fr);
  height: 100%;
  overflow: hidden;
}
.split-list {
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.split-detail {
  overflow-y: auto;
  background: var(--bg-subtle);
}

.split-view .issue-row {
  grid-template-columns: minmax(110px, auto) auto 1fr auto auto;
}
.split-view .issue-row .issue-row-labels { display: none; }

/* ===== Detail panel ===== */
.detail-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--fg-subtle);
  font-size: 13px;
  padding: 40px;
  text-align: center;
}

.detail {
  padding: 32px 36px 60px;
  max-width: 760px;
}

.detail-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--fg-subtle);
}
.detail-id {
  font-family: var(--font-mono);
  font-weight: 500;
}

.detail-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
  line-height: 1.3;
  color: var(--fg);
  text-wrap: pretty;
}

.detail-summary {
  font-size: 14px;
  color: var(--fg-muted);
  margin: 0 0 24px;
  line-height: 1.6;
  text-wrap: pretty;
}

.detail-attrs {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 10px;
  column-gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.detail-attr-key {
  font-size: 12px;
  color: var(--fg-subtle);
  font-weight: 500;
  display: flex;
  align-items: center;
}
.detail-attr-val {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 24px;
}
.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.detail-description {
  font-size: 14px;
  color: var(--fg);
  line-height: 1.7;
  white-space: pre-wrap;
  text-wrap: pretty;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}
.attachment svg { width: 14px; height: 14px; color: var(--fg-subtle); flex-shrink: 0; }
.attachment-name { font-family: var(--font-mono); font-size: 12px; }
.attachment-size {
  font-size: 11px;
  color: var(--fg-subtle);
  margin-left: auto;
  font-family: var(--font-mono);
}

/* ===== Kanban ===== */
.kanban-view {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 20px;
}
.kanban-cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 12px;
  height: 100%;
  min-width: 1100px;
}
.kanban-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.kanban-col-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  font-weight: 500;
}
.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
}
.kanban-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.kanban-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.kanban-card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  margin-bottom: 4px;
}
.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
  line-height: 1.4;
  text-wrap: pretty;
}
.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===== Side panel (create issue) ===== */
.scrim {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0.02 250 / 0.4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.scrim.open { opacity: 1; pointer-events: auto; }

[data-theme="dark"] .scrim { background: oklch(0.05 0.01 250 / 0.6); }

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 60;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.side-panel.open { transform: translateX(0); }

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.side-panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.side-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Forms ===== */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.field-required { color: var(--pri-high); margin-left: 2px; }
.field-hint {
  font-size: 12px;
  color: var(--fg-subtle);
  margin-top: 6px;
}

.input, .textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

/* File upload */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all 140ms;
}
.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-icon {
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  color: var(--fg-subtle);
}
.dropzone-text {
  font-size: 13px;
  color: var(--fg-muted);
}
.dropzone-text strong { color: var(--fg); font-weight: 600; }
.dropzone-hint {
  font-size: 11px;
  color: var(--fg-subtle);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.file-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.file-item svg { width: 14px; height: 14px; color: var(--fg-subtle); flex-shrink: 0; }
.file-name {
  font-family: var(--font-mono);
  font-size: 12px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size {
  font-size: 11px;
  color: var(--fg-subtle);
  font-family: var(--font-mono);
}
.file-remove {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--fg-subtle);
}
.file-remove:hover { background: var(--bg-hover); color: var(--fg); }

/* AI placeholder note in form */
.form-note {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.form-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--fg-subtle); }

/* Empty state */
.empty {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-inner { max-width: 320px; }
.empty-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.empty-text { font-size: 13px; color: var(--fg-subtle); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transition: opacity 200ms, transform 200ms;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }
