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

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2330;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --purple: #bc8cff;
  --radius: 8px;
}

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

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

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #161b22 0%, #0d1117 70%);
}

.login-card {
  text-align: center;
  padding: 3rem 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 380px;
  width: 100%;
}

.login-logo { margin-bottom: 1rem; }

.login-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #5865F2;
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s;
}
.discord-btn:hover { background: #4752c4; text-decoration: none; }

/* ── App Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar-brand h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  background: rgba(88,166,255,0.08);
  border-left-color: var(--accent);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-footer img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.sidebar-footer span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 2rem;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.red { color: var(--red); }
.stat-card .stat-value.orange { color: var(--orange); }
.stat-card .stat-value.purple { color: var(--purple); }
.stat-card .stat-value.blue { color: var(--accent); }

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.data-table th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-bug { background: rgba(248,81,73,0.15); color: var(--red); }
.badge-exploit { background: rgba(248,81,73,0.25); color: #ff7b72; }
.badge-optimization { background: rgba(210,153,34,0.15); color: var(--orange); }
.badge-refactor { background: rgba(188,140,255,0.15); color: var(--purple); }

.badge-validated { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-revised { background: rgba(210,153,34,0.15); color: var(--orange); }
.badge-cancelled { background: rgba(248,81,73,0.15); color: var(--red); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.card-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}

.card-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

.card-body code {
  background: rgba(255,255,255,0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.375rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { color: var(--text); border-color: var(--text-muted); }
.filter-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(88,166,255,0.08); }

/* ── Detail panel ── */
.detail-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  transition: right 0.25s ease;
  z-index: 20;
}

.detail-panel.open { right: 0; }

.detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  float: right;
}
.detail-close:hover { color: var(--text); }

.files-list {
  list-style: none;
  padding: 0;
}

.files-list li {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  padding: 0.2rem 0;
  color: var(--accent);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 1rem; opacity: 0.5; }

/* ── Section header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ── Performance Bars (Functions page) ── */
.perf-cell { min-width: 150px; }

.perf-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.perf-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.perf-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.perf-rating {
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.perf-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fn-name {
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(88,166,255,0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

.fn-speedup {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.fn-notes {
  font-size: 0.8rem;
  line-height: 1.4;
  max-width: 300px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; padding: 1rem 0; }
  .sidebar-brand h2, .nav-item span, .sidebar-footer span { display: none; }
  .sidebar-brand { justify-content: center; padding: 0 0 1rem; }
  .nav-item { justify-content: center; padding: 0.75rem; border-left: none; }
  .sidebar-footer { justify-content: center; }
  .main-content { margin-left: 60px; padding: 1rem; }
  .detail-panel { width: 100%; right: -100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
