/* ============================================================
   Load Test Manager — design tokens
   Sidebar stays a constant deep-ink brand surface; the content
   area is what switches between light/dark, since that's the
   part people stare at while reading metrics.
   ============================================================ */

:root {
  --sidebar-bg: #10131C;
  --sidebar-border: #20263A;
  --sidebar-text: #B8BEDA;
  --sidebar-text-dim: #6A7194;
  --sidebar-active-bg: #1B2036;

  --accent: #4C56E0;
  --accent-hover: #3C46CC;
  --accent-ink: #FFFFFF;

  --font-ui: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --surface-alt: #EFF1F6;
  --border: #E2E4EE;
  --text: #14171F;
  --text-muted: #656B7D;
  --code-bg: #F3F4F9;
  --code-text: #2B2F3B;
  --success-bg: #E3F5EA; --success-text: #187A43; --success-border: #B9E6C9;
  --warn-bg: #FFF4DE; --warn-text: #8A5A00; --warn-border: #F3DBA0;
  --danger-bg: #FDEAEA; --danger-text: #B3261E; --danger-border: #F4C6C3;
  --shadow: 0 1px 2px rgba(20, 23, 31, 0.06), 0 8px 24px -12px rgba(20, 23, 31, 0.12);
}

html[data-theme="dark"] {
  --bg: #0B0D14;
  --surface: #12151F;
  --surface-alt: #171B28;
  --border: #262C3D;
  --text: #E7E9F2;
  --text-muted: #8B92AA;
  --code-bg: #0E111A;
  --code-text: #C8CCDC;
  --success-bg: #10301F; --success-text: #5FD68E; --success-border: #1E4A30;
  --warn-bg: #362A0C; --warn-text: #F0B429; --warn-border: #4E3D12;
  --danger-bg: #351515; --danger-text: #FF7A7A; --danger-border: #4E1F1F;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

.shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8A6FF0);
  color: white; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.3px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { color: #F2F3FA; font-weight: 700; font-size: 14px; }
.brand-sub { color: var(--sidebar-text-dim); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-icon { font-size: 13px; width: 16px; text-align: center; opacity: 0.85; }
.nav-item:hover { background: var(--sidebar-active-bg); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

.sidebar-footer { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 14px; }
.k6-warning, .mock-warning {
  font-size: 11px; color: #F0B429; background: #362A0C;
  border: 1px solid #4E3D12; border-radius: 8px; padding: 8px 10px; line-height: 1.4;
}
.mock-warning { color: #8B92AA; background: #171B28; border-color: #262C3D; }

.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--sidebar-active-bg); border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text); border-radius: 8px; padding: 8px 10px;
  cursor: pointer; font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
}
.theme-toggle:hover { color: #fff; }
html[data-theme="light"] .tt-icon-dark,
html[data-theme="dark"] .tt-icon-light { display: none; }

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; background: var(--sidebar-active-bg);
  border: 1px solid var(--sidebar-border);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8A6FF0); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.user-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-name { color: #F2F3FA; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-text-dim); font-size: 10.5px; }

/* ---------------- Main ---------------- */
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px 0;
}
.page-title { font-size: 21px; font-weight: 800; margin: 0; letter-spacing: -0.2px; }
.content { padding: 20px 32px 48px; }

/* ---------------- Flash messages ---------------- */
.flash-stack { padding: 0 32px; display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

/* ---------------- Cards / surfaces ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin: 0 0 14px; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------------- Stat tiles ---------------- */
.stat-tile { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -0.5px; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-family: var(--font-ui);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger-text); }
.btn-danger:hover { border-color: var(--danger-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------------- Tables ---------------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.2px;
}
.badge-common { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-project { background: rgba(76, 86, 224, 0.12); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input[type=text], input[type=url], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-alt); color: var(--text); font-family: var(--font-ui); font-size: 13.5px;
}
textarea.code-input {
  font-family: var(--font-mono); font-size: 12.5px; min-height: 340px; background: var(--code-bg);
  color: var(--code-text); line-height: 1.6; white-space: pre; resize: vertical;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ---------------- Code block (readonly display) ---------------- */
pre.code-block {
  background: var(--code-bg); color: var(--code-text); font-family: var(--font-mono);
  font-size: 12.5px; padding: 16px; border-radius: 10px; overflow-x: auto;
  border: 1px solid var(--border); line-height: 1.6; max-height: 480px;
}

/* ---------------- Metric grid on result page ---------------- */
.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 1000px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
.metric-tile {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; text-align: left;
}
.metric-tile .m-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); font-weight: 700; }
.metric-tile .m-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-top: 4px; }

/* ---------------- Use case list ---------------- */
.usecase-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface-alt); }
.usecase-title { font-weight: 700; font-size: 13.5px; }
.usecase-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ---------------- Team pills ---------------- */
.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
.team-pill { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-alt); }
.team-role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); font-weight: 700; }
.team-name { font-size: 14px; font-weight: 700; margin-top: 4px; }
.team-name.empty { color: var(--text-muted); font-weight: 500; font-style: italic; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-header h2 { font-size: 16px; margin: 0; font-weight: 800; }

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Run overlay (loading state) ---------------- */
.run-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 20, 0.72);
  display: none; align-items: center; justify-content: center; z-index: 999;
  backdrop-filter: blur(2px);
}
.run-overlay.active { display: flex; }
.run-overlay-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px 36px; text-align: center; max-width: 380px; box-shadow: var(--shadow);
}
.spinner {
  width: 40px; height: 40px; margin: 0 auto 18px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.run-overlay-title { font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.run-overlay-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.run-overlay-card-live { max-width: 640px; width: 90vw; text-align: left; }
.run-overlay-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.spinner-sm { width: 24px; height: 24px; margin: 0; flex-shrink: 0; }
.live-output {
  max-height: 340px; overflow-y: auto; font-size: 11.5px; margin: 0;
  background: var(--code-bg); white-space: pre-wrap; word-break: break-word;
}

.link-row { display: flex; gap: 8px; }
