/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #21262d;
  --border:       #30363d;
  --border-muted: #21262d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-subtle:  #484f58;
  --blue:         #58a6ff;
  --blue-dim:     #1f3a5f;
  --green:        #3fb950;
  --green-dim:    #1a3a20;
  --yellow:       #d29922;
  --yellow-dim:   #3a2d00;
  --orange:       #f0883e;
  --orange-dim:   #3a1f00;
  --red:          #f85149;
  --red-dim:      #3a1010;
  --gray:         #6e7681;
  --gray-dim:     #21262d;
  --radius:       8px;
  --radius-sm:    5px;
  --shadow:       0 8px 24px rgba(0,0,0,0.4);
  --panel-width:  680px;
}

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-left  { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.queue-info { display: flex; gap: 8px; }

/* ── Connection Dot ───────────────────────────────────────────────────────── */
.connection-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  cursor: help;
  transition: background 0.3s;
}
.connection-dot.connecting  { background: var(--yellow); animation: pulse-yellow 1.5s infinite; }
.connection-dot.connected   { background: var(--green); }
.connection-dot.disconnected{ background: var(--red); animation: pulse-red 1.5s infinite; }

/* ── Content ──────────────────────────────────────────────────────────────── */
.content { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--text);
}
.stat-value.stat-green { color: var(--green); }
.stat-value.stat-red   { color: var(--red); }

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

/* ── Section ──────────────────────────────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

/* ── PR List ──────────────────────────────────────────────────────────────── */
.pr-list { display: flex; flex-direction: column; }

.pr-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-muted);
  transition: background 0.15s;
}
.pr-row:last-child { border-bottom: none; }
.pr-row:hover { background: var(--surface-2); }

.pr-main { flex: 1; min-width: 0; }

.pr-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.pr-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

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

.pr-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pr-repo   { font-size: 12px; color: var(--text-muted); }
.pr-author { font-size: 12px; color: var(--text-muted); }
.pr-time   { font-size: 12px; color: var(--text-subtle); }
.pr-elapsed { font-size: 12px; color: var(--text-subtle); }

.pr-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.pr-badges  { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pr-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-icon  { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--text-subtle); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   }
.badge-green  { background: var(--green-dim);  color: var(--green);  }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-red    { background: var(--red-dim);    color: var(--red);    }
.badge-gray   { background: var(--gray-dim);   color: var(--gray);   }

/* ── Status Badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-queued      { background: var(--gray-dim);   color: var(--gray);   }
.status-cloning     { background: var(--blue-dim);   color: var(--blue);   }
.status-pass1       { background: var(--orange-dim); color: var(--orange); }
.status-pass2       { background: var(--yellow-dim); color: var(--yellow); }
.status-completed   { background: var(--green-dim);  color: var(--green);  }
.status-failed      { background: var(--red-dim);    color: var(--red);    }
.status-none        { background: var(--gray-dim);   color: var(--text-subtle); }

.pulsing { animation: pulse-glow 1.4s ease-in-out infinite; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  background: transparent;
  color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #79bcff; border-color: #79bcff; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-orange {
  background: var(--orange-dim);
  border-color: var(--orange);
  color: var(--orange);
}
.btn-orange:hover:not(:disabled) { background: rgba(240,136,62,0.25); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── Select ───────────────────────────────────────────────────────────────── */
.select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: var(--blue); }

/* ── Review Panel ─────────────────────────────────────────────────────────── */
.review-panel {
  position: fixed;
  top: 0; right: 0;
  width: var(--panel-width);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
  box-shadow: var(--shadow);
}
.review-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title-wrap { flex: 1; min-width: 0; }

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  cursor: pointer;
}

.modal-dialog {
  position: relative;
  width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-body   { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ── Form Elements ────────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-label  { font-size: 13px; font-weight: 500; color: var(--text); }

.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--blue); }
.form-input::placeholder { color: var(--text-subtle); }

.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 2px;
}

/* ── Radio Group ──────────────────────────────────────────────────────────── */
.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.radio-label {
  cursor: pointer;
  display: block;
}
.radio-label input[type="radio"] { display: none; }

.radio-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
}

.radio-label input[type="radio"]:checked + .radio-card {
  border-color: var(--blue);
  background: var(--blue-dim);
}

.radio-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.radio-card-desc  { font-size: 11px; color: var(--text-muted); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes pulse-yellow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210,153,34,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(210,153,34,0); }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(248,81,73,0); }
}

/* ── Markdown Body ────────────────────────────────────────────────────────── */
.markdown-body { color: var(--text); font-size: 14px; line-height: 1.7; }

.markdown-body h1 { font-size: 20px; font-weight: 700; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border-muted); }
.markdown-body h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
.markdown-body h4 { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }

.markdown-body p  { margin: 0 0 12px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px 20px; }
.markdown-body li { margin-bottom: 4px; }

.markdown-body code {
  background: var(--surface-2);
  border: 1px solid var(--border-muted);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  color: #ff7b72;
}

.markdown-body pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 14px;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}

.markdown-body blockquote {
  border-left: 4px solid var(--border);
  padding: 4px 0 4px 14px;
  margin: 0 0 12px;
  color: var(--text-muted);
}

.markdown-body blockquote[data-type="warning"],
.markdown-body blockquote:has(strong:first-child) {
  border-left-color: var(--yellow);
  background: var(--yellow-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 14px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 13px;
}

.markdown-body th, .markdown-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body th {
  background: var(--surface-2);
  font-weight: 600;
}

.markdown-body tr:nth-child(even) { background: rgba(255,255,255,0.02); }

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.markdown-body strong { font-weight: 600; }
.markdown-body em     { font-style: italic; color: var(--text-muted); }

.markdown-body a { color: var(--blue); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid    { grid-template-columns: repeat(2, 1fr); }
  .content       { padding: 16px; }
  .review-panel  { width: 100vw; }
  .modal-dialog  { width: 95vw; margin: 0 auto; }
  .radio-group   { grid-template-columns: 1fr; }
  .pr-row        { flex-direction: column; }
  .pr-right      { align-items: flex-start; }
}

/* ── Purple Badge (followup) ─────────────────────────────────────────────── */
.badge-purple {
  background: rgba(163, 113, 247, 0.2);
  color: #a371f7;
}

/* ── Small Button ────────────────────────────────────────────────────────── */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
