/* ============================================================
   Fonts
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================================
   CSS Variables
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-root:       #09091a;
  --bg-primary:    #0b0b1e;
  --bg-secondary:  #0f0f28;
  --bg-tertiary:   #151533;
  --bg-card:       #111128;

  /* Text */
  --text-primary:   #eef0ff;
  --text-secondary: #8892b0;
  --text-muted:     #4a5270;

  /* Borders */
  --border:        #1c1e40;
  --border-light:  #252850;

  /* Status colours */
  --pass:       #0df5c4;
  --pass-dim:   #09b890;
  --pass-bg:    rgba(13, 245, 196, 0.08);

  --fail:       #ff4d6a;
  --fail-dim:   #c73050;
  --fail-bg:    rgba(255, 77, 106, 0.08);

  --skip:       #ffb547;
  --skip-bg:    rgba(255, 181, 71, 0.08);

  --broken:     #bf7fff;
  --broken-bg:  rgba(191, 127, 255, 0.08);

  --info:       #4cc9f0;
  --info-bg:    rgba(76, 201, 240, 0.08);

  /* Accent gradient */
  --accent:       #4cc9f0;
  --accent-2:     #7b35ff;
  --grad-accent:  linear-gradient(135deg, #4cc9f0 0%, #7b35ff 100%);
  --grad-pass:    linear-gradient(90deg, #0df5c4, #4cc9f0);
  --grad-fail:    linear-gradient(90deg, #ff4d6a, #ff8566);

  /* Shadows / glows */
  --glow-cyan:    0 0 20px rgba(76, 201, 240, 0.15);
  --glow-pass:    0 0 16px rgba(13, 245, 196, 0.2);
  --shadow-card:  0 4px 24px rgba(0, 0, 0, 0.5);

  --radius:    8px;
  --radius-lg: 14px;
}

/* ============================================================
   WIP Banner
   ============================================================ */
.wip-banner {
  background: repeating-linear-gradient(
    -45deg,
    #1a1200,
    #1a1200 12px,
    #221800 12px,
    #221800 24px
  );
  border-bottom: 2px solid var(--skip);
  color: var(--skip);
  text-align: center;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 101;
  box-shadow: 0 2px 12px rgba(255, 181, 71, 0.15);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  /* subtle star-field noise */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(76,201,240,0.06) 0%, transparent 70%);
}

/* ============================================================
   Header
   ============================================================ */
.header {
  background: rgba(11, 11, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 42px;
  z-index: 100;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-logo {
  font-size: 22px;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(76,201,240,0.5));
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.last-updated {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 0 14px rgba(76, 201, 240, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 0 24px rgba(76, 201, 240, 0.4);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-demo {
  background: var(--bg-tertiary);
  color: var(--pass);
  border: 1px solid rgba(13, 245, 196, 0.3);
}
.btn-demo:hover {
  background: var(--pass-bg);
  border-color: var(--pass);
  box-shadow: 0 0 12px rgba(13, 245, 196, 0.15);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

/* ============================================================
   Config Panel
   ============================================================ */
.config-panel {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.config-panel.hidden { display: none; }

.config-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 24px;
}

.config-inner h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
  color: var(--text-primary);
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 680px) { .config-grid { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.1);
}

.form-group small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.form-group small strong { color: var(--text-secondary); }

.config-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.config-note {
  font-size: 12px;
  color: var(--text-muted);
  padding: 11px 15px;
  background: rgba(76, 201, 240, 0.04);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  line-height: 1.6;
}
.config-note strong { color: var(--text-secondary); }
.config-note a { color: var(--accent); text-decoration: none; }
.config-note a:hover { text-decoration: underline; }

/* ============================================================
   Modal
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 20, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-card), var(--glow-cyan);
}
.modal-content h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.modal-content p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.6;
}
.modal-content em { color: var(--accent); font-style: normal; }
.modal-content pre {
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 12px;
  overflow-x: auto;
  margin-bottom: 22px;
  color: var(--pass);
  line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 26, 0.85);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.loading-overlay.hidden { display: none; }

.loader {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  box-shadow: 0 0 16px rgba(76, 201, 240, 0.3);
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 110px 24px;
}
.empty-icon {
  font-size: 56px;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 16px rgba(76,201,240,0.3));
}
.empty-state h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.empty-state p {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

/* ============================================================
   Sections  — coloured top-border accent
   ============================================================ */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
}

/* Top accent bar via pseudo-element */
.section::before {
  content: '';
  display: block;
  height: 2px;
  width: 100%;
  background: var(--grad-accent);
}

/* Override per-section: Failing = red, Core = purple */
.section.section-failing::before {
  background: var(--grad-fail);
}
.section.section-core::before {
  background: linear-gradient(90deg, #bf7fff, #7b35ff);
}

.section-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 54px;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.tag-label {
  background: rgba(191, 127, 255, 0.12);
  color: var(--broken);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  border: 1px solid rgba(191, 127, 255, 0.2);
}

.section-controls {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-fail { background: var(--fail-bg); color: var(--fail); border: 1px solid rgba(255,77,106,0.2); }
.badge-pass { background: var(--pass-bg); color: var(--pass); border: 1px solid rgba(13,245,196,0.2); }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(76,201,240,0.2); }

/* ============================================================
   Environment Summary Grid
   ============================================================ */
.env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  padding: 22px;
}

.env-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.env-card::after {
  /* subtle inner top glow */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(180deg, rgba(76,201,240,0.05) 0%, transparent 100%);
  pointer-events: none;
}
.env-card:hover {
  box-shadow: var(--glow-cyan);
  transform: translateY(-1px);
}
.env-card.has-error { border-top-color: var(--fail); }
.env-card.has-error::after {
  background: linear-gradient(180deg, rgba(255,77,106,0.06) 0%, transparent 100%);
}

.env-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 18px;
}
.env-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}
.env-card.has-error .env-dot {
  background: var(--fail);
  box-shadow: 0 0 6px var(--fail);
}

.env-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-total  .stat-value { color: var(--text-primary); }
.stat-passed .stat-value { color: var(--pass);  text-shadow: 0 0 12px rgba(13,245,196,0.4); }
.stat-failed .stat-value { color: var(--fail);  text-shadow: 0 0 12px rgba(255,77,106,0.4); }
.stat-skip   .stat-value { color: var(--skip);  text-shadow: 0 0 12px rgba(255,181,71,0.3); }

.pass-rate-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.fill-high   { background: var(--grad-pass); box-shadow: 0 0 8px rgba(13,245,196,0.5); }
.fill-medium { background: linear-gradient(90deg, #ffb547, #ff8c42); }
.fill-low    { background: var(--grad-fail); box-shadow: 0 0 8px rgba(255,77,106,0.4); }

.env-file-count {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* ============================================================
   Two-column Layout
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ============================================================
   Environment Tabs
   ============================================================ */
.env-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-x: auto;
  scrollbar-width: none;
}
.env-tabs::-webkit-scrollbar { display: none; }

.env-tab {
  padding: 5px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}
.env-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}
.env-tab.active {
  color: var(--accent);
  background: var(--info-bg);
  border-color: rgba(76, 201, 240, 0.2);
}

/* ============================================================
   Data Tables
   ============================================================ */
.table-container { overflow-x: auto; min-height: 80px; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table thead th {
  padding: 11px 18px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(76, 201, 240, 0.03); }

.data-table tbody td {
  padding: 11px 18px;
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Test name cell */
.cell-name { max-width: 260px; }
.test-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  letter-spacing: -0.01em;
}
.test-name:hover { white-space: normal; overflow: visible; word-break: break-word; }

.test-suite {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Env tag */
.env-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  background: var(--info-bg);
  color: var(--info);
  white-space: nowrap;
  border: 1px solid rgba(76,201,240,0.15);
  letter-spacing: 0.02em;
}

/* Error cell */
.error-cell { max-width: 220px; }
.error-msg {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.error-msg:hover { white-space: normal; overflow: visible; word-break: break-all; }

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.status-pill::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-pill.passed  { background: var(--pass-bg);   color: var(--pass);   border: 1px solid rgba(13,245,196,0.2); }
.status-pill.passed::before  { background: var(--pass);   box-shadow: 0 0 5px var(--pass); }
.status-pill.failed  { background: var(--fail-bg);   color: var(--fail);   border: 1px solid rgba(255,77,106,0.2); }
.status-pill.failed::before  { background: var(--fail);   box-shadow: 0 0 5px var(--fail); }
.status-pill.broken  { background: var(--broken-bg); color: var(--broken); border: 1px solid rgba(191,127,255,0.2); }
.status-pill.broken::before  { background: var(--broken); box-shadow: 0 0 5px var(--broken); }
.status-pill.skipped { background: var(--skip-bg);   color: var(--skip);   border: 1px solid rgba(255,181,71,0.2); }
.status-pill.skipped::before { background: var(--skip);   box-shadow: 0 0 5px var(--skip); }

/* Duration */
.duration {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Table empty state */
.table-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   Search & Filter Controls
   ============================================================ */
.search-input,
.select-input {
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 6px 11px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus,
.select-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.1);
}
.search-input { width: 150px; }
.select-input option { background: var(--bg-secondary); }

/* ============================================================
   Inline Error Card
   ============================================================ */
.error-inline {
  background: rgba(255, 77, 106, 0.07);
  border: 1px solid rgba(255, 77, 106, 0.25);
  border-radius: var(--radius);
  padding: 11px 15px;
  color: var(--fail);
  font-size: 12px;
  line-height: 1.5;
}

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