/* GTmetrix dashboard styles - plain CSS, no framework. */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --grey-bg: #eef0f3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #111827;
  color: #fff;
  flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.subtitle { margin: 4px 0 0; font-size: 12px; color: #9ca3af; }

.topbar-right { display: flex; gap: 10px; }

.chip {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 96px;
}
.chip-label { display: block; font-size: 10px; text-transform: uppercase; color: #9ca3af; letter-spacing: .04em; }
.chip-value { font-size: 16px; font-weight: 600; }

/* -------------------------------------------------------------- controls */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }
.btn-ghost { background: transparent; color: var(--red); border-color: #fca5a5; }

.conc { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.conc input {
  width: 56px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-family: inherit; font-size: 13px;
}
.conc .hint { font-size: 11px; color: #9ca3af; }

.run-status { margin-left: auto; font-size: 13px; color: var(--muted); }

/* -------------------------------------------------------------- progress */
.progress-wrap { padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
.progress-bar { height: 8px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.progress-text { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- banner */
.banner {
  margin: 14px 24px 0;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
}
.banner.info { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* --------------------------------------------------------------- results */
main { padding: 20px 24px 40px; }

table.results {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.results th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 10px 10px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.results td { padding: 10px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
.results tbody tr.result-row:hover { background: #fafbfc; }
.results .num { text-align: right; }
.results .col-expand { width: 28px; }
.results .empty td { text-align: center; color: var(--muted); padding: 28px; }

.expander {
  border: none; background: transparent; cursor: pointer;
  font-size: 12px; color: var(--muted); padding: 2px 6px;
}
.expander:hover { color: var(--text); }

.score {
  display: inline-block; min-width: 38px; text-align: center;
  padding: 3px 8px; border-radius: 4px; font-weight: 600;
}
.score.good { background: var(--green-bg); color: var(--green); }
.score.avg  { background: var(--amber-bg); color: var(--amber); }
.score.bad  { background: var(--red-bg); color: var(--red); }
.score.none { background: var(--grey-bg); color: var(--muted); }

.status-pill {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status-pill.completed { background: var(--green-bg); color: var(--green); }
.status-pill.failed    { background: var(--red-bg); color: var(--red); }
.status-pill.running   { background: #dbeafe; color: #1e40af; }
.status-pill.pending   { background: var(--grey-bg); color: var(--muted); }

.spinner {
  display: inline-block; width: 9px; height: 9px; margin-right: 5px;
  border: 2px solid #93c5fd; border-top-color: #1e40af; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.report-link { color: var(--accent); text-decoration: none; font-size: 12px; }
.report-link:hover { text-decoration: underline; }

.error-text { color: var(--red); font-size: 12px; }

/* ---------------------------------------------------------------- issues */
tr.issues-row > td { padding: 0; background: #fbfcfd; border-bottom: 1px solid var(--border); }
.issues-panel { padding: 14px 18px 18px 44px; }
.issues-panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.issue {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  margin-bottom: 8px;
  overflow: hidden;
}
.issue-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; cursor: pointer;
}
.issue-head:hover { background: #fafbfc; }
.issue-title { font-weight: 600; flex: 1; }
.issue-meta { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 400; }

.impact {
  display: inline-block; min-width: 60px; text-align: center;
  padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.impact.High   { background: var(--red-bg); color: var(--red); }
.impact.Medium { background: var(--amber-bg); color: var(--amber); }
.impact.Low    { background: var(--grey-bg); color: var(--muted); }

.issue-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

.issue-body { padding: 0 12px 12px 12px; border-top: 1px solid #f1f3f5; }
.issue-desc { margin: 10px 0; color: #374151; line-height: 1.5; }
.affected-list {
  margin: 0; padding: 8px 10px; list-style: none;
  background: #f8f9fb; border: 1px solid var(--border); border-radius: 4px;
  max-height: 260px; overflow: auto;
}
.affected-list li {
  font-family: Consolas, "Courier New", monospace;
  font-size: 11.5px; padding: 3px 0; word-break: break-all; color: #374151;
}
.affected-list .savings { color: var(--amber); margin-left: 8px; }
.no-issues { color: var(--muted); font-style: italic; }


/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid #d1d5db;
  background: #fff;
}

.tabs-spacer { flex: 1; }

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  position: relative;
  top: 1px;
}

.tab:hover { color: #111827; background: #f3f4f6; }

.tab.active {
  color: #1d4ed8;
  background: #f9fafb;
  border-color: #d1d5db;
  border-bottom: 2px solid #f9fafb;
}

/* A "!" appears when a tool has unmet prerequisites. */
.tab-note {
  color: #b91c1c;
  font-weight: 700;
  margin-left: 4px;
}

.btn-sm { padding: 5px 11px; font-size: 13px; }

/* Only the active panel is in the document flow. */
.panel { display: none; }
.panel.active { display: block; }

.panel-intro {
  margin: 0;
  padding: 12px 20px 0;
  font-size: 13px;
  color: #4b5563;
  max-width: 900px;
  line-height: 1.5;
}

.panel-intro code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
}

/* Egress state strip above the Lighthouse/PageSpeed tables. */
.egress-strip {
  margin: 10px 20px 0;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
}

.btn-copy {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-copy:hover { background: #f3f4f6; border-color: #9ca3af; }

.shot-none { color: #9ca3af; }

/*
 * The Lighthouse / PageSpeed tables carry 12 columns and their headers are
 * `white-space: nowrap`, so with full category names they can exceed the
 * viewport. Scroll the table inside its own container rather than letting the
 * whole page scroll sideways.
 */
[data-table] { overflow-x: auto; }
[data-table] table.results { min-width: 940px; }
