/* GitPanel — component-specific styles (git- prefix) */

/* ── Panel shell ─────────────────────────────────────── */
.git-panel {
  width: 380px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--kr-bg-code-panel);
  border-left: 1px solid var(--kr-border);
  /* Panel stays dark in both themes (IDE convention) — pin the text tokens
     to their dark-theme values so content inside remains readable. */
  --kr-text-primary: #e8eaed;
  --kr-text-secondary: rgba(255, 255, 255, 0.6);
  --kr-text-tertiary: rgba(255, 255, 255, 0.5);
  --kr-text-muted: rgba(255, 255, 255, 0.45);
  --kr-text-faint: rgba(255, 255, 255, 0.4);
  --kr-text-ghost: rgba(255, 255, 255, 0.35);
  --kr-border: rgba(255, 255, 255, 0.07);
  --kr-border-light: rgba(255, 255, 255, 0.06);
  --kr-border-medium: rgba(255, 255, 255, 0.1);
  --kr-bg-hover: rgba(255, 255, 255, 0.03);
  --kr-bg-hover-strong: rgba(255, 255, 255, 0.06);
  --kr-bg-active: rgba(255, 255, 255, 0.08);
  /* Accent also needs to stay lime inside this always-dark panel —
     badges/buttons would be unreadable otherwise when the app is in
     light theme (olive tint on dark bg = near-invisible). */
  --kr-accent: #c8ff00;
  --kr-accent-rgb: 200, 255, 0;
  --kr-accent-ink: #c8ff00;
  --kr-accent-text: rgba(200, 255, 0, 0.6);
  --kr-error: #ff1ba8;
  --kr-error-rgb: 255, 27, 168;
  --kr-success: #34d399;
  --kr-success-rgb: 52, 211, 153;
  --kr-info: #60a5fa;
  --kr-info-rgb: 96, 165, 250;
  --kr-warning: #ffc800;
  --kr-warning-rgb: 255, 200, 0;
  --kr-warning-soft: #fbbf24;
  --kr-purple: #8b5cf6;
  --kr-purple-rgb: 139, 92, 246;
  --kr-purple-soft: #c8a0ff;
}

.git-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--kr-border-light);
}

.git-header-title {
  font-size: var(--kr-fs-md);
  font-weight: 600;
  color: var(--kr-text-primary);
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.git-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.git-center {
  display: flex;
  justify-content: center;
  padding: 24px;
  color: var(--kr-text-dim);
}

/* ── Branch bar ──────────────────────────────────────── */
.git-branch-bar {
  display: flex;
  align-items: center;
  gap: var(--kr-sp-3);
  padding: 6px 12px;
  font-size: var(--kr-fs-base);
  color: var(--kr-text-primary);
}

.git-badge {
  font-size: var(--kr-fs-2xs);
  padding: 1px 5px;
  border-radius: var(--kr-r-md);
  font-weight: 600;
  background: rgba(var(--kr-accent-rgb), 0.15);
  color: var(--kr-accent);
}

.git-badge-behind {
  background: rgba(var(--kr-error-rgb), 0.15);
  color: var(--kr-error);
}

/* ── Warning banner ──────────────────────────────────── */
.git-warning {
  margin: 4px 12px;
  padding: 8px 10px;
  border-radius: var(--kr-r-md);
  background: rgba(var(--kr-warning-rgb), 0.06);
  border: 1px solid rgba(var(--kr-warning-rgb), 0.15);
  font-size: var(--kr-fs-sm);
  color: rgba(var(--kr-warning-rgb), 0.8);
  display: flex;
  align-items: center;
  gap: var(--kr-sp-3);
  flex-wrap: wrap;
}

/* ── File header / list ──────────────────────────────── */
.git-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
}

.git-file-list {
  padding: 0 4px;
}

.git-file-row {
  display: flex;
  align-items: center;
  gap: var(--kr-sp-3);
  padding: 4px 8px;
  border-radius: var(--kr-r-sm);
}

.git-file-btn {
  background: none;
  border: none;
  color: var(--kr-text-primary);
  font-size: var(--kr-fs-base);
  cursor: pointer;
  text-align: left;
  flex: 1;
  font-family: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 0;
}

/* Committed-on-branch section: read-only listing of files already saved
   on this branch but not yet merged. Subtle separator from the uncommitted
   list above. */
.git-committed-section {
  margin-top: var(--kr-sp-3);
  border-top: 1px dashed var(--kr-border-medium);
  padding-top: var(--kr-sp-2);
}

.git-file-row-committed {
  opacity: 0.85;
}

.git-file-btn-readonly {
  background: none;
  border: none;
  color: var(--kr-text-primary);
  font-size: var(--kr-fs-base);
  text-align: left;
  flex: 1;
  font-family: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 0;
  cursor: default;
}

/* ── Form row (branch creation) ──────────────────────── */
.git-form-row {
  display: flex;
  gap: 4px;
  padding: 4px 12px;
}

.git-input {
  flex: 1;
  padding: 5px 8px;
  border-radius: var(--kr-r-md);
  font-size: var(--kr-fs-base);
  font-family: inherit;
  border: 1px solid var(--kr-border-medium);
  background: var(--kr-bg-hover);
  color: var(--kr-text-primary);
}

/* ── Commit form ─────────────────────────────────────── */
.git-commit-form {
  margin: 4px 12px;
  padding: 8px 10px;
  border-radius: var(--kr-r-md);
  background: var(--kr-bg-subtle);
  border: 1px solid var(--kr-border-light);
}

.git-commit-options {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: var(--kr-fs-sm);
  color: var(--kr-text-tertiary);
}

.git-commit-option-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────── */
.git-small-btn {
  padding: 3px 8px;
  border-radius: var(--kr-r-md);
  font-size: var(--kr-fs-xs);
  font-family: inherit;
  border: 1px solid rgba(var(--kr-accent-rgb), 0.3);
  background: transparent;
  color: var(--kr-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}

.git-action-btn {
  padding: 5px 10px;
  border-radius: var(--kr-r-md);
  font-size: var(--kr-fs-sm);
  font-family: inherit;
  border: 1px solid rgba(var(--kr-accent-rgb), 0.3);
  background: rgba(var(--kr-accent-rgb), 0.1);
  color: var(--kr-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.git-icon-btn {
  background: none;
  border: none;
  color: var(--kr-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--kr-r-sm);
  display: flex;
}

.git-close-btn {
  background: none;
  border: none;
  color: var(--kr-text-dim);
  cursor: pointer;
  padding: 4px;
}

.git-link-btn {
  background: none;
  border: none;
  color: var(--kr-accent-text);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}

.git-back-btn {
  background: none;
  border: none;
  color: var(--kr-text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  display: flex;
}

/* ── Actions bar ─────────────────────────────────────── */
.git-actions-bar {
  display: flex;
  gap: 4px;
  padding: 4px 12px;
  flex-wrap: wrap;
}

.git-small-btn-push {
  border-color: rgba(var(--kr-info-rgb), 0.3);
  color: var(--kr-info);
}

.git-small-btn-pr {
  border-color: rgba(var(--kr-purple-rgb), 0.3);
  color: var(--kr-purple-soft);
}

/* ── PR link ─────────────────────────────────────────── */
.git-pr-link-row {
  margin: 4px 12px;
  padding: 6px 10px;
  border-radius: var(--kr-r-md);
  background: rgba(var(--kr-success-rgb), 0.08);
  border: 1px solid rgba(var(--kr-success-rgb), 0.2);
  font-size: var(--kr-fs-sm);
  color: var(--kr-success);
  display: flex;
  align-items: center;
  gap: var(--kr-sp-3);
}

.git-pr-link {
  color: var(--kr-purple-soft);
  text-decoration: underline;
  font-size: var(--kr-fs-sm);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── PR form ─────────────────────────────────────────── */
.git-pr-form {
  margin: 4px 12px;
  padding: 10px 12px;
  border-radius: var(--kr-r-lg);
  background: rgba(var(--kr-purple-rgb), 0.04);
  border: 1px solid rgba(var(--kr-purple-rgb), 0.15);
  display: flex;
  flex-direction: column;
}

.git-pr-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.git-pr-form-title {
  font-size: var(--kr-fs-sm);
  font-weight: 600;
  color: var(--kr-purple-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}

.git-pr-template-source {
  font-size: var(--kr-fs-2xs);
  color: var(--kr-text-dim);
}

.git-pr-tab-group {
  display: flex;
  gap: 0;
  margin-bottom: 4px;
}

.git-pr-tab {
  padding: 3px 8px;
  font-size: var(--kr-fs-2xs);
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(var(--kr-purple-rgb), 0.2);
}

.git-pr-tab:first-child {
  border-radius: var(--kr-r-md) 0 0 var(--kr-r-md);
}

.git-pr-tab:last-child {
  border-radius: 0 var(--kr-r-md) var(--kr-r-md) 0;
}

.git-pr-tab[data-active="true"] {
  background: rgba(var(--kr-purple-rgb), 0.15);
  color: var(--kr-purple-soft);
}

.git-pr-tab[data-active="false"] {
  background: transparent;
  color: var(--kr-text-faint);
}

.git-pr-preview {
  padding: 8px 10px;
  border-radius: var(--kr-r-md);
  background: var(--kr-bg-subtle);
  border: 1px solid var(--kr-border-light);
  font-size: var(--kr-fs-base);
  color: var(--kr-text-secondary);
  min-height: 180px;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.6;
  width: 100%;
  box-sizing: border-box;
}

.git-pr-body-textarea {
  min-height: 180px;
  max-height: 300px;
  resize: vertical;
  font-family: monospace;
  font-size: var(--kr-fs-base);
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}

.git-pr-submit-btn {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
  border-color: rgba(var(--kr-purple-rgb), 0.3);
  background: rgba(var(--kr-purple-rgb), 0.1);
  color: var(--kr-purple-soft);
}

/* ── Diff view ───────────────────────────────────────── */
.git-diff-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.git-diff-pre {
  margin: 0;
  font-size: var(--kr-fs-sm);
  font-family: monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Diff line layout (shared by all kinds) ──────────────
   Each line is a flex row: a narrow prefix column (+/-/ ) + the content.
   Fixed prefix width keeps code aligned across kinds. */
.git-diff-line {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 0 6px;
  min-height: 18px;
  white-space: pre-wrap;
  word-break: break-all;
}

.git-diff-prefix {
  flex-shrink: 0;
  width: 10px;
  text-align: center;
  opacity: 0.7;
  user-select: none;
}

.git-diff-content {
  flex: 1;
  min-width: 0;
}

/* ── Diff line kinds ───────────────────────────────────── */

/* Addition: subtle green background + full syntax highlighting via .hljs */
.git-diff-line-add {
  background: rgba(var(--kr-success-rgb), 0.12);
  border-left: 2px solid rgba(var(--kr-success-rgb), 0.65);
  padding-left: 4px;
}
.git-diff-line-add .git-diff-prefix {
  color: var(--kr-success);
  opacity: 1;
}

/* Context: neutral background, syntax highlighted but muted */
.git-diff-line-ctx {
  background: transparent;
  border-left: 2px solid transparent;
  padding-left: 4px;
  color: var(--kr-text-secondary);
}

/* Deletion: flat red, NO syntax highlighting — the user only needs to
   know the line is going away, not re-parse stale code. */
.git-diff-line-del {
  background: rgba(var(--kr-error-rgb), 0.14);
  border-left: 2px solid rgba(var(--kr-error-rgb), 0.65);
  padding-left: 4px;
  color: var(--kr-error-soft);
}
.git-diff-line-del .git-diff-prefix {
  color: var(--kr-error);
  opacity: 1;
}
.git-diff-line-del .git-diff-content {
  color: var(--kr-error-soft); /* uniformly red — no hljs tokens inside `del` */
}

/* Hunk header (@@ -1,3 +1,4 @@) — info-blue, stands out as section break */
.git-diff-line-hunk {
  color: var(--kr-info);
  margin-top: 4px;
  padding-top: 2px;
  padding-bottom: 2px;
  border-top: 1px dashed rgba(var(--kr-info-rgb), 0.25);
  font-weight: 600;
}

/* File meta (diff --git, index, +++, ---, rename, binary) — dim grey,
   rendered verbatim; these lines aren't content, just git chrome. */
.git-diff-line-meta {
  color: var(--kr-text-faint);
  font-style: italic;
}

/* ── highlight.js token colors (One Dark-ish, tuned for the Kronn palette) ──
   Minimal subset — only the token classes highlight.js actually emits for
   the languages we register. Keeps the CSS surface small instead of pulling
   in a full 500-line theme file. */
.hljs { color: inherit; background: transparent; }
.hljs-comment, .hljs-quote                { color: #7a8899; font-style: italic; }
.hljs-keyword, .hljs-selector-tag,
.hljs-addition, .hljs-type, .hljs-built_in { color: #c678dd; }
.hljs-string, .hljs-regexp,
.hljs-attr, .hljs-meta                    { color: #98c379; }
.hljs-number, .hljs-literal, .hljs-doctag,
.hljs-variable.language_                  { color: #d19a66; }
.hljs-title, .hljs-title.function_,
.hljs-section, .hljs-name                 { color: #61afef; }
.hljs-params, .hljs-variable              { color: #e06c75; }
.hljs-symbol, .hljs-bullet, .hljs-link,
.hljs-meta-string                         { color: #56b6c2; }
.hljs-emphasis                            { font-style: italic; }
.hljs-strong                              { font-weight: bold; }
.hljs-deletion                            { color: var(--kr-error); }

/* ── Status messages ─────────────────────────────────── */
.git-empty {
  padding: 24px;
  text-align: center;
  font-size: var(--kr-fs-base);
  color: var(--kr-text-dim);
}

.git-error {
  margin: 4px 12px;
  padding: 6px 10px;
  border-radius: var(--kr-r-md);
  background: rgba(var(--kr-error-rgb), 0.08);
  border: 1px solid rgba(var(--kr-error-rgb), 0.2);
  font-size: var(--kr-fs-sm);
  color: var(--kr-error-soft);
}

.git-success {
  margin: 4px 12px;
  padding: 6px 10px;
  border-radius: var(--kr-r-md);
  background: rgba(var(--kr-success-rgb), 0.08);
  border: 1px solid rgba(var(--kr-success-rgb), 0.2);
  font-size: var(--kr-fs-sm);
  color: var(--kr-success);
}

/* ── Terminal ────────────────────────────────────────── */
.git-term-section {
  border-top: 1px solid var(--kr-border-light);
}

.git-term-toggle {
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--kr-text-muted);
  font-size: var(--kr-fs-sm);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.git-term-body {
  display: flex;
  flex-direction: column;
  max-height: 200px;
  border-top: 1px solid var(--kr-border-ghost);
}

.git-term-output {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  font-size: var(--kr-fs-sm);
  font-family: monospace;
}

.git-term-cmd {
  color: var(--kr-accent);
  font-size: var(--kr-fs-sm);
}

.git-term-pre {
  margin: 2px 0 6px;
  font-size: var(--kr-fs-sm);
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--kr-text-secondary);
}

.git-term-pre-error {
  color: var(--kr-error-soft);
}

.git-term-pre-warning {
  color: var(--kr-text-muted);
}

.git-term-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 6px;
  border-top: 1px solid var(--kr-border-ghost);
}

.git-term-prompt {
  color: var(--kr-accent);
  font-size: var(--kr-fs-sm);
  flex-shrink: 0;
}

.git-term-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--kr-text-primary);
  font-size: var(--kr-fs-sm);
  font-family: monospace;
}

/* ── Misc ────────────────────────────────────────────── */
.git-file-count {
  font-size: var(--kr-fs-sm);
  color: var(--kr-text-muted);
}

.git-file-status {
  font-size: var(--kr-fs-2xs);
  flex-shrink: 0;
}

.git-header-actions {
  display: flex;
  gap: 4px;
}
