/* =============================================================================
   PROBLEMS — /problems and /problems/design-fix (templates/problems.html):
   tabs, filters, a paginated table and pagination. The table, pills and
   buttons are the dashboard's (css/shared/dashboard.css: .dash-card,
   .dash-table, .dash-pill, .dash-btn); this file only lays them out.
   PRISM theme tokens (--pt-*) for light / dark, sizes from --t-*.
============================================================================= */
/* The page scrolls (the shared base locks body scrolling for the canvas), and
   uses the app font, Inter, like the canvas, not the theme's IBM Plex Sans. */
.prism-theme body.page-problems { overflow: auto !important; height: auto !important; }
body.page-problems { --pb-font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif; font-family: var(--pb-font) !important; }
body.page-problems .an-toolbar, body.page-problems .pb, body.page-problems .pb button, body.page-problems .pb input { font-family: var(--pb-font); }

.pb {
  position: relative;
  z-index: 1;
  overflow-x: clip; /* the header glow bleeds past the edges */
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  color: var(--pt-text);
}
.pb .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Header: same scale as the dashboard header (.dash-title / .dash-sub). */
.pb-head { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
/* A soft blue glow drifting behind the header. */
.pb-head::before {
  content: ''; position: absolute; z-index: -1; inset: -60px -40px -30px -80px; pointer-events: none;
  background:
    radial-gradient(320px 160px at 18% 40%, color-mix(in srgb, #3b82f6 18%, transparent), transparent 70%),
    radial-gradient(260px 140px at 62% 10%, color-mix(in srgb, #06b6d4 14%, transparent), transparent 70%);
  filter: blur(8px);
  animation: pb-drift 14s ease-in-out infinite alternate;
}
@keyframes pb-drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(40px, 12px, 0); } }
.pb-heading { animation: pb-rise 0.4s ease-out both; }
.pb-sub { animation: pb-rise 0.45s ease-out 0.05s both; }
.pb-build { animation: pb-rise 0.5s ease-out 0.1s both; }
.pb-heading { margin: 0; font-size: var(--t-display); font-weight: 700; line-height: 1.2; color: var(--pt-text); }
.pb-sub { margin: 8px 0 0; max-width: 640px; font-size: var(--t-heading); font-weight: 500; line-height: 1.55; color: var(--pt-text-2); }

/* Build & Test card (header, right) */
.pb-build {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  max-width: 420px; padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--pt-accent) 35%, var(--pt-border));
  border-radius: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, #3b82f6 12%, transparent), color-mix(in srgb, #06b6d4 8%, transparent)),
    var(--pt-surface);
  color: var(--pt-text); text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 24px -14px color-mix(in srgb, var(--pt-accent) 60%, transparent);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.pb-build:hover {
  transform: translateY(-2px);
  border-color: var(--pt-accent);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08), 0 18px 34px -16px color-mix(in srgb, var(--pt-accent) 70%, transparent);
}
.pb-build:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: 3px; }
.pb-build-icon {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #ffffff;
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--pt-accent) 80%, transparent);
}
.pb-build-text { display: grid; gap: 2px; min-width: 0; }
.pb-build-title { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-subtitle); font-weight: 700; color: var(--pt-text); }
.pb-build-sub { font-size: var(--t-body); font-weight: 500; color: var(--pt-text-2); }
.pb-build-arrow { flex: none; margin-left: auto; color: var(--pt-accent); transition: transform 0.18s ease; }
.pb-build:hover .pb-build-arrow { transform: translateX(3px); }
.pb-pro-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: var(--t-micro); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #b45309; background: #fffbeb; border: 1px solid #fcd34d;
}
html[data-theme="dark"] .pb-pro-badge, html:not([data-theme="light"]) .pb-pro-badge { color: #fde68a; background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.45); }
html[data-theme="light"] .pb-pro-badge { color: #b45309; background: #fffbeb; border-color: #fcd34d; }

/* Tabs: a segmented control. The open tab is a raised card (shadow, blue
   count); the other sits flat in the track, so which list you're on is clear. */
.pb-tabs {
  display: inline-flex; gap: 4px; margin-top: 22px; padding: 4px;
  border-radius: 14px; border: 1px solid var(--pt-border);
  background: color-mix(in srgb, var(--pt-surface-2) 80%, transparent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}
.pb-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: var(--t-heading); font-weight: 600; color: var(--pt-text-3); text-decoration: none;
}
.pb-tab:hover { color: var(--pt-text); background: color-mix(in srgb, var(--pt-surface) 55%, transparent); }
.pb-tab.is-active {
  color: var(--pt-text); background: var(--pt-surface);
  border-color: color-mix(in srgb, var(--pt-accent) 30%, var(--pt-border));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 16px -6px color-mix(in srgb, var(--pt-accent) 45%, transparent);
  animation: pb-tab-in 0.25s ease-out both;
}
@keyframes pb-tab-in { from { transform: scale(0.97); opacity: 0.7; } }
.pb-count {
  min-width: 26px; text-align: center; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--pt-text-3) 14%, transparent); color: var(--pt-text-3);
  font-size: var(--t-caption); font-weight: 700; font-variant-numeric: tabular-nums;
}
.pb-tab.is-active .pb-count { background: var(--pt-accent); color: #0b1220; }

/* Filters */
.pb-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.pb-search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-surface);
  color: var(--pt-text-3);
}
.pb-search:focus-within { border-color: var(--pt-accent); }
.pb-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: var(--t-body); color: var(--pt-text);
}
.pb-seg { display: inline-flex; padding: 3px; border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-surface); }
.pb-seg-item { position: relative; cursor: pointer; }
.pb-seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.pb-seg-item span {
  display: block; padding: 6px 12px; border-radius: 7px;
  font-size: var(--t-body); font-weight: 600; color: var(--pt-text-2);
}
.pb-seg-item:hover span { color: var(--pt-text); }
.pb-seg-item.is-on span { background: var(--pt-surface-2); color: var(--pt-text); }
.pb-seg-item input:focus-visible + span { outline: 2px solid var(--pt-accent); outline-offset: 1px; }
.pb-select { position: relative; }
.pb-select select {
  height: 40px; padding: 0 32px 0 12px;
  border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-surface);
  font: inherit; font-size: var(--t-small); color: var(--pt-text); cursor: pointer;
}
.pb-select select:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: 1px; }

/* Custom dropdown (problems.js): the native select stays in the form, hidden. */
.pb-select .pb-dd-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pb-dd-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
  min-width: 170px; height: 40px; padding: 0 12px;
  border: 1px solid var(--pt-border); border-radius: 10px; background: var(--pt-surface);
  font: inherit; font-size: var(--t-body); font-weight: 600; color: var(--pt-text-2); cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.pb-dd-trigger.has-value { color: var(--pt-text); }
.pb-dd-trigger svg { flex: none; color: var(--pt-text-3); transition: transform 0.18s ease; }
.pb-dd-trigger:hover { border-color: color-mix(in srgb, var(--pt-accent) 55%, var(--pt-border)); box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--pt-accent) 50%, transparent); }
.pb-dd-trigger:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: 1px; }
.pb-select.is-open .pb-dd-trigger { border-color: var(--pt-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pt-accent) 18%, transparent); }
.pb-select.is-open .pb-dd-trigger svg { transform: rotate(180deg); }
.pb-dd-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0;
  min-width: 100%; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none;
  border: 1px solid var(--pt-border); border-radius: 12px; background: var(--pt-surface);
  box-shadow: 0 16px 40px -12px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.06);
  animation: pb-pop 0.16s ease-out;
}
.pb-dd-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 8px;
  font-size: var(--t-body); font-weight: 500; color: var(--pt-text); white-space: nowrap; cursor: pointer;
}
.pb-dd-option:hover, .pb-dd-option:focus { outline: none; background: var(--pt-surface-2); }
.pb-dd-option[aria-selected="true"] { color: var(--pt-accent); font-weight: 600; background: color-mix(in srgb, var(--pt-accent) 10%, transparent); }

/* Results */
.pb-results { margin-top: 18px; transition: opacity 0.15s ease; }
html.pb-personalizing .pb-results, .pb-results.is-loading { opacity: 0.35; pointer-events: none; }
/* Once the list filters in the browser, rows just appear: no entry animation. */
.pb-results.pb-live .pb-table tbody tr, .pb-results.pb-live .pb-status--solved svg { animation: none; }
button.pb-page { font-family: inherit; cursor: pointer; }
/* Search and filters: rows that come into view fade and slide in (problems.js). */
.pb-results.pb-live .pb-table tbody tr.pb-row-in,
.pb-results .pb-empty.pb-row-in { animation: pb-row-in 0.32s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms) both; }
@keyframes pb-row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pb-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 18px 0 10px; font-size: var(--t-body); font-weight: 500; color: var(--pt-text-2);
}
.pb-progress { display: inline-flex; align-items: center; gap: 10px; }
.pb-progress-bar { width: 120px; height: 6px; border-radius: 999px; background: var(--pt-surface-2); overflow: hidden; }
.pb-progress-bar > i {
  display: block; height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  animation: pb-grow 0.9s cubic-bezier(.2, .7, .2, 1) 0.2s both;
}
@keyframes pb-grow { from { width: 0; } }
.pb-summary strong { color: var(--pt-text); font-weight: 600; }

/* Design & Fix: an unsolved incident is "live" (pulsing red dot). */
.pb-status--live { width: 18px; height: 18px; display: inline-grid; place-items: center; }
.pb-live-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--dash-low); }
.pb-live-dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--dash-low); opacity: 0;
  animation: pb-ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes pb-ping { 0% { transform: scale(0.6); opacity: 0.7; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

/* Table */
.pb-card { padding: 16px 8px 4px; overflow-x: auto; }
.pb-table { min-width: 860px; }
.pb-table td { vertical-align: middle; }
/* Column headers: the canvas panel's section-label style ("CONSTRAINTS"). */
.pb-table th { font-size: var(--t-caption); font-weight: 700; letter-spacing: 0.1em; color: var(--pt-text); }
.pb-title { font-size: var(--t-heading); font-weight: 600; color: var(--pt-text); }
.pb-table .dash-pill { font-size: var(--t-small); }
.pb-table .dash-pill.is-none { color: var(--pt-text-2); background: var(--pt-surface-2); }
.pb-col-status { width: 36px; padding-right: 0 !important; }
.pb-col-diff { width: 110px; }
.pb-col-companies { width: 280px; }
.pb-col-score { width: 80px; }
.pb-col-actions { width: 230px; }
.pb-table--design-fix .pb-col-companies { width: 150px; }
.pb-table--design-fix .pb-col-actions { width: 150px; }

.pb-status { display: inline-flex; vertical-align: middle; color: var(--pt-text-3); }
td.pb-col-status { line-height: 0; }
.pb-status--solved { color: var(--dash-good); }
.pb-status--attempted { color: var(--dash-mid); }

.pb-title { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none; }
.pb-title:hover { color: var(--pt-accent); }
.pb-level { font-size: var(--t-caption); font-weight: 700; color: var(--pt-text-3); }

.pb-companies { display: flex; flex-wrap: wrap; gap: 4px; }
.pb-company {
  padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--pt-border); background: var(--pt-surface-2);
  font-size: var(--t-small); font-weight: 500; color: var(--pt-text); white-space: nowrap;
}
.pb-none { color: var(--pt-text-3); }
.pb-best { font-size: var(--t-body); font-weight: 600; color: var(--pt-text); font-variant-numeric: tabular-nums; }
.pb-best small { font-weight: 500; color: var(--pt-text-3); }
.pb-stars { display: inline-flex; gap: 2px; color: var(--pt-border-strong); }
.pb-stars .on { color: var(--dash-mid); }

.pb-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
/* Buttons lift with a shadow; Practice glows in the accent colour. */
.pb-btn {
  padding: 7px 14px; font-size: var(--t-body); white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.pb-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -6px rgba(15, 23, 42, 0.35); }
.pb-btn:active { transform: translateY(0) scale(0.97); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12); }
.pb-btn.dash-btn--primary { box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--pt-primary) 70%, transparent); }
.pb-btn.dash-btn--primary:hover { box-shadow: 0 10px 20px -8px color-mix(in srgb, var(--pt-primary) 85%, transparent); }
.pb-pro { display: inline-flex; align-items: center; gap: 4px; margin-right: 2px; font-size: var(--t-small); font-weight: 600; color: var(--pt-text-2); }
tr.is-locked .dash-btn--primary { border-color: var(--pt-border); background: var(--pt-surface); color: var(--pt-text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }

/* Motion: rows rise in one after another; solved ticks pop. */
@keyframes pb-pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pb-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pb-tick { 0% { transform: scale(0.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pb-table tbody tr { animation: pb-rise 0.32s ease-out both; }
.pb-table tbody tr:nth-child(1) { animation-delay: 0.02s; } .pb-table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.pb-table tbody tr:nth-child(3) { animation-delay: 0.06s; } .pb-table tbody tr:nth-child(4) { animation-delay: 0.08s; }
.pb-table tbody tr:nth-child(5) { animation-delay: 0.10s; } .pb-table tbody tr:nth-child(6) { animation-delay: 0.12s; }
.pb-table tbody tr:nth-child(7) { animation-delay: 0.14s; } .pb-table tbody tr:nth-child(8) { animation-delay: 0.16s; }
.pb-table tbody tr:nth-child(n+9) { animation-delay: 0.18s; }
.pb-status--solved svg { animation: pb-tick 0.45s cubic-bezier(.2, .9, .3, 1.3) 0.25s both; }
.pb-table tbody tr:hover .pb-title { color: var(--pt-accent); }
.pb-table tbody tr:hover .dash-pill.is-none { background: var(--pt-surface); box-shadow: inset 0 0 0 1px var(--pt-border); }
.pb-btn.dash-btn--primary { position: relative; overflow: hidden; }
.pb-btn.dash-btn--primary::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg); transition: left 0.5s ease;
}
.pb-btn.dash-btn--primary:hover::after { left: 120%; }
.pb-tab, .pb-seg-item span, .pb-page { transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease; }
.pb-page:hover { transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) {
  .pb-table tbody tr, .pb-status--solved svg, .pb-dd-menu, .pb-head::before, .pb-heading, .pb-sub, .pb-build,
  .pb-live-dot::after, .pb-tab.is-active, .pb-progress-bar > i, .pb-row-in { animation: none !important; }
  .pb-btn, .pb-build, .pb-page { transition: none; }
  .pb-btn:hover, .pb-build:hover, .pb-page:hover { transform: none; }
}

.pb-empty { padding: 40px 16px; border: 1px dashed var(--pt-border); border-radius: 14px; text-align: center; color: var(--pt-text-2); }
.pb-empty p { margin: 0 0 12px; }

/* Pagination */
.pb-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.pb-page {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px;
  border: 1px solid var(--pt-border); border-radius: 8px; background: var(--pt-surface);
  font-size: var(--t-small); font-weight: 600; color: var(--pt-text-2); text-decoration: none;
}
.pb-page:hover { border-color: var(--pt-accent); color: var(--pt-accent); }
.pb-page.is-current { border-color: var(--pt-accent); background: color-mix(in srgb, var(--pt-accent) 12%, transparent); color: var(--pt-accent); }

/* Tablets: drop companies and score; phones: also genre, and the table scrolls. */
@media (max-width: 1024px) {
  /* dashboard.css hides every column after the third on small screens;
     this table picks its own. */
  .pb-table th, .pb-table td { display: table-cell; }
  .pb-table .pb-col-companies, .pb-table .pb-col-score { display: none; }
  .pb-table { min-width: 0; }
}
@media (max-width: 640px) {
  .pb { padding: 20px 16px 48px; }
  .pb-build { max-width: none; width: 100%; }
  .pb-col-actions { width: auto; }
  .pb-actions { flex-wrap: wrap; }
}

/* Light mode: a soft slate stage so the white cards read as cards, not one
   white sheet. */
html[data-theme="light"] body.page-problems {
  --pt-bg: #e9eef6;
  background:
    radial-gradient(1100px 380px at 50% -120px, rgba(59, 130, 246, 0.12), transparent 70%),
    #e9eef6 !important;
}
html[data-theme="light"] .page-problems .pb-card {
  background: #ffffff;
  border: 1px solid #d5dde8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 14px 32px -18px rgba(15, 23, 42, 0.25);
}
html[data-theme="light"] .page-problems .pb-table tbody tr:hover { background: #f5f8ff; }
html[data-theme="light"] .page-problems .pb-search,
html[data-theme="light"] .page-problems .pb-seg,
html[data-theme="light"] .page-problems .pb-dd-trigger {
  background: #ffffff; border-color: #d5dde8; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
html[data-theme="light"] .page-problems .pb-tabs { background: #e9eef5; border-color: #d5dde8; box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .page-problems .pb-tab { color: #64748b; }
html[data-theme="light"] .page-problems .pb-tab:hover { color: #0f172a; background: rgba(255, 255, 255, 0.6); }
html[data-theme="light"] .page-problems .pb-tab.is-active {
  color: #0f172a; background: #ffffff; border-color: #bfdbfe;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 18px -8px rgba(37, 99, 235, 0.45);
}
html[data-theme="light"] .page-problems .pb-count { background: #dde4ee; color: #64748b; }
html[data-theme="light"] .page-problems .pb-tab.is-active .pb-count { background: #2563eb; color: #ffffff; }
html[data-theme="light"] .page-problems .pb-progress-bar { background: #dbe3ee; }
