/* RJ FAQ - Dynamic FAQ System Styles with Circular/Roboto Font System */
/* Version 0.9887-08072025 */

/* Import Roboto font as fallback - Circular should be loaded by the site */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;0,900;1,400&display=swap');

:root {
  --faq-font-display: 'Circular', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --faq-font-heading: 'Circular', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --faq-color-text: #1f2937;
  --faq-color-text-light: #6b7280;
  --faq-color-text-answer: #374151; /* Darker for better accessibility */
  --faq-color-border: #e5e7eb;
  --faq-color-primary: #3b82f6;
  --faq-color-primary-light: #dbeafe;
  --faq-color-primary-dark: #1e40af;
  --faq-color-primary-hover: #2563eb;
  --faq-color-secondary: #10b981;
  --faq-color-warning: #f59e0b;
  --faq-color-bg: #ffffff;
  --faq-color-bg-light: #f9fafb;
  --faq-transition: all 0.3s ease;
}

/* Container */
.rjdev-faq-container {
  font-family: var(--faq-font-display);
  background: var(--faq-color-bg);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--faq-color-border);
  overflow: hidden;
  margin: 1.5rem 0;
  padding: 1.5rem;
}

/* Error and Notice States */
.rjdev-faq-error,
.rjdev-faq-notice {
  text-align: center;
  padding: 2rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.rjdev-faq-error {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.rjdev-faq-notice {
  color: var(--faq-color-text-light);
  background: var(--faq-color-bg-light);
  border: 1px solid var(--faq-color-border);
}

/* Search Bar */
.faq-search-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.faq-search-input {
  width: 100%;
  padding: 0.875rem 3.5rem 0.875rem 1rem;
  font-size: 1rem;
  font-family: var(--faq-font-display);
  border: 2px solid var(--faq-color-border);
  border-radius: 12px;
  background: var(--faq-color-bg);
  color: var(--faq-color-text);
  transition: var(--faq-transition);
  outline: none;
}

.faq-search-input:focus {
  border-color: #6b7280;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.faq-search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: var(--faq-color-text-light);
  pointer-events: none;
}

.faq-search-clear {
  position: absolute;
  right: 2.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--faq-color-text-light);
  color: white;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: var(--faq-transition);
}

.faq-search-clear:hover {
  background: var(--faq-color-text);
}

.faq-search-wrapper.has-value .faq-search-clear {
  display: flex;
}

/* Category Filters */
.faq-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--faq-color-border);
}

.faq-filter-btn {
  padding: 0.625rem 1.25rem;
  font-size: 0.9rem;
  font-family: var(--faq-font-display);
  font-weight: 500;
  border: 2px solid var(--faq-color-border);
  border-radius: 50px;
  background: var(--faq-color-bg);
  color: var(--faq-color-text);
  cursor: pointer;
  transition: var(--faq-transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  outline: none;
  position: relative;
  overflow: hidden;
}

.faq-filter-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.faq-filter-btn.active {
  background: #e5e7eb;
  color: var(--faq-color-text);
  border-color: #9ca3af;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.faq-count {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* Content Wrapper */
.faq-content-wrapper {
  min-height: 200px;
  position: relative;
}

/* Accordion Style */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-style-accordion .faq-item {
  border: 1px solid var(--faq-color-border);
  border-radius: 12px;
  overflow: visible;
  background: var(--faq-color-bg);
  transition: var(--faq-transition);
  position: relative;
}

.faq-style-accordion .faq-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.faq-style-accordion .faq-item.expanded {
  border-color: #6b7280;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Category tag - positioned to avoid arrow completely */
.faq-category-tag {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 3rem; /* Well clear of the arrow */
  z-index: 2;
}

.category-label {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border-radius: 6px;
  font-size: 0.45rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.faq-question {
  width: 100%;
  padding: 1rem 3.5rem 1rem 1rem; /* Much more right padding for arrow and tag */
  background: transparent;
  border: none;
  text-align: left;
  font-size: 1.14rem; /* Increased 20% from 0.95rem */
  font-family: var(--faq-font-heading);
  font-weight: 600;
  color: var(--faq-color-text);
  cursor: pointer;
  display: block;
  transition: var(--faq-transition);
  outline: none;
  position: relative;
  min-height: 2.5rem; /* Ensure minimum height */
}

.faq-question:hover {
  background: var(--faq-color-bg-light);
}

.faq-item.expanded .faq-question {
  background: #f3f4f6;
  color: var(--faq-color-text);
  border-bottom: 1px solid var(--faq-color-border); /* Visual separator */
  margin-bottom: 0.25rem; /* Small gap before answer */
}

.faq-question-text {
  display: block;
  line-height: 1.4;
  padding-right: 1rem; /* Extra safety padding */
}

.faq-toggle-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  z-index: 3; /* Above category tag */
  background: var(--faq-color-bg); /* Background to prevent overlap visibility */
  border-radius: 4px;
}

.faq-toggle-icon svg {
  width: 16px;
  height: 16px;
}

.faq-item.expanded .faq-toggle-icon {
  transform: rotate(180deg);
}

/* Answer styles - clean preview without overlap */
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
  opacity: 0;
  margin-top: 0; /* No margin in collapsed state */
}

/* Show preview for non-expanded items */
.faq-item:not(.expanded) .faq-answer {
  max-height: 2.4rem;
  opacity: 1;
}

.faq-answer-content {
  padding: 0.5rem 1rem 0.75rem; /* Better top padding for separation */
  font-size: 0.875rem;
  line-height: 1.4;
  color: #6b7280;
}

/* Collapsed state - show preview */
.faq-item:not(.expanded) .faq-answer-content {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 0.25rem; /* Less padding in collapsed state */
}

/* Only show "..." when content actually overflows (controlled by JS) */
.faq-item:not(.expanded) .faq-answer.has-overflow::after {
  content: '...';
  position: absolute;
  right: 1rem;
  bottom: 0.25rem;
  font-size: 0.8rem;
  color: #9ca3af;
  background: linear-gradient(to left, white 0%, white 60%, transparent 100%);
  padding-left: 2rem;
  pointer-events: none;
}

/* Expanded state */
.faq-item.expanded .faq-answer {
  max-height: 2000px; /* Large enough for any content */
  transition: max-height 0.4s ease-out;
}

.faq-item.expanded .faq-answer::after {
  display: none;
}

.faq-item.expanded .faq-answer-content {
  color: var(--faq-color-text);
  -webkit-line-clamp: unset;
  display: block;
}

.faq-answer-content p {
  margin: 0 0 0.75rem;
}

.faq-answer-content p:last-child {
  margin-bottom: 0;
}

/* List Style */
.faq-style-list .faq-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.faq-category-section {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--faq-color-border);
}

.faq-category-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-category-title {
  font-family: var(--faq-font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--faq-color-text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #6b7280;
}

.faq-category-items {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.faq-style-list .faq-item {
  padding-left: 1rem;
  border-left: 3px solid #e5e7eb;
  transition: var(--faq-transition);
}

.faq-style-list .faq-item:hover {
  border-left-color: #6b7280;
}

.faq-question-list {
  font-family: var(--faq-font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--faq-color-text);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.faq-answer-list {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--faq-color-text-answer);
}

/* Cards Style - Cleaner and more compact */
.faq-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.faq-cards[data-columns="1"] {
  grid-template-columns: 1fr;
}

.faq-cards[data-columns="2"] {
  grid-template-columns: repeat(2, 1fr);
}

.faq-cards[data-columns="3"] {
  grid-template-columns: repeat(3, 1fr);
}

.faq-card {
  background: var(--faq-color-bg);
  border: 1px solid var(--faq-color-border);
  border-radius: 12px;
  overflow: hidden;
  transition: var(--faq-transition);
  cursor: pointer;
  position: relative;
  min-height: 120px; /* Appropriate for larger text */
}

.faq-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #9ca3af;
}

.faq-card.expanded {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-color: #6b7280;
}

.faq-card-content {
  padding: 1rem;
  position: relative;
}

.faq-card-category {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1;
}

.faq-category-badge {
  display: inline-block;
  padding: 0.125rem 0.4rem;
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
  border-radius: 6px;
  font-size: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Card question - Same size as accordion on desktop */
.faq-card-question {
  font-family: var(--faq-font-heading);
  font-size: 1.14rem !important; /* Same as accordion questions */
  font-weight: 600;
  color: var(--faq-color-text);
  margin: 0 0 0.5rem;
  line-height: 1.3;
  padding-right: 4rem; /* More space for category badge with larger text */
}

.faq-card-answer {
  font-size: 0.875rem; /* Proportionally larger to match question */
  line-height: 1.4;
  color: #6b7280;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.faq-card.expanded .faq-card-answer {
  -webkit-line-clamp: unset;
  display: block;
  color: var(--faq-color-text-answer);
}

.faq-card-more {
  color: #9ca3af;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: none;
}

.faq-card:not(.expanded) .faq-card-answer.has-overflow + .faq-card-more {
  display: block;
}

/* Force single column on mobile - VERY IMPORTANT */
@media (max-width: 768px) {
  .faq-style-cards .faq-cards,
  .faq-style-cards .faq-cards[data-columns="1"],
  .faq-style-cards .faq-cards[data-columns="2"],
  .faq-style-cards .faq-cards[data-columns="3"] {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important; /* Reduced gap between cards */
  }
  
  /* Mobile card styles */
  .faq-card-question {
    font-size: 0.9rem !important; /* Increased from 0.84rem */
  }
  
  .faq-card-answer {
    font-size: 0.7rem !important;
  }
}

/* No Results */
.faq-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--faq-color-text-light);
  font-size: 1rem;
}

.faq-no-results p {
  margin: 0;
}

/* Footer */
.faq-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--faq-color-border);
  text-align: center;
}

.faq-footer-text {
  font-size: 0.9rem;
  color: var(--faq-color-text-light);
  margin: 0;
}

.faq-contact-link {
  color: #4b5563;
  text-decoration: underline;
  font-weight: 500;
  transition: var(--faq-transition);
}

.faq-contact-link:hover {
  color: #1f2937;
  text-decoration: underline;
}

/* Search Highlight */
.faq-highlight {
  background-color: #fef3c7;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-weight: 500;
  color: var(--faq-color-text);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.faq-item {
  animation: fadeIn 0.3s ease forwards;
}

/* Mobile Responsive - Clean and readable */
@media (max-width: 768px) {
  .rjdev-faq-container {
    padding: 0.75rem;
    margin: 0.5rem 0;
  }
  
  .faq-search-wrapper {
    margin-bottom: 0.75rem;
  }
  
  .faq-search-input {
    padding: 0.5rem 2.75rem 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
  
  .faq-category-filters {
    gap: 0.4rem;
    margin-bottom: 0.75rem;
  }
  
  .faq-filter-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
  
  .faq-count {
    font-size: 0.65rem;
  }
  
  .faq-accordion {
    gap: 0.4rem;
  }
  
  /* Mobile: Question with 12.5% increase */
  .faq-question {
    padding: 0.75rem 3rem 0.75rem 0.75rem; /* Right padding for arrow and tag */
    font-size: 0.98rem !important; /* Increased 12.5% from 0.875rem */
    line-height: 1.3;
    min-height: 2rem;
  }
  
  .faq-item.expanded .faq-question {
    border-bottom: 1px solid var(--faq-color-border);
    margin-bottom: 0.15rem;
  }
  
  .faq-question-text {
    padding-right: 0.5rem;
  }
  
  .faq-toggle-icon {
    right: 0.5rem;
  }
  
  /* Mobile: Show 1 line of answer preview */
  .faq-item:not(.expanded) .faq-answer {
    max-height: 1.6rem;
  }
  
  .faq-item.expanded .faq-answer {
    max-height: 2000px;
  }
  
  .faq-answer-content {
    padding: 0.35rem 0.75rem 0.5rem;
    font-size: 0.775rem;
    line-height: 1.35;
  }
  
  .faq-item:not(.expanded) .faq-answer-content {
    -webkit-line-clamp: 1;
    padding-top: 0.15rem;
  }
  
  /* Mobile "..." indicator */
  .faq-item:not(.expanded) .faq-answer.has-overflow::after {
    content: '...';
    right: 0.75rem;
    bottom: 0.1rem;
    font-size: 0.75rem;
    padding-left: 1.5rem;
  }
  
  /* Category tags on mobile - positioned vertically centered */
  .faq-category-tag {
    top: 50%;
    transform: translateY(-50%);
    right: 2.25rem; /* Clear of arrow */
  }
  
  .category-label {
    font-size: 0.4rem;
    padding: 0.1rem 0.25rem;
  }
  
  /* Cards on mobile - always single column */
  .faq-cards,
  .faq-cards[data-columns="1"],
  .faq-cards[data-columns="2"],
  .faq-cards[data-columns="3"] {
    grid-template-columns: 1fr !important;
    gap: 0.5rem; /* Reduced gap between cards */
  }
  
  .faq-card-content {
    padding: 0.75rem 0.75rem 0.5rem; /* Reduced bottom padding */
  }
  
  .faq-card-category {
    top: 0.4rem;
    right: 0.4rem;
  }
  
  .faq-category-badge {
    font-size: 0.4rem;
    padding: 0.1rem 0.25rem;
  }
  
  .faq-card {
    min-height: auto; /* Let content determine height on mobile */
  }
  
  .faq-card-question {
    font-size: 0.9rem !important; /* Slightly increased for better readability */
    margin-bottom: 0.25rem; /* Reduced spacing */
    padding-right: 2.5rem;
  }
  
  .faq-card-answer {
    font-size: 0.7rem !important;
    -webkit-line-clamp: 2;
    margin-bottom: 0; /* Remove bottom margin */
  }
  
  .faq-card-more {
    font-size: 0.6rem;
    margin-top: 0.15rem; /* Reduced spacing */
  }
  
  .faq-toggle-icon {
    width: 16px;
    height: 16px;
  }
  
  .faq-toggle-icon svg {
    width: 12px;
    height: 12px;
  }
  
  .faq-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
  }
  
  .faq-footer-text {
    font-size: 0.8rem;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .faq-cards[data-columns="3"] {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .faq-card-question {
    font-size: 1rem !important; /* Between desktop and mobile sizes */
  }
  
  .faq-card-answer {
    font-size: 0.8rem !important;
  }
}

/* Large desktop enhancements */
@media (min-width: 1024px) {
  .rjdev-faq-container {
    padding: 2rem;
    margin: 2rem 0;
  }
  
  .faq-search-wrapper {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 2rem;
  }
  
  .faq-category-filters {
    justify-content: center;
    margin-bottom: 2rem;
  }
  
  .faq-accordion {
    max-width: 900px;
    margin: 0 auto;
  }
  
  .faq-cards {
    gap: 1.5rem;
  }
}

/* Print styles */
@media print {
  .faq-search-wrapper,
  .faq-category-filters,
  .faq-footer {
    display: none;
  }
  
  .faq-style-accordion .faq-item {
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
  }
  
  .faq-answer {
    max-height: none !important;
    display: block !important;
  }
  
  .faq-toggle-icon {
    display: none;
  }
}

/* Accessibility improvements */
.faq-question:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

.faq-filter-btn:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

.faq-search-input:focus {
  outline: 2px solid #6b7280;
  outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .faq-style-accordion .faq-item {
    border-width: 2px;
  }
  
  .faq-filter-btn {
    border-width: 2px;
  }
  
  .faq-search-input {
    border-width: 2px;
  }
}

/* Dark mode support (optional) */
body.dark-mode .rjdev-faq-container {
  --faq-color-text: #f3f4f6;
  --faq-color-text-light: #9ca3af;
  --faq-color-text-answer: #d1d5db;
  --faq-color-border: #374151;
  --faq-color-bg: #1f2937;
  --faq-color-bg-light: #111827;
  --faq-color-primary-light: #1e3a8a;
}

body.dark-mode .rjdev-faq-container {
  background: var(--faq-color-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .faq-highlight {
  background-color: #854d0e;
  color: #fef3c7;
}
