/* ============================================================
   Padelbot shared styles
   - index.html: public/consumer UI
   - index-dev.html: development/debug UI
   ============================================================ */

:root {
  --pb-blue: #00427A;
  --pb-orange: #d43900;
  --pb-ink: #162033;
  --pb-muted: #667085;
  --pb-border: #d9e2ec;
  --pb-soft: #f5f7fa;
  --pb-card: #ffffff;
  --pb-shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --pb-radius: 18px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--pb-ink);
  background: #ffffff;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ============================================================
   Public UI
   ============================================================ */

.public-ui {
  background:
    radial-gradient(circle at top left, rgba(0, 66, 122, 0.10), transparent 28rem),
    linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  min-height: 100vh;
}

.public-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 52px;
}

.public-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--pb-orange);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.12em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.public-hero h1 {
  color: var(--pb-blue);
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin: 0 0 14px;
}

.hero-copy {
  color: #344054;
  font-size: 18px;
  line-height: 1.55;
  margin: 0;
  max-width: 690px;
}

.hero-card {
  background: var(--pb-card);
  border: 1px solid rgba(0, 66, 122, 0.12);
  border-radius: var(--pb-radius);
  box-shadow: var(--pb-shadow);
  padding: 18px;
}

.hero-card-title {
  color: var(--pb-blue);
  font-size: 15px;
  font-weight: 750;
  margin-bottom: 10px;
}

.hero-card ul {
  margin: 0;
  padding-left: 20px;
  color: #475467;
  line-height: 1.5;
  font-size: 14px;
}

.ask-card {
  background: var(--pb-card);
  border: 1px solid var(--pb-border);
  border-radius: 24px;
  box-shadow: var(--pb-shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.ask-form {
  display: flex;
  gap: 10px;
  margin: 0;
}

.ask-form input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--pb-border);
  border-radius: 15px;
  color: var(--pb-ink);
  background: #ffffff;
  outline: none;
  padding: 15px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ask-form input[type="text"]:focus {
  border-color: rgba(0, 66, 122, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 66, 122, 0.10);
}

.ask-form button,
.primary-btn {
  border: 1px solid var(--pb-orange);
  border-radius: 15px;
  background: var(--pb-orange);
  color: #ffffff;
  font-weight: 750;
  padding: 14px 20px;
}

.examples-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.example-chip {
  border: 1px solid rgba(0, 66, 122, 0.16);
  background: #f8fbff;
  color: var(--pb-blue);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.example-chip:hover {
  background: #edf5ff;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  margin-top: 12px;
}

.loading-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--pb-muted);
  font-size: 14px;
}

.loading-indicator.visible {
  display: inline-flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0, 66, 122, 0.18);
  border-top-color: var(--pb-blue);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  color: #b42318;
  font-size: 14px;
}

.results-grid {
  display: grid;
  gap: 18px;
}

.result-card {
  background: var(--pb-card);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-radius);
  box-shadow: var(--pb-shadow);
  overflow: hidden;
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--pb-border);
}

.result-card h2 {
  color: var(--pb-blue);
  font-size: 17px;
  margin: 0;
}

.result-card-subtitle {
  color: var(--pb-muted);
  font-size: 13px;
}

.result-card-body {
  padding: 18px;
}

.table-scroll {
  overflow: auto;
  width: 100%;
}

.answer-content {
  line-height: 1.62;
  color: #26364b;
}

.answer-content p {
  margin: 0 0 12px;
}

.answer-content .analysis-block {
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
  line-height: 1.62;
}

.answer-content h3 {
  margin: 14px 0 8px;
  color: var(--pb-blue);
  font-size: 15px;
}

.answer-content ul {
  margin-top: 8px;
  padding-left: 22px;
}

.stats-inline {
  margin-bottom: 16px;
}

.sources-line {
  border-top: 1px solid var(--pb-border);
  margin-top: 16px;
  padding-top: 12px;
  color: var(--pb-muted);
  font-size: 13px;
}

.sources-line a {
  color: var(--pb-blue);
  font-weight: 650;
  text-decoration: none;
}

.sources-line a:hover {
  text-decoration: underline;
}

/* ============================================================
   Tables
   ============================================================ */

table.data {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  overflow: hidden;
}

table.data th,
table.data td {
  border-bottom: 1px solid var(--pb-border);
  padding: 9px 11px;
  font-size: 12px;
  text-align: center;
  vertical-align: middle;
}

table.data th {
  color: #ffffff;
  background: var(--pb-blue);
  font-weight: 750;
  white-space: pre-line;
}

table.data th:first-child,
table.data td:first-child,
table.data th:last-child,
table.data td:last-child {
  text-align: left;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data th.sort-col,
table.data td.sort-col {
  background: var(--pb-orange) !important;
  color: #ffffff !important;
}

/* ============================================================
   Disambiguation
   ============================================================ */

.disambig-panel {
  display: none;
  background: #fff8f5;
  border: 1px solid rgba(212, 57, 0, 0.28);
  border-radius: 16px;
  padding: 14px;
  margin-top: 14px;
}

.disambig-title {
  color: var(--pb-blue);
  font-weight: 800;
  margin-bottom: 6px;
}

.disambig-hint {
  color: #667085;
  font-size: 13px;
  margin-bottom: 10px;
}

.disambig-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.disambig-row label {
  color: #344054;
  font-size: 14px;
}

.disambig-row select {
  margin-left: 6px;
  border: 1px solid var(--pb-border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #ffffff;
}

.disambig-row button {
  border: 1px solid var(--pb-blue);
  border-radius: 10px;
  background: var(--pb-blue);
  color: white;
  padding: 9px 12px;
}

.disambig-row .secondary-btn {
  background: #ffffff;
  color: var(--pb-blue);
}

/* ============================================================
   Development UI
   ============================================================ */

.dev-ui {
  background: #ffffff;
  color: #000000;
}

.dev-wrap {
  max-width: 1050px;
  margin: 32px auto;
  padding: 0 16px;
}

.dev-wrap h1 {
  font-size: 22px;
  margin: 0 0 16px;
  color: var(--pb-blue);
}

.dev-wrap h2 {
  font-size: 16px;
  margin: 24px 0 8px;
  color: var(--pb-blue);
}

.dev-note {
  color: #667085;
  font-size: 13px;
  margin: 6px 0 14px;
}

.dev-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dev-ui pre,
.dev-pre {
  background: #ffffff;
  border: 1px solid #2a3355;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  max-height: 42vh;
  white-space: pre-wrap;
}

.dev-ui .ask-form {
  margin-bottom: 16px;
}

.dev-ui .ask-form input[type="text"] {
  background: #eeeeee;
  color: var(--pb-orange);
}

.dev-ui .disambig-panel {
  background: #ffffff;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 760px) {
  .public-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 22px;
  }

  .public-hero {
    grid-template-columns: 1fr;
  }

  .hero-card {
    display: none;
  }

  .ask-form {
    flex-direction: column;
  }

  .ask-form button {
    width: 100%;
  }

  .result-card-header {
    display: block;
  }

  .result-card-subtitle {
    display: block;
    margin-top: 4px;
  }

  .dev-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   v106 — Accessible multi-level sort hierarchy
   ============================================================ */

/* Single-level sorts keep the existing orange treatment above.
   Multi-level sorts stay in the same Padelbot orange family.  Level 1
   starts with the standard --pb-orange; deeper levels progressively
   darken while preserving strong white-text contrast.  The visible
   numbered badge remains the authoritative hierarchy cue; color is
   only a supporting cue, so the design does not depend on color alone. */
table.data.multi-sort th.sort-col,
table.data.multi-sort td.sort-col {
  background: #9a2400 !important; /* safe fallback for levels > 6 */
  color: #ffffff !important;
}

table.data.multi-sort th.sort-col[data-sort-level="1"],
table.data.multi-sort td.sort-col[data-sort-level="1"] {
  background: var(--pb-orange) !important;
}

table.data.multi-sort th.sort-col[data-sort-level="2"],
table.data.multi-sort td.sort-col[data-sort-level="2"] {
  background: #c93400 !important;
}

table.data.multi-sort th.sort-col[data-sort-level="3"],
table.data.multi-sort td.sort-col[data-sort-level="3"] {
  background: #bd3000 !important;
}

table.data.multi-sort th.sort-col[data-sort-level="4"],
table.data.multi-sort td.sort-col[data-sort-level="4"] {
  background: #b12c00 !important;
}

table.data.multi-sort th.sort-col[data-sort-level="5"],
table.data.multi-sort td.sort-col[data-sort-level="5"] {
  background: #a62800 !important;
}

table.data.multi-sort th.sort-col[data-sort-level="6"],
table.data.multi-sort td.sort-col[data-sort-level="6"] {
  background: #9a2400 !important;
}

/* Keep the sort-order marker large enough to read comfortably.  The
   numeral is approximately normal header-text size, inside a badge
   almost twice that height; it is intentionally not a superscript. */
table.data th .sort-order-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32em;
  margin-left: 0.45em;
  white-space: nowrap;
  vertical-align: middle;
}

table.data th .sort-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 2.1em;
  height: 2.1em;
  padding: 0 0.32em;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #ffffff;
  color: var(--pb-orange);
  font-size: 1.15em;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

table.data th .sort-dir-arrow {
  display: inline-block;
  color: #ffffff;
  font-size: 1.28em;
  font-weight: 900;
  line-height: 1;
}

/* ============================================================
   v115 — Query spelling feedback
   ============================================================ */
.spellcheck-notice {
  margin: 8px 0 14px;
  padding: 9px 12px;
  border-left: 4px solid var(--pb-orange);
  border-radius: 6px;
  background: #fff5ef;
  color: #4a220f;
  font-size: 0.98rem;
  line-height: 1.45;
}

.spellcheck-notice[hidden] {
  display: none !important;
}

.spellcheck-original {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--pb-orange);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  font-weight: 650;
}

.spellcheck-correction {
  color: #8f2700;
  font-weight: 800;
}

.spellcheck-suggestion {
  display: inline;
  margin: 0 0.2em;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8f2700;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.spellcheck-suggestion:hover,
.spellcheck-suggestion:focus-visible {
  color: var(--pb-blue);
}


/* ============================================================
   v129 — Shared performance radar chart styles
   Promoted from consumer index.html so public and dev UIs render
   the shared padelbot.js chart component consistently.
   ============================================================ */

/* Optional 5-metric performance radar chart. Rendered only for 1- or 2-racket tables. */
    .performance-chart.hidden,
    .performance-chart-panel.hidden {
      display: none;
    }

    .performance-chart {
      margin-top: 12px;
      border-top: 1px solid rgba(148, 163, 184, 0.22);
      padding-top: 12px;
    }

    .performance-chart-toggle-row {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      gap: 8px;
      margin-bottom: 10px;
    }

    .performance-chart-toggle {
      border: 1px solid rgba(37, 99, 235, 0.25);
      border-radius: 999px;
      background: rgba(239, 246, 255, 0.95);
      color: #1d4ed8;
      cursor: pointer;
      font: inherit;
      font-size: 0.9rem;
      font-weight: 650;
      line-height: 1.2;
      padding: 7px 11px;
      box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
      transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    }

    .performance-chart-toggle:hover,
    .performance-chart-toggle[aria-expanded="true"] {
      border-color: rgba(37, 99, 235, 0.45);
      box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
      transform: translateY(-1px);
    }

    .performance-chart-panel {
      border: 1px solid rgba(148, 163, 184, 0.22);
      border-radius: 16px;
      background: rgba(248, 250, 252, 0.72);
      padding: 12px;
    }

    .performance-chart-controls {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      gap: 8px 10px;
      margin: 2px 0 10px;
    }

    .performance-chart-select-label {
      color: #475569;
      font-size: 0.88rem;
      font-weight: 700;
    }

    .performance-chart-select {
      max-width: min(100%, 360px);
      border: 1px solid rgba(148, 163, 184, 0.45);
      border-radius: 999px;
      background: white;
      color: #0f172a;
      font: inherit;
      font-size: 0.9rem;
      line-height: 1.2;
      padding: 7px 32px 7px 11px;
    }

    .performance-chart-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 10px 14px;
      align-items: center;
      justify-content: center;
      margin-bottom: 6px;
      color: #334155;
      font-size: 0.9rem;
      font-weight: 650;
    }

    .performance-chart-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
    }

    .performance-chart-swatch {
      width: 11px;
      height: 11px;
      border-radius: 999px;
      flex: 0 0 auto;
    }

    .performance-chart-graphic-wrap {
      display: flex;
      justify-content: center;
      overflow-x: auto;
    }

    .performance-chart-svg {
      width: min(100%, 430px);
      height: auto;
      overflow: visible;
    }

    .performance-chart-ring {
      fill: none;
      stroke: rgba(148, 163, 184, 0.38);
      stroke-width: 1;
    }

    .performance-chart-axis {
      stroke: rgba(148, 163, 184, 0.44);
      stroke-width: 1;
    }

    .performance-chart-axis-label {
      fill: #334155;
      font-size: 11px;
      font-weight: 700;
    }

    .performance-chart-ring-label {
      fill: #94a3b8;
      font-size: 9px;
      dominant-baseline: middle;
    }

    .performance-chart-polygon {
      vector-effect: non-scaling-stroke;
    }

    .performance-chart-point {
      stroke: white;
      stroke-width: 1.2;
    }

    .performance-chart-caption {
      margin: 8px 0 0;
      color: #64748b;
      font-size: 0.88rem;
      line-height: 1.35;
      text-align: center;
    }
