/*!
 * ASK Unified Frontend Styles
 * File: ask-unified.css
 * Date: 2025-09-06
 * Source merge: fe-report.css + frontend.css
 *
 * Goals:
 *  - Consolidate variables and component styles from the FE Report and Assessment UI.
 *  - Remove duplication and conflicting overrides.
 *  - Keep squared, modern aesthetic with Bootstrap compatibility where needed.
 *  - Preserve backward compatibility for markup variants (labels vs .ask-option,
 *    .ask-pagination vs .ask-nav, server-side question numbering via .ask-qnum).
 *
 * Notes for devs:
 *  - Variables can be overridden via wp_add_inline_style or inline <style> in PHP.
 *  - Assessment colours use --ask-* custom properties, mapped to the core palette.
 *  - Premium gating relies on [data-premium] and [data-lock] attributes.
 *  - Keep this file as the single enqueue for public UI (replace fe-report.css & frontend.css).
 */

/* ================================================================
   0) ROOT VARIABLES — COLOUR SYSTEM & TYPOGRAPHY
   ---------------------------------------------------------------- */
:root {
  /* Core palette + typography (from FE Report) */
  --theme-font: 'Montserrat', -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bg: #f6f7f9;
  --card-bg: #fff;
  --card-border: rgba(0, 0, 0, 0.08);
  --text: #111827;
  --muted: #6b7280;
  --primary: #5856d6;
  --accent: #83b3fc;
  --growth: #2ecc71;
  --grayring: #e9eef5;
  --pillar-align: #f4a742;
  --pillar-shift: #35599a;
  --pillar-keep: #81d742;

  /* Heading colours; may be overridden by admin inline CSS */
  --h1-color: #111827;
  --h2-color: #374151;
  --h3-color: #4B5563;

  /* Donut segments (score, delta, remainder) */
  --donut-score: #10B981;
  --donut-delta: #F59E0B;
  --donut-remainder: #E5E7EB;

  /* Typography scale */
  --heading-font: 'Montserrat', -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --body-font: 'Montserrat', -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --h1-size: 2em;
  --h2-size: 1.5em;
  --h3-size: 1.2em;
  --h4-size: 1em;
  --p-size: 1em;
  --p-line-height: 1.3;
  --p-color: #111827;

  /* Assessment theme variables (from Frontend) — mapped to core where sensible */
  --ask-narrative: var(--text, #111827);
  --ask-primary: var(--accent, #83b3fc);
  --ask-growth: var(--pillar-keep, #81d742);
  --ask-card-bg: var(--card-bg, #ffffff);
  --ask-card-border: var(--card-border, #e0e0e0);
  --ask-border: #e5e7eb;
  --ask-bg: #f8fafc;

  /* Optional knobs injected by PHP; set safe defaults */
  --ask-nav-inactive: #9ca3af;
  --ask-submit: var(--ask-growth);
}

/* ================================================================
   1) BASE & TYPOGRAPHY
   ---------------------------------------------------------------- */
html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font);
}

/* Utility heading sizes/colours used across reports */
.ask-fe .h5,
.ask-fe h5,
.ask-fe .report-title {
  color: var(--h1-color);
  font-family: var(--heading-font);
  font-size: var(--h1-size);
}
.ask-fe h6 {
  color: var(--h2-color);
  font-family: var(--heading-font);
  font-size: var(--h2-size);
}
.ask-fe .section-title {
  color: var(--h3-color);
  font-family: var(--heading-font);
  font-size: var(--h3-size);
}
.ask-fe p {
  color: var(--p-color);
  font-family: var(--body-font);
  font-size: var(--p-size);
  line-height: var(--p-line-height);
}

/* Small title used in cards/sections */
.section-title {
  font-weight: 700;
  font-size: 1rem;
}

/* ================================================================
   2) LAYOUT WRAPPERS
   ---------------------------------------------------------------- */
.ask-dashboard {
  margin: 0 auto;
  width: 98%;
  padding: 2%;
  box-sizing: border-box;
}
.ask-assessment-view {
  margin: 0 auto;
  width: 98%;
  max-width: 1200px;
  padding: 2%;
  box-sizing: border-box;
}

/* Two-column helper */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ================================================================
   3) CARD COMPONENTS
   ---------------------------------------------------------------- */
.ask-card,
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.persona-intro-card {
  background: #f9fafb;
  border: 1px solid var(--card-border);
}
.persona-intro-card h6 {
  font-weight: 600;
  margin-bottom: 4px;
}
.persona-intro-card p {
  margin-bottom: 0;
}

/* Short description block; aligns with donut height */
.short-desc {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Muted badge (kept for future use) */
.badge-muted {
  background: #eef2f7;
  color: #111827;
}

/* ================================================================
   4) BUTTONS & TABS
   ---------------------------------------------------------------- */
.btn-square { border-radius: 0; }

/* Icon buttons (used in headers) */
.btn-icon {
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 0;
}
.btn-icon .material-icons {
  font-size: 18px;
  vertical-align: -4px;
}

/* Nav tabs: squared edges + primary colour */
.nav-tabs .nav-link { border-radius: 0 !important; color: var(--primary); font-family: var(--body-font)}
.nav-tabs .nav-link.active { background: var(--primary) !important; color: #fff !important; }
.nav-tabs .nav-link:hover { color: var(--primary); background: #efefee; }

/* Persona tabs: horizontal scroll on small screens */
#personaTabs { overflow-x: auto; white-space: nowrap; }
#personaTabs .nav-link { min-width: 120px; text-align: center; }

/* CTA bar container (paired with responsive stacking below) */
.ask-cta-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ================================================================
   5) PREMIUM GATING — LOCK & OVERLAY
   ---------------------------------------------------------------- */
.lock { position: relative; min-height: 260px; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
}
.overlay .panel {
  background: #fff;
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 20px;
  max-width: 560px;
  width: 100%;
}
[data-premium].is-locked [data-premium-body] { display: none; }
[data-premium].is-locked [data-lock] { display: block; }
[data-lock] { display: none; }

/* ================================================================
   6) COURSE LIST & UPGRADE CTAS
   ---------------------------------------------------------------- */
.course-list li {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #eceff4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.course-list li:nth-child(even) { background: #f7f8fb; }
.course-list li span {
  flex: 1 1 auto;
  margin-right: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Course/Upgrade buttons: outline → fill on hover */
.course-list li .btn,
.ask-upgrade-lead,
.ask-upgrade-team,
.ask-upgrade-self,
#btnViewMoreDomains,
#btnCollapseDomains {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: 0;
  font-weight: 600;
}
.course-list li .btn:hover,
.ask-upgrade-lead:hover,
.ask-upgrade-team:hover,
.ask-upgrade-self:hover,
#btnCollapseDomains:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
/* View more → growth on hover */
#btnViewMoreDomains:hover {
  background: var(--pillar-keep);
  color: #fff;
  border-color: var(--pillar-keep);
}

/* ================================================================
   7) AUTH / PROMPTS
   ---------------------------------------------------------------- */
.ask-auth-wrapper {
  max-width: 420px;
  margin: 2rem auto;
  padding: 2rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.ask-auth-wrapper p { margin-bottom: 1rem; }
.ask-auth-wrapper label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
  color: #374151;
}
.ask-auth-wrapper input.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #f9fafb;
  font-size: 1rem;
  box-sizing: border-box;
}
.ask-auth-wrapper input.input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
}
.ask-auth-wrapper .button {
  display: inline-block;
  width: 100%;
  padding: 0.5rem 0;
  font-size: 1rem;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
}
.ask-auth-wrapper .button-primary {
  background-color: #0A84FF;
  border: 1px solid #0A84FF;
  color: #ffffff;
}
.ask-auth-wrapper .button-primary:hover { background-color: #0066cc; border-color: #0066cc; }
.ask-auth-wrapper .button-secondary {
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #374151;
}
.ask-auth-wrapper .button-secondary:hover { background-color: #e5e7eb; }
.ask-auth-wrapper .ask-switch-link a {
  font-size: 0.875rem;
  color: #0A84FF;
  text-decoration: underline;
}
.ask-auth-wrapper .ask-switch-link a:hover { color: #0066cc; }

.ask-upgrade-prompt {
  max-width: 420px;
  margin: 1.5rem auto;
  padding: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: #f9fafb;
  text-align: center;
}
.ask-upgrade-prompt p { margin-bottom: 0.75rem; color: #374151; }

/* ================================================================
   8) ASSESSMENT: QUESTIONS, OPTIONS & NAVIGATION
   ---------------------------------------------------------------- */
/* Inherit system font if injected by theme */
.ask-assessment-form { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Montserrat", sans-serif; }

/* Reset list */
.ask-questions { list-style: none; padding: 0; margin: 0; }

/* Question card */
.ask-question {
  border: 1px solid var(--ask-card-border);
  background-color: var(--ask-card-bg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 0;
}

/* Titles & numbering (server-side .ask-qnum) */
.ask-question-title {
  font-weight: 500;
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--ask-narrative);
  position: relative;
}
.ask-qnum { font-weight: 700; margin-right: 0.5rem; color: var(--ask-primary); }
/* Hide legacy <span class="num"> to avoid duplicate numbering */
.ask-question-title .num { display: none; }

/* Options grid: 5 columns on desktop, stacked on small screens */
.ask-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  padding-top: 0.5rem;
}

/* Modern pill element (div.ask-option) */
.ask-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 1px solid var(--ask-border);
  border-radius: 999px;
  background-color: var(--ask-bg);
  color: var(--ask-narrative);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}
.ask-option:hover { background-color: var(--ask-border); opacity: 1; }
.ask-option.selected {
  background-color: var(--ask-primary) !important;
  color: #fff !important;
  border-color: var(--ask-primary) !important;
}
.ask-option input { display: none; }

/* Legacy label-based markup support */
.ask-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ask-border);
  background: var(--ask-bg);
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}
.ask-options label:hover { opacity: 0.8; }
.ask-options input { display: none; }
/* When script toggles .selected on label */
.ask-options label.selected {
  background-color: var(--ask-primary) !important;
  color: #fff !important;
  border-color: var(--ask-primary) !important;
}
/* When using :checked + span structure */
.ask-options input:checked + span {
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
}

/* Navigation (preferred: .ask-nav) */
.ask-nav {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.ask-nav .btn {
  flex: 1;
  min-width: 160px;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--ask-primary);
  background-color: var(--ask-primary);
  color: #ffffff;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: center;
}
.ask-nav .btn:hover:not(:disabled) { opacity: 0.8; }
.ask-nav .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: var(--ask-nav-inactive);
  background-color: var(--ask-nav-inactive);
  color: #ffffff;
}
.ask-nav .btn-growth {
  border-color: var(--ask-submit);
  background-color: var(--ask-submit);
  color: #ffffff;
}

/* Back-compat: .ask-pagination mirrors .ask-nav styling */
.ask-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.ask-pagination .ask-page-info {
  flex: 1 1 auto;
  text-align: center;
  font-weight: 500;
  color: var(--ask-narrative);
}
.ask-pagination button {
  flex: 0 0 40%;
  max-width: 45%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 400;
  border: 1px solid var(--ask-primary);
  border-radius: 0.5rem;
  cursor: pointer;
  color: #ffffff;
  background-color: var(--ask-primary);
  transition: opacity 0.15s ease;
}
.ask-pagination button:hover:not(:disabled) { opacity: 0.8; }
.ask-pagination button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: var(--ask-nav-inactive);
  background-color: var(--ask-nav-inactive);
  color: #ffffff;
}
.ask-pagination .ask-see-results {
  background-color: var(--ask-submit);
  border-color: var(--ask-submit);
  color: #ffffff;
}

/* ================================================================
   9) LOADING OVERLAY (SPINNER + PROGRESS BAR)
   ---------------------------------------------------------------- */
.ask-loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}
.ask-loading h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ask-narrative);
}
.ask-progress {
  width: 60%;
  max-width: 300px;
  height: 8px;
  background-color: var(--ask-border);
  border-radius: 999px;
  overflow: hidden;
}
.ask-progress-bar {
  height: 100%;
  width: 0%;
  background-color: var(--ask-growth);
  animation: ask-progress 1.8s linear forwards;
}
@keyframes ask-progress { from { width: 0%; } to { width: 100%; } }

.ask-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--ask-border);
  border-top-color: var(--ask-narrative);
  animation: ask-spin 0.8s linear infinite;
}
@keyframes ask-spin { to { transform: rotate(360deg); } }
/* Legacy keyframes alias */
@keyframes askspin { to { transform: rotate(360deg); } }

/* ================================================================
   10) MODALS & BODY SCROLL
   ---------------------------------------------------------------- */
body.modal-open { overflow-y: scroll; padding-right: 0 !important; }

#askUpgradeModal .modal-dialog {
  max-width: 480px;
  margin: 1rem auto;
}
#askUpgradeModal .modal-content {
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#askUpgradeModal .modal-body {
  flex: 1 1 auto;
  overflow: auto;
}
#askUpgradeFrame {
  width: 100%;
  height: 70vh;
  border: 0;
}

/* ================================================================
   11) RESPONSIVE REFINEMENTS
   ---------------------------------------------------------------- */
/* Center/limit overlay panels */
[data-premium] .overlay .panel,
.ask-card .overlay .panel {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* XS: overlay panel grows wider, CTA bars stack, long text narrows */
@media (max-width: 575.98px) {
  [data-premium] .overlay .panel,
  .ask-card .overlay .panel { max-width: 90vw; }

  .ask-cta-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .ask-cta-bar .btn, .ask-cta-bar .button { width: 100%; }

  /* Limit line length of long descriptions on narrow screens */
  .ask-long { max-width: 42ch; }

  #askUpgradeFrame { height: 65vh; }
}

/* SM: tighten gutters + card padding */
@media (max-width: 767.98px) {
  .row.g-3 {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.75rem;
  }
  .ask-card { padding: 0.875rem; }
  .ask-card .section-title { font-size: 1rem; }
}

/* Options stack & nav column on narrow devices */
@media (max-width: 720px) {
  .ask-options { grid-template-columns: 1fr; }
  .ask-nav { flex-direction: column; }
  .ask-nav .btn { width: 100%; min-width: 0; }
  .ask-pagination button { flex-basis: 100%; max-width: 100%; }
}
