/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6f8;
  color: #1e293b;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-bottom: 1px solid #1e293b;
}
.brand-icon { font-size: 1.5rem; color: #22c55e; }
.brand-text { font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }

.sidebar-nav { list-style: none; padding: 1rem 0; flex: 1; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.sidebar-nav li a:hover { background: #1e293b; color: #f1f5f9; }
.sidebar-nav li a.active { background: #1e293b; color: #22c55e; font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #1e293b;
  font-size: .8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-name { color: #94a3b8; }
.logout-link { color: #ef4444; text-decoration: none; }
.logout-link:hover { text-decoration: underline; }

/* ── Content Area ─────────────────────────────────────────────────────────── */
.content {
  margin-left: 240px;
  padding: 2rem 2.5rem;
  flex: 1;
  max-width: 960px;
}
.content-full { margin-left: 0; max-width: 100%; }

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.7rem; font-weight: 700; color: #0f172a; margin-bottom: .3rem; }
.page-desc { color: #64748b; font-size: .95rem; }
.back-link { color: #3b82f6; text-decoration: none; font-size: .85rem; }
.back-link:hover { text-decoration: underline; }

/* ── Flash Messages ───────────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 1.5rem; }
.flash {
  padding: .7rem 1rem;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: .5rem;
}
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  padding: 2.5rem;
  width: 380px;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 2.2rem; color: #22c55e; }
.login-header h1 { font-size: 1.4rem; margin-top: .4rem; color: #0f172a; }
.login-subtitle { color: #64748b; font-size: .85rem; margin-top: .2rem; }

.form-group { margin-bottom: 1.2rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: .92rem;
  transition: border-color .15s;
}
.form-group input:focus { outline: none; border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }

.btn {
  display: inline-block;
  padding: .7rem 1.4rem;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s;
}
.btn-primary { background: #22c55e; color: #fff; }
.btn-primary:hover { background: #16a34a; }
.btn-full { width: 100%; text-align: center; }

/* ── Timeline / Version Cards ─────────────────────────────────────────────── */
.timeline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.version-card {
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.version-card:hover { border-color: #22c55e; box-shadow: 0 2px 12px rgba(34,197,94,.12); }

.vc-header { display: flex; align-items: center; gap: .7rem; margin-bottom: .3rem; }
.vc-version { font-size: 1.15rem; font-weight: 700; color: #0f172a; }
.vc-date { font-size: .8rem; color: #94a3b8; margin-bottom: .4rem; }
.vc-summary { font-size: .9rem; color: #475569; margin-bottom: .6rem; }
.vc-stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat {
  font-size: .78rem;
  color: #64748b;
  background: #f1f5f9;
  padding: .2rem .55rem;
  border-radius: 4px;
}

.badge {
  font-size: .7rem;
  padding: .15rem .55rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-security { background: #fef3c7; color: #92400e; }
.badge-feature { background: #dbeafe; color: #1e40af; }
.badge-patch { background: #f0fdf4; color: #166534; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
  font-size: .95rem;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.tab {
  padding: .6rem 1.1rem;
  font-size: .85rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: #0f172a; }
.tab.active { color: #22c55e; border-bottom-color: #22c55e; font-weight: 600; }

/* ── Detail sections ──────────────────────────────────────────────────────── */
.detail-section { margin-bottom: 2rem; }
.detail-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .8rem; color: #0f172a; }
.detail-section h3 { font-size: 1rem; font-weight: 600; margin: 1rem 0 .5rem; color: #334155; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.overview-stat {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.2rem;
  text-align: center;
}
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; color: #22c55e; }
.stat-label { font-size: .8rem; color: #64748b; }

.service-list { display: flex; gap: .5rem; list-style: none; flex-wrap: wrap; }
.service-tag {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .3rem .7rem;
  font-size: .82rem;
  font-weight: 500;
  color: #334155;
}

.item-list { padding-left: 1.4rem; }
.item-list li { margin-bottom: .45rem; font-size: .9rem; color: #334155; line-height: 1.5; }

.file-list { list-style: none; }
.file-list li { margin-bottom: .3rem; }
.file-list code { background: #f1f5f9; padding: .15rem .4rem; border-radius: 4px; font-size: .82rem; }

.test-output {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.2rem;
  border-radius: 8px;
  font-size: .82rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

.readme-block { margin-bottom: 1.5rem; }

.empty-note { color: #94a3b8; font-style: italic; font-size: .9rem; }

/* ── Markdown body ────────────────────────────────────────────────────────── */
.markdown-body { line-height: 1.7; font-size: .92rem; color: #334155; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.5rem; margin-bottom: .6rem; color: #0f172a; }
.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body p { margin-bottom: .8rem; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; margin-bottom: .8rem; }
.markdown-body li { margin-bottom: .3rem; }
.markdown-body code {
  background: #f1f5f9;
  padding: .12rem .4rem;
  border-radius: 4px;
  font-size: .85rem;
}
.markdown-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.2rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
}
.markdown-body pre code { background: transparent; padding: 0; color: inherit; }
.markdown-body table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.markdown-body th, .markdown-body td {
  padding: .5rem .7rem;
  border: 1px solid #e2e8f0;
  text-align: left;
  font-size: .85rem;
}
.markdown-body th { background: #f8fafc; font-weight: 600; }
.markdown-body blockquote {
  border-left: 3px solid #22c55e;
  padding-left: 1rem;
  color: #64748b;
  margin-bottom: .8rem;
}

/* ── Persona / Training Cards ─────────────────────────────────────────────── */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.persona-card {
  display: block;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.persona-card:hover { border-color: #22c55e; box-shadow: 0 2px 12px rgba(34,197,94,.12); }
.persona-icon { font-size: 2rem; margin-bottom: .5rem; }
.persona-card h2 { font-size: 1.1rem; font-weight: 700; color: #0f172a; margin-bottom: .3rem; }
.persona-card p { font-size: .85rem; color: #64748b; line-height: 1.5; }

.training-content { max-width: 720px; }

/* ── Pygments codehilite ──────────────────────────────────────────────────── */
.highlight { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow-x: auto; margin-bottom: 1rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   SPLIT LAYOUT — Changelog single-page view
   ══════════════════════════════════════════════════════════════════════════════ */

.split-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 2rem);
}

/* ── Left: Version Panel ── */
.version-panel {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  border-radius: 10px 0 0 10px;
  overflow-y: auto;
  max-height: calc(100vh - 4rem);
  position: sticky;
  top: 2rem;
}
.vp-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vp-header h2 { font-size: 1rem; font-weight: 700; color: #0f172a; }
.vp-count {
  background: #f1f5f9; color: #64748b;
  font-size: .75rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 10px;
}
.vp-list { list-style: none; padding: 0; }
.vp-item {
  display: block;
  padding: .75rem 1.2rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
}
.vp-item:hover { background: #f8fafc; }
.vp-item.vp-active {
  background: #f0fdf4;
  border-left: 3px solid #22c55e;
}
.vp-item-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .15rem; }
.vp-ver { font-size: .9rem; font-weight: 700; color: #0f172a; }
.vp-date { font-size: .72rem; color: #94a3b8; }
.vp-summary { font-size: .78rem; color: #64748b; line-height: 1.4; margin-top: .15rem; }

/* ── Right: Detail Panel ── */
.detail-panel {
  flex: 1;
  background: #fff;
  border-radius: 0 10px 10px 0;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-height: calc(100vh - 4rem);
}
.dp-header {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding-bottom: .8rem; border-bottom: 1px solid #f1f5f9;
}
.dp-header h1 { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin: 0; }
.dp-date { font-size: .85rem; color: #94a3b8; }

/* Tab panes (JS-driven) */
.tab-panes { min-height: 300px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.btn-sm { padding: .4rem .9rem; font-size: .82rem; }
.btn-secondary {
  background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0;
  padding: .5rem 1rem; border-radius: 8px; font-size: .85rem;
  font-weight: 500; cursor: pointer;
}
.btn-secondary:hover { background: #e2e8f0; }

/* ── Feedback Cards ── */
.fb-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.fb-header h2 { font-size: 1.15rem; font-weight: 700; color: #0f172a; margin: 0; }
.fb-list { display: flex; flex-direction: column; gap: .75rem; }
.fb-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .9rem 1.1rem;
  transition: border-color .15s;
}
.fb-card:hover { border-color: #94a3b8; }
.fb-card-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.fb-id { font-size: .72rem; font-weight: 600; color: #94a3b8; font-family: monospace; }
.fb-card-title { font-size: .92rem; font-weight: 600; color: #0f172a; margin-bottom: .2rem; }
.fb-card-meta { font-size: .75rem; color: #94a3b8; display: flex; gap: .3rem; }
.fb-card-desc { font-size: .82rem; color: #475569; margin-top: .3rem; line-height: 1.45; }
.fb-resolved {
  font-size: .75rem; color: #16a34a; font-weight: 600;
  margin-top: .4rem; padding: .2rem .5rem;
  background: #f0fdf4; border-radius: 4px; display: inline-block;
}
.fb-count {
  background: #ef4444; color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 8px;
  margin-left: .3rem;
}

/* Category / priority / status badges */
.badge-cat-bug { background: #fef2f2; color: #b91c1c; }
.badge-cat-enhancement { background: #eff6ff; color: #1d4ed8; }
.badge-cat-question { background: #fefce8; color: #a16207; }
.badge-pri-critical { background: #fef2f2; color: #dc2626; font-weight: 700; }
.badge-pri-high { background: #fff7ed; color: #c2410c; }
.badge-pri-medium { background: #fefce8; color: #a16207; }
.badge-pri-low { background: #f0fdf4; color: #15803d; }
.badge-status-draft { background: #f1f5f9; color: #64748b; }
.badge-status-submitted { background: #eff6ff; color: #2563eb; }
.badge-status-collected { background: #fef3c7; color: #92400e; }
.badge-status-in_progress { background: #dbeafe; color: #1e40af; }
.badge-status-resolved { background: #dcfce7; color: #166534; }

/* Feedback tab highlight */
.tab-feedback { position: relative; }

/* ══════════════════════════════════════════════════════════════════════════════
   FEEDBACK CHAT PANEL (slide-in from right)
   ══════════════════════════════════════════════════════════════════════════════ */

.fb-chat-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 500;
}
.fb-chat-overlay.open { display: block; }

.fb-chat-panel {
  position: fixed;
  top: 0; right: -420px; bottom: 0;
  width: 420px;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  z-index: 510;
  display: flex;
  flex-direction: column;
  transition: right .25s ease;
}
.fb-chat-panel.open { right: 0; }

.fb-chat-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fb-chat-header h3 { font-size: 1rem; font-weight: 700; color: #0f172a; margin: 0; }
.fb-chat-close {
  background: none; border: none; font-size: 1.5rem;
  color: #94a3b8; cursor: pointer; line-height: 1;
}
.fb-chat-close:hover { color: #0f172a; }

.fb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.fb-msg {
  max-width: 85%;
  padding: .6rem .9rem;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.5;
  word-break: break-word;
}
.fb-msg-ai {
  background: #f1f5f9; color: #334155;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.fb-msg-user {
  background: #22c55e; color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.fb-chat-attachments {
  padding: 0 1.2rem;
  display: flex; gap: .4rem; flex-wrap: wrap;
}
.fb-attach-chip {
  font-size: .72rem; background: #eff6ff; color: #2563eb;
  padding: .2rem .5rem; border-radius: 4px;
}

.fb-chat-input-area {
  padding: .8rem 1.2rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.fb-attach-btn {
  font-size: 1.2rem; cursor: pointer; color: #64748b;
  display: flex; align-items: center;
}
.fb-attach-btn:hover { color: #22c55e; }
.fb-chat-input {
  flex: 1;
  padding: .55rem .8rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: .88rem;
}
.fb-chat-input:focus { outline: none; border-color: #22c55e; }
.fb-chat-send {
  background: #22c55e; color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}
.fb-chat-send:hover { background: #16a34a; }

/* Summary area */
.fb-summary-area {
  padding: 1rem 1.2rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  max-height: 50vh;
  overflow-y: auto;
}
.fb-summary-area h4 { font-size: .95rem; font-weight: 700; margin-bottom: .6rem; color: #0f172a; }
.fb-summary-fields {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: .4rem .8rem;
  align-items: center;
}
.fb-summary-fields label { font-size: .78rem; font-weight: 600; color: #64748b; }
.fb-summary-fields select, .fb-summary-input {
  width: 100%;
  padding: .4rem .6rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: .82rem;
}
.fb-summary-fields select:focus, .fb-summary-input:focus { outline: none; border-color: #22c55e; }
.fb-summary-fields textarea { resize: vertical; }

.fb-summary-actions {
  display: flex; gap: .6rem; margin-top: .8rem; justify-content: flex-end;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 1.25rem; max-width: 100%; }
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .persona-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .split-layout { flex-direction: column; }
  .version-panel { width: 100%; min-width: auto; max-height: 200px; border-right: none; border-bottom: 1px solid #e2e8f0; border-radius: 10px 10px 0 0; }
  .detail-panel { border-radius: 0 0 10px 10px; max-height: none; }
  .fb-chat-panel { width: 100%; right: -100%; }
}
