/**
 * TradeCalcs FAQ Accordion Styles
 * Customizable via CSS variables
 * Version 1.0.0
 */

/* CSS Variables for easy theming */
:root {
  --tc-faq-bg: #ffffff;
  --tc-faq-border: #e5e7eb;
  --tc-faq-question-color: #111827;
  --tc-faq-answer-color: #4b5563;
  --tc-faq-hover-bg: #f9fafb;
  --tc-faq-active-bg: #f3f4f6;
  --tc-faq-icon-color: #6b7280;
  --tc-faq-radius: 8px;
  --tc-faq-spacing: 1rem;
  --tc-faq-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Container */
[data-tradecalcs-faq] {
  font-family: var(--tc-faq-font-family);
  max-width: 100%;
}

/* FAQ Item */
.tc-faq-item {
  background: var(--tc-faq-bg);
  border: 1px solid var(--tc-faq-border);
  border-radius: var(--tc-faq-radius);
  margin-bottom: var(--tc-faq-spacing);
  overflow: hidden;
  transition: box-shadow 150ms ease;
}

.tc-faq-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tc-faq-item:last-child {
  margin-bottom: 0;
}

/* Question (clickable header) */
.tc-faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--tc-faq-question-color);
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease;
  position: relative;
}

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

.tc-faq-question:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.tc-faq-question:active {
  background: var(--tc-faq-active-bg);
}

/* Answer (collapsible content) */
.tc-faq-answer {
  padding: 0 1.25rem 1rem 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--tc-faq-answer-color);
}

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

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

/* Icons */
.tc-faq-icon {
  flex-shrink: 0;
  margin-left: 1rem;
  color: var(--tc-faq-icon-color);
  transition: transform 300ms ease;
}

/* Chevron Icon */
.tc-faq-icon-chevron::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 300ms ease;
}

.tc-faq-open .tc-faq-icon-chevron::before {
  transform: rotate(-135deg);
}

/* Plus/Minus Icon */
.tc-faq-icon-plus {
  position: relative;
  width: 20px;
  height: 20px;
}

.tc-faq-icon-plus::before,
.tc-faq-icon-plus::after {
  content: '';
  position: absolute;
  background: currentColor;
  transition: transform 300ms ease, opacity 300ms ease;
}

.tc-faq-icon-plus::before {
  width: 100%;
  height: 2px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.tc-faq-icon-plus::after {
  width: 2px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.tc-faq-open .tc-faq-icon-plus::after {
  transform: translateX(-50%) rotate(90deg);
  opacity: 0;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .tc-faq-question {
    font-size: 1rem;
    padding: 0.875rem 1rem;
  }

  .tc-faq-answer {
    font-size: 0.875rem;
    padding: 0 1rem 0.875rem 1rem;
  }

  .tc-faq-icon {
    margin-left: 0.75rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .tc-faq-question,
  .tc-faq-item,
  .tc-faq-icon,
  .tc-faq-icon-chevron::before,
  .tc-faq-icon-plus::before,
  .tc-faq-icon-plus::after {
    transition: none;
  }

  .tc-faq-answer {
    transition: none !important;
  }
}

/* Dark Mode Support (optional, uses prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
  :root {
    --tc-faq-bg: #1f2937;
    --tc-faq-border: #374151;
    --tc-faq-question-color: #f9fafb;
    --tc-faq-answer-color: #d1d5db;
    --tc-faq-hover-bg: #111827;
    --tc-faq-active-bg: #0f172a;
    --tc-faq-icon-color: #9ca3af;
  }
}
