/* ═══════════════════════════════════════════════════════════
   KlasKickers SiteCheck — Design System
   Color palette:
   #ffffff #d9ed92 #b5e48c #99d98c #76c893 #52b69a
   #34a0a4 #168aad #1a759f #1e6091 #184e77
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Palette */
  --c-white:  #ffffff;
  --c-lime-1: #d9ed92;
  --c-lime-2: #b5e48c;
  --c-green-1: #99d98c;
  --c-green-2: #76c893;
  --c-teal-1: #52b69a;
  --c-teal-2: #34a0a4;
  --c-blue-1: #168aad;
  --c-blue-2: #1a759f;
  --c-blue-3: #1e6091;
  --c-navy:   #184e77;

  /* Semantic */
  --bg-body:    #f4f7fa;
  --bg-card:    var(--c-white);
  --bg-nav:     var(--c-navy);
  --text:       #2d3748;
  --text-muted: #718096;
  --text-light: #a0aec0;
  --border:     #e2e8f0;
  --shadow-sm:  0 1px 3px rgba(24, 78, 119, 0.06);
  --shadow-md:  0 4px 12px rgba(24, 78, 119, 0.08);
  --shadow-lg:  0 8px 24px rgba(24, 78, 119, 0.1);
  --radius:     8px;
  --radius-lg:  12px;

  /* Status colors */
  --status-passed:  var(--c-teal-1);
  --status-failed:  #e76f51;
  --status-flaky:   #e9c46a;
  --status-running: var(--c-blue-1);
  --status-queued:  var(--text-muted);
  --status-error:   #e76f51;
  --status-skipped: var(--text-light);

  /* Animation */
  --transition: 0.2s ease;
}

/* ── Reset & Base ────────────────────────────────────────── */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Skip Link (Accessibility) ───────────────────────────── */

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--c-navy);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  z-index: 1000;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 16px;
}

/* ── Focus States ────────────────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--c-blue-1);
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--c-blue-1);
  outline-offset: 2px;
}

/* ── Navigation ──────────────────────────────────────────── */

.nav {
  background: var(--bg-nav);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--c-white);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-logo {
  color: var(--c-lime-1);
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--c-white);
  background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
  color: var(--c-white);
  background: rgba(255, 255, 255, 0.15);
}

/* ── Layout ──────────────────────────────────────────────── */

.main {
  flex: 1;
  padding: 2rem 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Page Header ─────────────────────────────────────────── */

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

.page-header h1 {
  color: var(--c-navy);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-navy);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Forms ───────────────────────────────────────────────── */

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group-lg {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .form-group-lg { grid-column: span 1; }
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-blue-3);
  margin-bottom: 0.35rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--c-white);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--c-blue-1);
  box-shadow: 0 0 0 3px rgba(22, 138, 173, 0.15);
  outline: none;
}

.form-select-sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.form-help {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--c-teal-1);
}

/* Radio Card Group */
.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.radio-card {
  cursor: pointer;
  flex: 1;
  min-width: 120px;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  text-align: center;
}

.radio-card input:checked + .radio-card-inner {
  border-color: var(--c-teal-1);
  background: rgba(82, 182, 154, 0.05);
  box-shadow: 0 0 0 3px rgba(82, 182, 154, 0.15);
}

.radio-card:hover .radio-card-inner {
  border-color: var(--c-teal-2);
}

.radio-card input:focus-visible + .radio-card-inner {
  outline: 3px solid var(--c-blue-1);
  outline-offset: 2px;
}

.radio-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--c-navy);
}

.radio-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Details (accordion) */
.form-details {
  margin-top: 0.5rem;
}

.form-details-summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-blue-2);
  padding: 0.5rem 0;
  user-select: none;
  list-style: none;
}

.form-details-summary::before {
  content: '▸ ';
  transition: transform var(--transition);
}

.form-details[open] .form-details-summary::before {
  content: '▾ ';
}

.form-details-body {
  padding: 0.75rem 0;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-teal-1);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-teal-2);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--c-blue-2);
  border-color: var(--c-blue-2);
}

.btn-outline:hover:not(:disabled) {
  background: var(--c-blue-2);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  font-size: 0.85em;
}

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: white;
  background: var(--text-muted);
}

.badge-passed  { background: var(--status-passed); }
.badge-failed  { background: var(--status-failed); }
.badge-flaky   { background: var(--status-flaky); color: #333; }
.badge-running { background: var(--status-running); animation: pulse 2s infinite; }
.badge-queued  { background: var(--status-queued); }
.badge-error   { background: var(--status-error); }
.badge-skipped { background: var(--status-skipped); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Status Dot ──────────────────────────────────────────── */

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  background: var(--text-muted);
}

.status-dot.status-passed  { background: var(--status-passed); }
.status-dot.status-failed  { background: var(--status-failed); }
.status-dot.status-running { background: var(--status-running); animation: pulse 2s infinite; }
.status-dot.status-queued  { background: var(--status-queued); }
.status-dot.status-error   { background: var(--status-error); }

/* ── Progress Bar ────────────────────────────────────────── */

.progress-bar-container {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-lime-2), var(--c-teal-1));
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

/* ── Log Output ──────────────────────────────────────────── */

.log-output {
  background: #1a1a2e;
  color: #e8e8f0;
  padding: 1rem;
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-output .log-line-error {
  color: #ff6b6b;
}

.log-output .log-line-pass {
  color: var(--c-lime-2);
}

.log-output .log-line-info {
  color: #74b9ff;
}

/* ── Stats Grid ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--c-navy);
  line-height: 1.1;
}

.stat-passed .stat-number { color: var(--status-passed); }
.stat-failed .stat-number { color: var(--status-failed); }
.stat-flaky .stat-number  { color: var(--status-flaky); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Runs List ───────────────────────────────────────────── */

.runs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.run-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
  cursor: pointer;
}

.run-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-teal-1);
  transform: translateY(-1px);
}

.run-card-status {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}

.run-card-info {
  min-width: 0;
}

.run-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--c-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  flex-wrap: wrap;
}

.run-card-stats {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.run-card-stats span {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.run-card-arrow {
  color: var(--text-light);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ── Filters ─────────────────────────────────────────────── */

.filter-card {
  margin-bottom: 1.25rem;
}

.filter-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  margin-bottom: 0;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0;
}

/* ── Results Table ───────────────────────────────────────── */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.results-table th {
  background: var(--c-navy);
  color: white;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.results-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.results-table tbody tr {
  transition: background var(--transition);
}

.results-table tbody tr:hover {
  background: rgba(22, 138, 173, 0.03);
}

.results-table .test-name {
  font-weight: 500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table .error-detail {
  margin-top: 0.25rem;
}

.results-table .error-detail summary {
  cursor: pointer;
  color: var(--status-failed);
  font-size: 0.75rem;
}

.results-table .error-detail pre {
  background: #fef3f2;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  overflow-x: auto;
  margin-top: 0.25rem;
  max-height: 120px;
  overflow-y: auto;
}

.artifact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--c-blue-2);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  transition: background var(--transition);
}

.artifact-link:hover {
  background: rgba(26, 117, 159, 0.08);
  text-decoration: underline;
}

/* ── Tabs ────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--c-blue-2);
}

.tab.active {
  color: var(--c-navy);
  border-bottom-color: var(--c-teal-1);
}

.tab:focus-visible {
  outline: 3px solid var(--c-blue-1);
  outline-offset: -3px;
}

.tab-panel {
  animation: fadeIn 0.25s ease;
}

/* ── Tips & Tops ─────────────────────────────────────────── */

.tips-tops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .tips-tops-grid { grid-template-columns: 1fr; }
}

.tip-item, .top-item {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.tip-item {
  background: #fef9f5;
  border-left: 4px solid var(--status-failed);
}

.tip-item.tip-p0 { border-left-color: var(--status-failed); }
.tip-item.tip-p1 { border-left-color: var(--status-flaky); }
.tip-item.tip-p2 { border-left-color: var(--c-blue-1); }

.top-item {
  background: #f0faf6;
  border-left: 4px solid var(--c-teal-1);
}

.tip-item-header, .top-item-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.tip-priority {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  color: white;
}

.tip-priority-p0 { background: var(--status-failed); }
.tip-priority-p1 { background: var(--status-flaky); color: #333; }
.tip-priority-p2 { background: var(--c-blue-1); }

.tip-category, .top-category {
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: #edf2f7;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tip-item h4, .top-item h4 {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.tip-item p, .top-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tip-action {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 0.78rem;
}

/* ── Breadcrumb ──────────────────────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--c-blue-2);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Run Header ──────────────────────────────────────────── */

.run-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.run-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.run-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.run-meta-label {
  font-weight: 600;
  color: var(--c-blue-3);
}

/* ── Pagination ──────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Loading / Empty States ──────────────────────────────── */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--c-teal-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Footer ──────────────────────────────────────────────── */

.footer {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-up {
  animation: slideUp 0.35s ease;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .page-header h1 { font-size: 1.4rem; }

  .run-card {
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
  }

  .run-card-stats {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .run-card-arrow { display: none; }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .nav-inner { padding: 0 1rem; }
  .container { padding: 0 1rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .radio-group {
    flex-direction: column;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Utility ─────────────────────────────────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
