/* ── Google Font ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ───────────────────────────────────── */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Surface palette */
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #21262d;
  --surface-3: #30363d;
  --border:    #30363d;
  --border-subtle: #21262d;

  /* Text */
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --text-faint:#6e7681;

  /* Brand */
  --brand:     #58a6ff;
  --brand-dim: #1f6feb;

  /* Semantic */
  --good:  #3fb950;
  --warn:  #d29922;
  --bad:   #f85149;
  --error-bg: #1c1313;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow: 0 4px 24px rgba(0,0,0,0.45);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ───────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 22px;
  color: var(--brand);
  line-height: 1;
}

.brand-icon.large {
  font-size: 40px;
  display: block;
  text-align: center;
  margin-bottom: 4px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  font-size: 14px;
}

/* ── Page layout ─────────────────────────────────────── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  width: 100%;
}

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

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
}

/* ── Forms ───────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-sans);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

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

/* ── Buttons ─────────────────────────────────────────── */
button { font-family: var(--font-sans); cursor: pointer; border: none; }

.btn-primary {
  background: var(--brand-dim);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { background: var(--brand); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: color 0.15s, background 0.15s;
}

.btn-ghost:hover { color: var(--text); background: var(--surface-3); }

.back-btn {
  background: transparent;
  color: var(--brand);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}

.back-btn:hover { opacity: 0.75; }

/* ── Cards ───────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover { border-color: var(--surface-3); box-shadow: var(--shadow-sm); }

.card-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.card-sub {
  font-size: 12px;
  margin-top: 4px;
}

/* ── Panels ──────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

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

.panel-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Filter Bar ──────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-input {
  width: 200px;
  padding: 7px 10px;
  font-size: 13px;
}

/* ── Table ───────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

.table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 11px 10px;
  vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: none; }

.run-row {
  cursor: pointer;
  transition: background 0.12s;
}

.run-row:hover { background: var(--surface-2); }
.run-row:hover .run-id-cell { color: var(--brand); }

.run-id-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: color 0.12s;
}

/* ── Branch Pill ─────────────────────────────────────── */
.branch-pill {
  display: inline-block;
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Pass Rate Pill ──────────────────────────────────── */
.rate-pill {
  display: inline-block;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  line-height: 1.5;
}

/* ── Run Detail ──────────────────────────────────────── */
.detail-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.detail-run-id {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.detail-meta {
  text-align: right;
}

.run-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--brand);
}

.run-link:hover { text-decoration: underline; }

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}

/* ── Status Tabs ─────────────────────────────────────── */
.tc-filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.tab-btn:hover { color: var(--text); border-color: var(--surface-3); }
.tab-btn.active { color: #fff; border-color: transparent; }
.tab-btn.active.tab-all     { background: var(--brand-dim); }
.tab-btn.active.tab-passed  { background: #1a4a2a; color: var(--good); border-color: var(--good); }
.tab-btn.active.tab-failed  { background: #3a1515; color: var(--bad);  border-color: var(--bad); }
.tab-btn.active.tab-error   { background: #3a1515; color: var(--bad);  border-color: var(--bad); }
.tab-btn.active.tab-skipped { background: #3a2e10; color: var(--warn); border-color: var(--warn); }

.tab-count {
  background: var(--surface-3);
  border-radius: 20px;
  padding: 0 5px;
  font-size: 11px;
}

/* ── Test Case Table ─────────────────────────────────── */
.tc-table {
  table-layout: fixed;
}

.tc-table th:nth-child(1) { width: 90px;  }   /* Status badge */
.tc-table th:nth-child(2) { width: 45%;   }   /* Test Name — primary column */
.tc-table th:nth-child(3) { width: 35%;   }   /* Class / Suite */
.tc-table th:nth-child(4) { width: 80px;  }   /* Duration */

.tc-table td { padding: 10px; }

.tc-name {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--text);
}

/* Class/Suite column: long fully-qualified names must wrap */
.tc-table td.mono {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.tc-error-msg {
  margin-top: 6px;
  background: var(--error-bg);
  border: 1px solid #3a1515;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--bad);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
}

.tc-row-error { background: rgba(248, 81, 73, 0.04); }

/* ── Status Badges ───────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-passed  { background: #1a4a2a; color: var(--good); }
.badge-failed  { background: #3a1515; color: var(--bad); }
.badge-error   { background: #3a1515; color: var(--bad); }
.badge-skipped { background: #3a2e10; color: var(--warn); }

/* ── Utilities ───────────────────────────────────────── */
.muted   { color: var(--text-muted); font-size: 13px; }
.mono    { font-family: var(--font-mono); font-size: 12px; }
.error   {
  color: var(--bad);
  background: var(--error-bg);
  border: 1px solid #3a1515;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin: 12px 0;
}

/* ── Anchor resets for elements styled as buttons/links ─ */
a.back-btn,
a.btn-ghost,
a.run-link {
  text-decoration: none;
}

a.topbar-brand {
  text-decoration: none;
  color: inherit;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .cards        { grid-template-columns: repeat(2, 1fr); }
  .detail-kpis  { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .cards        { grid-template-columns: 1fr 1fr; }
  .detail-kpis  { grid-template-columns: repeat(2, 1fr); }
  .filter-input { width: 100%; }
  .panel-header { flex-direction: column; align-items: flex-start; }
}
