/* ============================================================
   Seurch plan & checkout pages (private build).

   Styled with the open core's design tokens, exposed as CSS variables by the
   committed search/tailwind.css and re-pointed under `.dark` and
   `.theme-system` (dark scheme), so every colour here flips automatically in
   dark mode. Like landing.css, tokens are read with light-mode fallbacks.

   This is a standalone stylesheet because the private build intentionally
   does not run the open core's Tailwind CLI pipeline: a utility class the
   core's own templates don't use is tree-shaken out of the committed build,
   so overlay pages cannot rely on arbitrary utilities being present.
   ============================================================ */

/* Every pl- root, including the ones used standalone outside a card
   (.pl-link, .pl-btn), so the aliases are always defined where read. */
.pl-card,
.pl-banner,
.pl-switch,
.pl-confirm,
.pl-group,
.pl-tokens,
.pl-btn,
.pl-link {
  --pl-surface: var(--color-surface, #ffffff);
  --pl-elevated: var(--color-elevated, #f8fafc);
  --pl-edge: var(--color-edge, #e2e8f0);
  --pl-ink: var(--color-ink, #1e293b);
  --pl-ink-muted: var(--color-ink-muted, #64748b);
  --pl-brand: var(--color-brand, #4f46e5);
  --pl-brand-soft: var(--color-brand-soft, #eef2ff);
  /* Amber warning / red danger pairs: no semantic tokens exist for them, so
     re-point them for dark the same two ways the core re-points its own. */
  --pl-warn: #b45309;
  --pl-danger: #dc2626;
}
.dark .pl-card,
.dark .pl-banner,
.dark .pl-switch,
.dark .pl-confirm,
.dark .pl-group,
.dark .pl-tokens,
.dark .pl-btn,
.dark .pl-link {
  --pl-warn: #fbbf24;
  --pl-danger: #f87171;
}
@media (prefers-color-scheme: dark) {
  .theme-system .pl-card,
  .theme-system .pl-banner,
  .theme-system .pl-switch,
  .theme-system .pl-confirm,
  .theme-system .pl-group,
  .theme-system .pl-tokens,
  .theme-system .pl-btn,
  .theme-system .pl-link {
    --pl-warn: #fbbf24;
    --pl-danger: #f87171;
  }
}

/* ---- Cards -------------------------------------------------------------- */
.pl-card {
  background: var(--pl-surface);
  border: 1px solid var(--pl-edge);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.pl-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.pl-plan-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pl-ink);
  margin: 0;
}
.pl-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pl-brand);
  background: var(--pl-brand-soft);
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}

/* ---- Price line ---------------------------------------------------------- */
.pl-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
}
.pl-amount {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--pl-ink);
}
.pl-period {
  font-size: 0.85rem;
  color: var(--pl-ink-muted);
}
.pl-muted {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--pl-ink-muted);
  margin: 0;
}
.pl-facts {
  list-style: none;
  margin: 0;
  padding: 0.9rem 0 0;
  border-top: 1px solid var(--pl-edge);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--pl-ink);
}

/* ---- Usage meter ---------------------------------------------------------- */
.pl-usage {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--pl-edge);
}
.pl-usage-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--pl-ink-muted);
}
.pl-usage-row strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--pl-ink);
}
.pl-bar {
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--pl-brand-soft);
  overflow: hidden;
}
.pl-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--pl-brand);
  transition: width 0.18s ease;
}
.pl-usage-note {
  font-size: 0.9rem;
  color: var(--pl-ink);
  margin: 0;
}
.pl-alert {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--pl-warn);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

/* ---- Success banner ------------------------------------------------------- */
.pl-banner {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--pl-ink);
  background: var(--pl-brand-soft);
  border: 1px solid color-mix(in oklab, var(--pl-brand) 35%, transparent);
  border-radius: 0.75rem;
  padding: 0.8rem 1rem;
}

/* ---- Buttons & links ------------------------------------------------------ */
.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 0.55rem;
  padding: 0.65rem 1.1rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
/* Pinned to indigo-600/700 in both themes, like the core's own primary
   buttons (`bg-indigo-600 hover:bg-indigo-700 text-white`, no dark variant):
   the dark-mode brand token (#818cf8) is too light behind white text. */
.pl-btn-primary {
  color: #fff;
  border: 1px solid transparent;
  background: #4f46e5;
}
.pl-btn-primary:hover {
  background: #4338ca;
}
.pl-btn-ghost {
  color: var(--pl-ink);
  background: transparent;
  border: 1px solid var(--pl-edge);
}
.pl-btn-ghost:hover {
  color: var(--pl-brand);
  border-color: var(--pl-brand);
}
.pl-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--pl-brand);
  text-decoration: none;
}
.pl-link:hover {
  text-decoration: underline;
}
/* Cancel action: neutral at rest, red on hover, mirroring the core's
   "Remove" buttons in Settings. */
/* ---- Checkout opt-in ------------------------------------------------------- */
/* One checkbox above the confirm button: renewal is part of buying the pack,
   not a second decision on a second page. */
.pl-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--pl-ink);
  cursor: pointer;
}
.pl-choice input {
  margin-top: 0.2rem;
  accent-color: var(--pl-brand);
}

/* ---- Pack switcher --------------------------------------------------------- */
.pl-switch {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--pl-edge);
}
.pl-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pl-ink);
  margin: 0;
}
.pl-tiers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: stretch;
  margin-top: 0.25rem;
}
@media (min-width: 640px) {
  .pl-tiers {
    grid-template-columns: repeat(3, 1fr);
  }
}
.pl-tier {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--pl-surface);
  border: 1px solid var(--pl-edge);
  border-radius: 1rem;
  padding: 1.25rem;
}
.pl-tier-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--pl-ink);
  margin: 0;
}
.pl-tier .pl-amount {
  font-size: 1.35rem;
}
.pl-tier-quota {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pl-ink);
  margin: 0;
}
.pl-tier .pl-btn {
  margin-top: auto;
}
.pl-tier .pl-btn {
  width: 100%;
}
/* ---- Cost dial (tokens per search, searches left) --------------------------- */
/* The live readouts the provider picker feeds: plan.js updates the values as
   providers are toggled; without JS they show the server-rendered figure for
   the saved defaults and refresh on the next save.

   One group per search type, each with its own total, laid out like the core's
   Settings -> Engines groups so the two pages read as one product. */
.pl-group + .pl-group {
  margin-top: 1.5rem;
}
.pl-group-cost {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pl-edge);
}
/* The per-provider price beside each toggle: a column of figures, so it is
   worth aligning. `tabular-nums` is a Tailwind utility the core's own templates
   never use, which means the committed build tree-shakes it away (see the note
   at the top of this file); spell it out here instead. */
.pl-tokens {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pl-ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pl-cost {
  margin-top: 0.25rem;
  border: 1px solid var(--pl-edge);
  border-radius: 0.75rem;
  background: var(--pl-elevated);
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.pl-cost-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--pl-ink-muted);
}
.pl-cost-row strong {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--pl-brand);
  white-space: nowrap;
}

/* ---- Settings-menu integration --------------------------------------------- */
/* The plan page renders the shared settings sidebar (private/_settings_nav.html)
   and marks its own item with aria-current. The core's active-item styling is
   driven by the settings-page radios, which don't exist here, so drive the
   highlight off aria-current instead, reusing the core brand tokens so it flips
   in dark mode exactly like the real settings nav. */
.settings-nav a[aria-current="page"] {
  background: var(--color-brand-soft);
  color: var(--color-brand);
  border-left-color: var(--color-brand);
}
@media (max-width: 700px) {
  .settings-nav a[aria-current="page"] {
    border-left-color: transparent;
    border-bottom-color: var(--color-brand);
  }
}

/* ---- Motion ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .pl-btn,
  .pl-bar-fill {
    transition: none;
  }
}
