/* ============================================================
   PaidHR Advanced FAQ Widget — Frontend Styles
   ============================================================ */

/* ── CSS custom properties (defaults; Elementor selectors override) ── */
.phr-faq-wrap {
  --phr-speed:        320ms;
  --phr-easing:       cubic-bezier(0.4, 0, 0.2, 1);
  --phr-rot:          90deg;
  --phr-accent:       #004AF5;
  --phr-accent-light: #EFF2FF;
  --phr-border:       #CCDBFD;
  --phr-text:         #102B68;
  --phr-answer:       #333333;
  --phr-radius:       14px;
  font-family: inherit;
  box-sizing: border-box;
}

.phr-faq-wrap *,
.phr-faq-wrap *::before,
.phr-faq-wrap *::after {
  box-sizing: border-box;
}

/* ── Title & Subtitle ───────────────────────────────────────── */
/* Defaults only — Elementor selector controls override all of these */
.phr-faq-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.phr-faq-title {
  color: #022B86;
  font-size: 40px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 16px;
  text-align: center;
}

.phr-faq-subtitle {
  color: #555;
  font-size: 16px;
  font-weight: 400;
  text-align: center;
  margin: 8px 0 32px;
}

/* ── Expand / Collapse buttons ──────────────────────────────── */
.phr-faq-controls {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.phr-faq-controls button {
  background: transparent;
  border: 1px solid var(--phr-border);
  border-radius: 6px;
  color: var(--phr-accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  transition: background var(--phr-speed) var(--phr-easing),
              border-color var(--phr-speed) var(--phr-easing);
}

.phr-faq-controls button:hover {
  background: var(--phr-accent-light);
  border-color: var(--phr-accent);
}

/* ── Search ─────────────────────────────────────────────────── */
.phr-faq-search-wrap { width: 100%; }

.phr-faq-search {
  width: 100%;
  display: block;
  background: #fff;
  border: 1px solid var(--phr-border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 1rem;
  font-family: inherit;
  color: #333;
  outline: none;
  transition: border-color var(--phr-speed) var(--phr-easing),
              box-shadow  var(--phr-speed) var(--phr-easing);
}

.phr-faq-search:focus {
  border-color: var(--phr-accent);
  box-shadow: 0 0 0 3px rgba(0, 74, 245, 0.12);
}

.phr-faq-no-results { color: #666; }

/* ── Grid layouts ───────────────────────────────────────────── */

/*
 * Display mode is driven by the data-display attribute which is set
 * explicitly in both PHP render() and content_template(). Attribute
 * selectors override every class-based or Elementor-generated rule
 * because !important is paired with a direct DOM-attribute match.
 */

/* Base: spacing & alignment only */
.phr-faq-grid {
  gap: 20px;
  align-items: start;
}

/* ── Single column — 1 item per row (default) ── */
.phr-faq-grid[data-display="stack"],
.phr-faq-grid:not([data-display]) {
  display: grid !important;
  grid-template-columns: 1fr !important;
}

/* ── Multi-column grid ─── */
.phr-faq-grid[data-display="grid"] {
  display: grid !important;
}
/* Static column fallbacks — Elementor responsive selector overrides via selector specificity */
.phr-faq-grid--cols-1 { grid-template-columns: 1fr; }
.phr-faq-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.phr-faq-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.phr-faq-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.phr-faq-grid--equal  { align-items: stretch; }

/* ── Flexbox — auto-wrap cards ─── */
.phr-faq-grid[data-display="flex"] {
  display: flex !important;
  flex-wrap: wrap;
}
.phr-faq-grid[data-display="flex"] .phr-faq-item {
  flex: 1 1 400px;
}

/* ── Responsive breakpoints ─────────────────────────────────── */
@media (max-width: 1024px) {
  .phr-faq-grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
  .phr-faq-grid--cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .phr-faq-grid--cols-2,
  .phr-faq-grid--cols-3,
  .phr-faq-grid--cols-4           { grid-template-columns: 1fr; }
  .phr-faq-grid[data-display="flex"] .phr-faq-item { flex: 1 1 100%; }
}

/* ── Card ───────────────────────────────────────────────────── */
.phr-faq-item {
  background: var(--phr-accent-light);
  border: 1px solid var(--phr-border);
  border-radius: var(--phr-radius);
  overflow: hidden;
  transition: box-shadow 300ms ease,
              background 300ms ease,
              border-color 300ms ease,
              transform 300ms ease;
  outline: none;
}

.phr-faq-item:hover {
  box-shadow: 0 4px 24px rgba(0, 74, 245, 0.1);
}

/* Focus-within highlight (keyboard users) */
.phr-faq-item:focus-within {
  box-shadow: 0 0 0 2px var(--phr-accent), 0 4px 16px rgba(0, 74, 245, 0.12);
}

/* ── Header ─────────────────────────────────────────────────── */
.phr-faq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.phr-faq-header.phr-icon-left {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.phr-faq-header:focus-visible {
  outline: 2px solid var(--phr-accent);
  outline-offset: -2px;
  border-radius: var(--phr-radius);
}

/* ── Question ───────────────────────────────────────────────── */
.phr-faq-question {
  flex: 1;
  color: var(--phr-text);
  font-size: clamp(15px, 1.5vw, 18px);
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  transition: color var(--phr-speed) var(--phr-easing);
}

.phr-faq-item.is-open .phr-faq-question {
  color: var(--phr-accent);
}

/* ── Badge ──────────────────────────────────────────────────── */
.phr-faq-badge {
  display: inline-block;
  background: var(--phr-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Icon wrapper ───────────────────────────────────────────── */
.phr-faq-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phr-faq-icon svg {
  width: 40px;
  height: 40px;
  display: block;
  transition: transform var(--phr-speed) var(--phr-easing);
}

/* Rotate SVG-based icons on open */
.phr-faq-item.is-open .phr-faq-icon svg {
  transform: rotate(var(--phr-rot, 90deg));
}

/* Custom Elementor icon states */
.phr-icon-custom-wrap .phr-icon-opened         { display: none !important; }
.phr-faq-item.is-open .phr-icon-custom-wrap .phr-icon-closed { display: none !important; }
.phr-faq-item.is-open .phr-icon-custom-wrap .phr-icon-opened { display: inline-flex !important; }
.phr-faq-icon i { transition: transform var(--phr-speed) var(--phr-easing), color var(--phr-speed); }

/* ── Plus / Minus icon ──────────────────────────────────────── */
.phr-faq-icon-pm,
.phr-faq-icon-box {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  color: var(--phr-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--phr-speed) var(--phr-easing),
              color var(--phr-speed) var(--phr-easing);
}

.phr-faq-icon-box {
  border-radius: 8px;
  border: 1px solid var(--phr-border);
}

.phr-pm-bar {
  position: absolute;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--phr-speed) var(--phr-easing),
              opacity var(--phr-speed) var(--phr-easing);
}

.phr-pm-h { width: 45%; height: 2px; }
.phr-pm-v { width: 2px; height: 45%; }

.phr-faq-item.is-open .phr-pm-v {
  transform: rotate(90deg);
  opacity: 0;
}

/* ── Body / Slide ───────────────────────────────────────────── */
.phr-faq-body {
  max-height: 0;
  overflow: hidden;
  padding: 0 32px;
  transition: max-height var(--phr-speed) var(--phr-easing),
              padding-bottom var(--phr-speed) var(--phr-easing),
              opacity var(--phr-speed) var(--phr-easing);
}

.phr-faq-item.is-open .phr-faq-body {
  padding-bottom: 28px;
}

/* Entrance: fade */
.phr-faq-wrap[data-entrance="fade"] .phr-faq-body { opacity: 0; }
.phr-faq-wrap[data-entrance="fade"] .phr-faq-item.is-open .phr-faq-body { opacity: 1; }

/* Entrance: slide_up */
.phr-faq-wrap[data-entrance="slide_up"] .phr-faq-answer {
  transform: translateY(10px);
  transition: transform var(--phr-speed) var(--phr-easing);
}
.phr-faq-wrap[data-entrance="slide_up"] .phr-faq-item.is-open .phr-faq-answer {
  transform: translateY(0);
}

/* ── Answer ─────────────────────────────────────────────────── */
.phr-faq-answer {
  color: var(--phr-answer);
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
  border-top: 1px solid var(--phr-border);
  padding-top: 18px;
}

.phr-faq-answer p:last-child { margin-bottom: 0; }
.phr-faq-answer strong { font-weight: 600; }
.phr-faq-answer a { color: var(--phr-accent); font-weight: 600; text-decoration: none; }
.phr-faq-answer a:hover { text-decoration: underline; }
.phr-faq-answer ul, .phr-faq-answer ol { padding-left: 20px; margin: 8px 0; }
.phr-faq-answer li { margin-bottom: 4px; }

/* ── Hidden (search) ────────────────────────────────────────── */
.phr-faq-item.phr-hidden { display: none !important; }

/* ── Search highlight ───────────────────────────────────────── */
.phr-highlight {
  background: rgba(0, 74, 245, 0.15);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Hash-target highlight ──────────────────────────────────── */
.phr-faq-item.phr-hash-active {
  box-shadow: 0 0 0 3px var(--phr-accent), 0 8px 32px rgba(0, 74, 245, 0.18);
  animation: phrHashPulse 0.8s var(--phr-easing) both;
}

@keyframes phrHashPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 74, 245, 0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(0, 74, 245, 0); }
  100% { box-shadow: 0 0 0 3px var(--phr-accent), 0 8px 32px rgba(0, 74, 245, 0.18); }
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .phr-faq-search-wrap,
  .phr-faq-controls,
  .phr-faq-icon         { display: none !important; }

  .phr-faq-body {
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: 16px !important;
  }

  .phr-faq-answer {
    opacity: 1 !important;
    transform: none !important;
  }

  .phr-faq-item {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ccc !important;
    margin-bottom: 12px;
  }

  .phr-faq-grid {
    display: block !important;
  }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .phr-faq-body,
  .phr-faq-icon svg,
  .phr-pm-bar,
  .phr-faq-item,
  .phr-faq-question,
  .phr-faq-answer {
    transition: none !important;
    animation: none !important;
  }
}
