/* Oopsie — Exception Tracker */

/* ═══════════════════════════════════════════
   Design Tokens
   ═══════════════════════════════════════════ */

:root {
  /* Palette */
  --bg: #0f1117;
  --bg-raised: #161922;
  --bg-surface: #1c1f2e;
  --bg-surface-hover: #232738;
  --bg-inset: #0b0d13;

  --text: #e4e5ea;
  --text-secondary: #9096a8;
  --text-tertiary: #5c6278;

  --border: #2a2e3e;
  --border-subtle: #1f2233;

  --red: #f04e56;
  --red-dim: rgba(240, 78, 86, 0.12);
  --red-hover: #e0353e;
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --purple: #a78bfa;

  /* Layout */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1080px;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px var(--border);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, monospace;
}

/* ═══════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue); text-decoration: none; transition: color 0.15s; }
a:hover { color: #93c5fd; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-inset);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

pre code {
  background: none;
  padding: 0;
  border: none;
  border-radius: 0;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }

::selection {
  background: rgba(96, 165, 250, 0.3);
}

/* ═══════════════════════════════════════════
   Navigation
   ═══════════════════════════════════════════ */

.top-nav {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.nav-brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  min-height: 44px;
}
.nav-brand::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}
.nav-brand:hover { color: #fff; opacity: 0.9; }

.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-links a,
.nav-links .btn-link {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.nav-links a:hover,
.nav-links .btn-link:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

/* ═══════════════════════════════════════════
   Container & Layout
   ═══════════════════════════════════════════ */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ═══════════════════════════════════════════
   Flash Messages
   ═══════════════════════════════════════════ */

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid;
}
.flash-notice {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.2);
}
.flash-alert {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(240, 78, 86, 0.2);
}

/* ═══════════════════════════════════════════
   Page Header
   ═══════════════════════════════════════════ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #fff;
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: all 0.15s;
  gap: 0.35rem;
  white-space: nowrap;
  min-height: 36px;
}
.btn-primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-primary:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
  color: #fff;
  box-shadow: 0 0 16px rgba(240, 78, 86, 0.25);
}
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: #3a3f54;
}
.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(240, 78, 86, 0.3);
}
.btn-danger:hover {
  background: var(--red-dim);
  border-color: var(--red);
}
.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════ */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ═══════════════════════════════════════════
   Project List (Dashboard)
   ═══════════════════════════════════════════ */

.project-list { display: grid; gap: 0.5rem; }

.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  transition: all 0.2s;
}
.project-card:hover {
  border-color: var(--border);
  background: var(--bg-surface);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.project-info h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.project-info h2 a { color: var(--text); }
.project-info h2 a:hover { color: #fff; }

.project-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════
   Badges
   ═══════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(240, 78, 86, 0.2);
}
.badge-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.2);
}
.badge-muted {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}
.empty-state p { margin: 0.5rem 0; }
.empty-state strong { color: var(--text); }

/* ═══════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════ */

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--bg-inset);
  color: var(--text);
  transition: all 0.15s;
  min-height: 44px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

input::placeholder {
  color: var(--text-tertiary);
}

input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  transition: all 0.15s;
  margin-top: 0.5rem;
  min-height: 44px;
}
input[type="submit"]:hover {
  background: var(--red-hover);
  box-shadow: 0 0 16px rgba(240, 78, 86, 0.25);
}

.field-errors {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

.form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--bg-inset);
  color: var(--text);
}

/* ═══════════════════════════════════════════
   Login Page
   ═══════════════════════════════════════════ */

/* Style the login form specifically */
body > main.container > form:first-of-type {
  max-width: 380px;
  margin: 4rem auto 0;
}

body > main.container > form input[type="email"],
body > main.container > form input[type="password"] {
  margin-bottom: 0.75rem;
  display: block;
}

/* ═══════════════════════════════════════════
   Error Table
   ═══════════════════════════════════════════ */

.error-table {
  width: 100%;
  border-collapse: collapse;
}
.error-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.error-table th:first-child {
  border-radius: var(--radius-lg) 0 0 0;
}
.error-table th:last-child {
  border-radius: 0 var(--radius-lg) 0 0;
}
.error-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  vertical-align: middle;
}
.error-table tr:last-child td {
  border-bottom: none;
}
.error-table tr:hover td {
  background: var(--bg-surface);
}

.error-class {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.error-class a { color: var(--text); }
.error-class a:hover { color: var(--red); }

.error-message {
  color: var(--text-tertiary);
  font-size: 0.78rem;
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 450px;
}

.error-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════
   Status Indicators
   ═══════════════════════════════════════════ */

.status-unresolved {
  color: var(--red);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-resolved {
  color: var(--green);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-ignored {
  color: var(--text-tertiary);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════════
   Error Detail Stats
   ═══════════════════════════════════════════ */

.error-stats {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  flex: 1;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* ═══════════════════════════════════════════
   Section Titles
   ═══════════════════════════════════════════ */

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ═══════════════════════════════════════════
   Backtrace
   ═══════════════════════════════════════════ */

.backtrace-card {
  padding: 0;
  overflow: hidden;
}
.backtrace-frame {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  transition: background 0.1s;
}
.backtrace-frame:last-child { border-bottom: none; }
.backtrace-frame:hover { background: var(--bg-surface); }
.backtrace-frame-top {
  background: var(--red-dim);
}
.backtrace-frame-top:hover { background: rgba(240, 78, 86, 0.18); }
.backtrace-frame-top .frame-number {
  color: var(--red);
  font-weight: 700;
}

.backtrace-frame code {
  word-break: break-all;
  font-size: inherit;
  font-family: inherit;
  background: none;
  padding: 0;
  border: none;
  color: var(--text);
}
.frame-number {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  min-width: 1.5rem;
  text-align: right;
  user-select: none;
}

/* ═══════════════════════════════════════════
   Context / JSON
   ═══════════════════════════════════════════ */

.context-json {
  margin: 0;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  padding: 1rem;
  background: var(--bg-inset);
  border-radius: var(--radius);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════
   API Key
   ═══════════════════════════════════════════ */

.api-key-display {
  display: block;
  padding: 0.65rem 0.85rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  word-break: break-all;
  user-select: all;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   Breadcrumb-style links
   ═══════════════════════════════════════════ */

.page-header a {
  color: var(--text-secondary);
  font-weight: 500;
}
.page-header a:hover { color: var(--text); }

/* ═══════════════════════════════════════════
   Inline form
   ═══════════════════════════════════════════ */

.inline-form { display: inline; }

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   Homepage
   ═══════════════════════════════════════════ */

.hero {
  text-align: center;
  padding: 4rem 0 3rem;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 1rem;
  line-height: 1.15;
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
.feature-card {
  display: flex;
  flex-direction: column;
}
.feature-card h3 {
  font-size: 1rem;
  color: #fff;
  margin: 0 0 0.5rem;
}
.feature-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}
.feature-card pre {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0;
  flex: 1;
}
.feature-card pre code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  background: none;
  padding: 0;
}

.home-section {
  margin-bottom: 3rem;
}
.home-section h2 {
  font-size: 1.25rem;
  color: #fff;
  margin: 0 0 0.5rem;
}
.home-section > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

/* ═══════════════════════════════════════════
   Page Header Actions
   ═══════════════════════════════════════════ */

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ═══════════════════════════════════════════
   CLI Page
   ═══════════════════════════════════════════ */

.cli-intro {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.cli-intro p { margin: 0; }

.cli-section {
  margin-bottom: 1.5rem;
}
.cli-section h2 {
  font-size: 1.1rem;
  color: #fff;
  margin: 0 0 1rem;
}
.cli-section p {
  margin: 0.5rem 0;
  line-height: 1.6;
}
.cli-section pre {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}
.cli-section pre code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  padding: 0;
}

.cli-commands-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.cli-commands-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.cli-commands-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.cli-commands-table td code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: nowrap;
}

.text-secondary { color: var(--text-secondary); }

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .error-stats { flex-direction: column; }
  .stat { border-right: none; border-bottom: 1px solid var(--border); }
  .stat:last-child { border-bottom: none; }
  .nav-inner { padding: 0 0.5rem; }
  .project-card { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}
