/* ===========================
   Performance Test Modal
   =========================== */

.perf-modal {
  width: min(820px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Fullscreen Layout ---------- */
.perf-modal.perf-fullscreen {
  width: 98vw;
  height: 94vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  padding: 0;
}

/* ---------- Header ---------- */
.perf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ---------- Body ---------- */
.perf-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Inputs row */
.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
  gap: 12px;
}

.perf-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
}

/* Live section */
.perf-live {
  display: grid;
  gap: 10px;
  position: relative;
}

.perf-progress {
  height: 8px;
  border-radius: 10px;
  background: #eef4ff;
  overflow: hidden;
  border: 1px solid var(--border);
}

.perf-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.perf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

/* Chart container */
.perf-chart-wrap {
  position: relative;
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

/* Tooltip */
.perf-tip {
  position: absolute;
  padding: 6px 8px;
  background: #111;
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -120%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s ease-in-out;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* Summary cards */
.perf-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.perf-summary h4 {
  margin: 0;
}

.perf-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(130px,1fr));
  gap: 10px;
}

.cardlet {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}

.cardlet .k {
  font-size: 12px;
  color: var(--muted);
}

.cardlet .v {
  font-weight: 800;
  font-size: 16px;
}

.perf-table-wrap {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ---------- Footer ---------- */
.perf-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  position: sticky;
  bottom: 0;
}

/* ---------- Badges ---------- */
.badge-ok {
  background: #16a34a;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 800;
  font-size: 12px;
}

.badge-err {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 800;
  font-size: 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .perf-header h3 { font-size: 16px; }
  .perf-grid { grid-template-columns: 1fr; }
}
































/* ===================================================
   Performance Test Dialog — clean fullscreen version
   =================================================== */

.perf-modal {
  width: min(820px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
}

/* --- Fullscreen (fit-to-viewport, no side scroll) --- */
.perf-modal.perf-fullscreen {
  position: fixed;
  inset: 2dvh 2dvw;
  width: 96dvw;
  height: 96dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* --- Header --- */
.perf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(0,0,0,0.06); }

/* --- Body --- */
.perf-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  gap: 10px;
}

.perf-grid label { font-weight: 600; font-size: 14px; display: grid; gap: 4px; }

/* Live section */
.perf-live {
  display: grid;
  gap: 10px;
}
.perf-progress {
  height: 8px;
  background: #eef4ff;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.perf-bar { height: 100%; background: var(--primary); transition: width 0.3s; }
.perf-stats { display:flex; flex-wrap:wrap; gap:14px; font-size:13px; color:var(--muted); }

/* Chart auto height (~40% viewport) */
.perf-chart-wrap {
  height: clamp(240px, 40vh, 480px);
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}
#perfChart { width:100%; height:100%; display:block; }

/* Tooltip */
.perf-tip {
  position:absolute;
  padding:6px 8px;
  background:#111;
  color:#fff;
  border-radius:8px;
  font-size:12px;
  pointer-events:none;
  transform:translate(-50%,-120%);
  opacity:0;
  transition:opacity .1s;
  white-space:nowrap;
  box-shadow:0 4px 14px rgba(0,0,0,.25);
}

/* Summary + Table */
.perf-summary { display:flex; flex-direction:column; gap:10px; }
.perf-summary-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(120px,1fr));
  gap:10px;
}
.cardlet {
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
  background:#fff;
  box-shadow:var(--shadow);
}
.cardlet .k { font-size:12px; color:var(--muted); }
.cardlet .v { font-weight:800; font-size:16px; }

.perf-table-wrap {
  max-height: clamp(150px, 28vh, 300px);
  overflow-y: auto;
  border:1px solid var(--border);
  border-radius:10px;
}

/* --- Footer --- */
.perf-footer {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:10px 18px;
  border-top:1px solid var(--border);
  background:#fff;
}

/* Badges */
.badge-ok { background:#16a34a; color:#fff; border-radius:999px; padding:2px 8px; font-weight:800; font-size:12px; }
.badge-err { background:#ef4444; color:#fff; border-radius:999px; padding:2px 8px; font-weight:800; font-size:12px; }

@media (max-width:600px){
  .perf-grid{ grid-template-columns:1fr; }
}
.perf-modal {
  transition: all 0.25s ease-in-out;
}



/* Runner tweaks */
#apiBaseWrap { transition: opacity .15s; }
.perf-disabled { pointer-events: none; opacity: .6; }




/* --- Fullscreen modal: use full viewport, no extra scroll --- */
.perf-modal.perf-fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;            /* respects mobile browser UI */
  max-height: 100dvh;
  inset: 0;                  /* center -> full-bleed */
  margin: 0;
  border-radius: 10px;
}

/* Remove global dimming when "disabled" (we’ll disable only inputs) */
.perf-modal.perf-disabled {
  opacity: 1;
  filter: none;
  pointer-events: auto;
}

/* Disable only the controls while running */
.perf-modal.perf-running .perf-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Ensure the chart always has height and stays clipped */
#perfChart {
  display: block;
  width: 100%;
  height: 300px;             /* fixed drawing height for sparkline */
}
.perf-chart-wrap {
  overflow: hidden;          /* make sure nothing paints outside */
  border-radius: 8px;
}






















/* Chart wrapper needs a fixed height and positioning for tooltip */
.perf-chart {
  position: relative;
  width: 100%;
  height: 340px;              /* <- pick your height */
  background: #fbfdff;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  overflow: hidden;           /* keeps the line inside */
}

/* Canvas must fill the wrapper — not the page */
.perf-chart > canvas {
  position: absolute;
  inset: 0;                   /* top/right/bottom/left: 0 */
  width: 100%;
  height: 100%;
  display: block;             /* kill inline-canvas baseline gap */
}

/* Tooltip anchors to the wrapper */
.perf-tip {
  position: absolute;
  transform: translate(8px, -28px);
  background: rgba(17,24,39,.9);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
}
