/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --bg:            #f0f4f9;
  --surface:       #ffffff;
  --surface-2:     #f6f9fc;
  --border:        #d1dae8;
  --border-subtle: #e4ebf5;

  --text:   #0d1b2e;
  --text-2: #2b3c52;
  --muted:  #5c6e84;

  --primary:       #0b67d0;
  --primary-hover: #084ea8;
  --primary-tint:  #ddeeff;

  --success:        #166534;
  --success-vivid:  #16a34a;
  --success-bg:     #f0fdf4;
  --success-border: #bbf7d0;

  --warning:        #92400e;
  --warning-vivid:  #d97706;
  --warning-bg:     #fffbeb;
  --warning-border: #fde68a;

  --danger:         #991b1b;
  --danger-vivid:   #dc2626;
  --danger-bg:      #fff5f5;
  --danger-border:  #fecaca;

  --font:      system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  --shadow-sm: 0 1px 3px rgba(13,27,46,0.07), 0 1px 2px rgba(13,27,46,0.04);
  --shadow-md: 0 4px 14px rgba(13,27,46,0.08), 0 1px 4px rgba(13,27,46,0.04);

  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 15px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}
body { min-height: 100vh; }
button, input { font: inherit; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
strong { font-weight: 600; }

/* ── Environment banner ───────────────────────────────────────────────────── */
.env-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: #fef9ee;
  border-bottom: 1px solid #fde68a;
  font-size: 12.5px;
  color: var(--warning);
}
.env-tag {
  display: inline-block;
  padding: 2px 7px;
  background: var(--warning-vivid);
  color: #fff;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Shell ────────────────────────────────────────────────────────────────── */
.shell {
  max-width: 1340px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--primary);
}
h1 { font-size: 28px; margin-bottom: 6px; }
h2 { font-size: 17px; margin-bottom: 4px; }
.subtitle {
  margin: 0;
  max-width: 600px;
  color: var(--muted);
  font-size: 14px;
}
.muted { color: var(--muted); font-size: 13px; }

/* ── Session meta chip ────────────────────────────────────────────────────── */
.session-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 100px;
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  color: var(--success);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.session-meta::before {
  content: '';
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: var(--success-vivid);
  animation: pulse-dot 2.5s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.login-card { max-width: 440px; }

/* ── Login form ───────────────────────────────────────────────────────────── */
.stack {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
label span {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11,103,208,0.12);
}
.actions { display: flex; gap: 10px; align-items: center; }
.actions.wrap { flex-wrap: wrap; }
.message {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
}
.message.error   { color: var(--danger); }
.message.success { color: var(--success-vivid); }

/* ── Controls card ────────────────────────────────────────────────────────── */
.controls-card { margin-bottom: 20px; }

.controls-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.util-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.run-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms, border-color 100ms;
  user-select: none;
}
.button:hover   { background: #e8eef7; border-color: #b8c5d6; }
.button:active  { transform: translateY(1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.button.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.button.ghost:hover {
  background: #e8eef7;
  border-color: var(--border);
  color: var(--text-2);
}

.button.danger-ghost:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.button.small {
  padding: 5px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}
.button.run-btn {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */
.grid.two-col {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  align-items: start;
  min-width: 0;
}

/* ── Catalog card ─────────────────────────────────────────────────────────── */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  min-width: 0;
}
.card-head h2 { margin-bottom: 0; flex-shrink: 0; }

.catalog-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Tests list */
.tests-list-root {
  display: grid;
  gap: 18px;
  min-width: 0;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.category-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.category-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.tests-list, .results-list {
  display: grid;
  gap: 8px;
}

.test-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  background: var(--surface-2);
  transition: border-color 120ms;
  min-width: 0;
  overflow: hidden;
}
.test-item:hover { border-color: var(--border); }

.test-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.test-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
/* Prevent "Lancer" button from shrinking under long test names */
.test-head > .button { flex-shrink: 0; }

.test-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.test-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.test-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* Status badges — prominent */
.badge.status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.01em;
}
.badge.pass { background: var(--success-bg); color: var(--success);  border-color: var(--success-border); }
.badge.fail { background: var(--danger-bg);  color: var(--danger);   border-color: var(--danger-border);  }
.badge.skip { background: var(--warning-bg); color: var(--warning);  border-color: var(--warning-border); }

/* Metadata badges — subtle */
.badge.category { background: var(--primary-tint); color: var(--primary); }
.badge.cleanup  {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border-subtle);
}
.badge.suite {
  background: #f0f4fa;
  color: #3a5170;
  border-color: #dce6f0;
}
.badge.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border-subtle);
}

/* ── Summary panel ────────────────────────────────────────────────────────── */
.summary-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface-2);
}
.summary-panel.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13.5px;
}
.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.stat {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  min-width: 0;
}
.stat-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat[data-stat="passed"] .stat-value { color: var(--success-vivid); }
.stat[data-stat="failed"] .stat-value { color: var(--danger-vivid);  }
.stat-value.mono {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: -0.01em;
}

/* ── Result items ─────────────────────────────────────────────────────────── */
.result-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  background: var(--surface-2);
  min-width: 0;
  overflow: hidden;
}
.result-item[data-status="pass"] {
  border-left: 3px solid var(--success-vivid);
  background: #f7fdfb;
}
.result-item[data-status="fail"] {
  border-left: 3px solid var(--danger-vivid);
  background: #fff7f7;
}
.result-item[data-status="skip"] {
  border-left: 3px solid var(--warning-vivid);
  background: #fffdf5;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
/* Name + description side: takes remaining space, truncates cleanly */
.result-head > div:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.result-head > div:first-child strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-head > div:first-child .muted {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  max-width: 50%;
}

/* ── Code / error blocks ──────────────────────────────────────────────────── */
.result-details, .error-block {
  margin-top: 12px;
  background: #0d1424;
  color: #cdd9e8;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  border: 1px solid #1e2d44;
}
.error-block {
  background: #1a0909;
  color: #f7c8c8;
  border-color: #3d1515;
}

/* ── Running state ────────────────────────────────────────────────────────── */
#panel.is-running .run-btn        { opacity: 0.5; }
#panel.is-running [data-run-test] { opacity: 0.35; pointer-events: none; }

/* Pulse indicator for "Exécution en cours…" */
#panel.is-running .summary-panel .muted {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
#panel.is-running .summary-panel .muted::before {
  content: '';
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: run-pulse 0.9s ease-in-out infinite;
}
@keyframes run-pulse {
  0%, 100% { opacity: 1;    transform: scale(1);    }
  50%       { opacity: 0.3; transform: scale(0.75); }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid.two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .hero,
  .controls-head { flex-direction: column; }
  .util-actions  { flex-wrap: wrap; }

  .test-head { flex-direction: column; gap: 8px; }
  .test-head > .button { align-self: flex-start; }

  .result-head {
    flex-direction: column;
    gap: 8px;
  }
  .result-meta {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .shell     { padding: 20px 16px 40px; }
  h1         { font-size: 24px; }
  .card      { padding: 16px; }
  .run-strip { flex-direction: column; }
  .run-btn   { width: 100%; justify-content: center; }
}
