/**
 * AI FAQ Generator - Polished Frontend Styles
 * FAQ / Follow-up / Quiz / Chatbot / Summary
 */

/* --- 공통 색/여백 스케일 --- */
:root {
  --aifaq-bg: #f3f4ff;         /* 연보라 배경 */
  --aifaq-brd: #e0e6ff;        /* 은은한 테두리 */
  --aifaq-accent: #6366f1;     /* 보라 포인트 */
  --aifaq-accent-weak: #818cf8;
  --aifaq-text-strong: #1e1b4b;
  --aifaq-text: #334155;
  --aifaq-muted: #64748b;
  --aifaq-white: #fff;
  --aifaq-radius: 10px;
  --aifaq-gap: 10px;
}
/* ========= ✨ [요약] Summary Box ========= */
.ai-summary-box {
  margin-bottom: 1em;
  border-radius: 15px;
}

/* 헤더 스타일 */
.summary-header {
  display: flex;
  margin-bottom: 15px;
  align-items: center;
  gap: 15px;
  margin: 0;
  padding: 15px;
  justify-content: space-between;
  background: #f0f4ff;
  border-radius: 10px;
  border-bottom: 2px solid #f0f0f0;
}

.summary-title {
  font-weight: 700;
  font-size: 1.3em;
  color: #667eea;
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-toggle {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 25px;
  font-size: 0.9em;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.summary-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.summary-toggle:active {
  transform: translateY(0);
}

/* 요약 옵션 버튼 스타일 */
.summary-options {
  display: flex;
  display:none;
  gap: 10px;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin-bottom: 20px;
}

.summary-options button {
  flex: none;
  padding: 10px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  background-color: white;
  color: #666;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95em;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.summary-options button:hover {
  border-color: #667eea;
  color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.2);
}

.summary-options button.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.summary-options button.active::after {
  content: '✓';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8em;
}

/* 요약 콘텐츠 래퍼 */
.summary-content-wrapper {
  display:none;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 25px;
  border: none;
  border-left: 4px solid #667eea;
  position: relative;
  animation: fadeIn 0.5s ease forwards;
}

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

/* 요약 콘텐츠 */
.summary-content {
  line-height: 1.8;
  color: #444;
  margin-bottom: 0;
  font-size: 1.05em;
}
.summary-content p{margin-bottom:15px;}

/* 짧은 요약 스타일 */
.summary-content.short {
  display:none;
  font-weight: 500;
  color: #333;
  padding: 10px 0;
}

/* 보통 요약 리스트 스타일 */
.summary-content.normal {
  display:none;
  padding-left: 0;
}

.summary-content.short ul,
.summary-content.normal ul,
.summary-content.detailed ul{
  margin: 0;
}

.summary-content.short li,
.summary-content.normal li,
.summary-content.detailed li{
  position: relative;
  padding-left: 20px;
  line-height: 1.8;
}

.summary-content.short li::before,
.summary-content.normal li::before,
.summary-content.detailed li::before{
  content: "✓";
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
  font-size: 1.2em;
  top: -2px;
}
.summary-content.short ul,
.summary-content.normal ul,
.summary-content.detailed ul{
  list-style: none;
}

/* 상세 요약 스타일 */
.summary-content.detailed {
  border-radius: 8px;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .ai-summary-box {
    margin-bottom: 1.5em;
  }
  
  .summary-title {
    font-size: 1.1em;
  }
  
  .summary-options {
    flex-wrap: wrap;
  }
  
  .summary-options button {
    padding: 8px 16px;
    font-size: 0.9em;
  }
  
  .summary-content-wrapper {
    padding: 20px;
  }
  
  .summary-content {
    font-size: 1em;
  }
}

/* 애니메이션 효과 추가 */
.summary-content-wrapper {
  opacity: 0;
  animation: slideIn 0.5s ease forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}


@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 로딩 상태 (필요시 사용) */
.summary-loading {
  text-align: center;
  padding: 30px;
  color: #667eea;
}

.summary-loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ========= 1) FAQ ========= */
.ai-faq-box {
  margin: 1.5em 0;
  background: var(--aifaq-bg);
  border: 1px solid var(--aifaq-brd);
  border-left: 5px solid var(--aifaq-accent);
  border-radius: var(--aifaq-radius);
  padding: 20px;
  overflow: hidden;
}

.ai-faq-box .faq-header {
  font-weight: 600;
  font-size: 0.95em;
  color: #4338ca;
  margin: 0 0 14px 0;
}

/* 질문 행 */
.ai-faq-box .faq-question {
  font-weight: 600;
  font-size: 1.1em;
  color: var(--aifaq-text-strong);
  cursor: pointer;
  margin: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.ai-faq-box .faq-question .question-text { flex: 1; }
.ai-faq-box .faq-question .question-icon {
  font-style: normal; font-weight: bold;
  color: var(--aifaq-accent-weak);
  transition: transform .2s ease-in-out;
}
.ai-faq-box .faq-question.active .question-icon { transform: rotate(180deg); }

/* 답변 */
.ai-faq-box .faq-answer {
  color: var(--aifaq-text);
  line-height: 1.7;
  padding: 15px 0 5px 0;
  margin-top: 5px;
  border-top: 1px solid #d9dffa;
}
.ai-faq-box .faq-answer p:first-child { margin-top: 0; }
.ai-faq-box .faq-answer p:last-child { margin-bottom: 0; }

/* 접근성 포커스 */
.ai-faq-box .faq-question:focus-visible {
  outline: 2px solid var(--aifaq-accent);
  outline-offset: 2px; border-radius: 6px;
}

/* Follow-up 입력 UI */
.ai-faq-box .faq-followup { display: flex; gap: 8px; margin: 14px 0px 14px 0px;}
.ai-faq-box .faq-followup .followup-input {
  flex: 1; padding: 10px 12px;
  border: 1px solid #d9dffa; border-radius: 8px; background: var(--aifaq-white);
}
.ai-faq-box .faq-followup .followup-submit {
  padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--aifaq-accent); background: var(--aifaq-accent);
  color: #fff; cursor: pointer;
}
.ai-faq-box .faq-followup .followup-submit:disabled { opacity: .6; cursor: not-allowed; }

/* ========= 2) Quiz (동의/반대) ========= */
.ai-quiz-box {
  margin: 2.5em 0;
  background: var(--aifaq-white);
  border: 1px solid #e5e7eb;
  border-top: 4px solid var(--aifaq-accent); /* 상단에 강조 테두리 추가 */
  border-radius: var(--aifaq-radius);
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); /* 부드러운 그림자 효과 */
  text-align: center; /* 내부 요소 가운데 정렬 */
}

.ai-quiz-box .quiz-header {
  margin: 0 0 8px;
  color: var(--aifaq-muted);
  font-weight: 600;
  font-size: 0.9em;
}

.ai-quiz-box .quiz-statement {
  margin: 0 0 18px;
  font-size: 1.25em; /* 폰트 크기 강조 */
  font-weight: 600;
  color: var(--aifaq-text-strong);
}

.ai-quiz-box .quiz-actions {
  display: flex; /* Flexbox를 사용하여 버튼을 좌우로 배치 */
  gap: var(--aifaq-gap);
  justify-content: center; /* 버튼 그룹을 중앙에 위치 */
}

/* 개별 버튼 기본 스타일 */
.ai-quiz-box .quiz-option {
  flex: 1; /* 버튼이 공간을 균등하게 차지하도록 설정 */
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--aifaq-brd);
  background: transparent;
  color: var(--aifaq-text);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease-in-out; /* 부드러운 전환 효과 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* 아이콘 추가 (FontAwesome 등 아이콘 라이브러리 필요 시) */
.ai-quiz-box .quiz-option[data-option="agree"]::before { content: '👍'; }
.ai-quiz-box .quiz-option[data-option="disagree"]::before { content: '👎'; }


/* 동의 버튼 스타일 */
.ai-quiz-box .quiz-option[data-option="agree"] {
    border-color: var(--aifaq-accent-weak);
}
.ai-quiz-box .quiz-option[data-option="agree"]:hover {
  transform: translateY(-2px);
  background: var(--aifaq-accent);
  border-color: var(--aifaq-accent);
  color: var(--aifaq-white);
}

/* 반대 버튼 스타일 */
.ai-quiz-box .quiz-option[data-option="disagree"] {
    border-color: #d1d5db; /* 회색 테두리 */
}
.ai-quiz-box .quiz-option[data-option="disagree"]:hover {
  transform: translateY(-2px);
  background: #4b5563; /* 진한 회색 */
  border-color: #4b5563;
  color: var(--aifaq-white);
}

.ai-quiz-box .quiz-option:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.ai-quiz-box .quiz-result {
  margin-top: 16px;
  color: var(--aifaq-text);
  font-weight: 500;
  font-size: 0.95em;
}

/* ========= 3) Chatbot ========= */
.ai-chatbot-box {
  margin: 2.5em 0;
  border: 1px solid #e5e7eb;
  border-radius: var(--aifaq-radius);
  padding: 18px;
  background: var(--aifaq-white);
}
.ai-chatbot-box .chatbot-header { margin: 0 0 10px; color: var(--aifaq-muted); font-weight: 600; }
.ai-chatbot-box .chatbot-window {
  max-height: 280px; overflow: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 2px; /* 스크롤바 간격 */
}
.ai-chatbot-box .chat-row { max-width: 85%; padding: 10px 12px; border-radius: 12px; line-height: 1.6; }
.ai-chatbot-box .chat-row.user { align-self: flex-end; background: #e0e7ff; color: #111827; }
.ai-chatbot-box .chat-row.bot  { align-self: flex-start; background: #f1f5f9; color: #0f172a; }
.ai-chatbot-box .chatbot-input { display: flex; gap: var(--aifaq-gap); margin-top: 10px; }
.ai-chatbot-box input.chatbot-text {
  flex: 1; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #d1d5db;
}
.ai-chatbot-box .chatbot-send {
  padding: 10px 14px; border-radius: 8px;
  background: #6366F9; cursor: pointer;
}
.ai-chatbot-box .chatbot-send:disabled { opacity: .6; cursor: not-allowed; }

/* ===== Poll Results Section - ✨ 개선된 디자인 ===== */
.ai-quiz-results {
  margin: 2.5em 0;
  padding: 24px;
  border: 1px solid #e5e7eb;
  border-radius: var(--aifaq-radius);
  background: #f9fafb; /* 살짝 어두운 배경으로 구분 */
}

.ai-quiz-results .results-title {
  margin: 0 0 18px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--aifaq-text-strong);
  text-align: center; /* 제목 중앙 정렬 */
}

.ai-quiz-results .result-row {
  margin-bottom: 20px;
}
.ai-quiz-results .result-row:last-child {
  margin-bottom: 0;
}

.ai-quiz-results .result-statement {
  margin-bottom: 8px;
  color: var(--aifaq-text-strong);
  font-weight: 600;
  font-size: 1.05em;
}

/* 막대 그래프 컨테이너 */
.ai-quiz-results .bar-wrap {
  display: flex; /* 내부 막대를 좌우로 배치 */
  height: 16px; /* 막대 높이 증가 */
  border-radius: 9999px;
  overflow: hidden;
  background: #e5e7eb; /* 막대 기본 배경색 */
  border: 1px solid #e2e8f0;
}

/* 동의(Agree) 막대 스타일 */
.ai-quiz-results .bar-agree {
  background: var(--aifaq-accent); /* 투표 버튼과 동일한 강조색 */
  transition: width 0.5s ease-in-out;
}

/* 반대(Disagree) 막대 스타일 */
.ai-quiz-results .bar-disagree {
  background: #a5b4fc; /* 동의보다 연한 보라색 계열 */
  transition: width 0.5s ease-in-out;
}

/* 범례(Legend) 스타일 */
.ai-quiz-results .legend {
  margin-top: 8px;
  color: var(--aifaq-muted);
  font-weight: 600;
  display: flex;
  gap: 16px; /* 항목 간 간격 증가 */
  align-items: center;
  font-size: 0.9em;
}

/* 범례 내부 색상 강조 */
.ai-quiz-results .legend .agree {
  color: var(--aifaq-accent);
  font-weight: 700;
}

.ai-quiz-results .legend .disagree {
  color: #475569;
  font-weight: 700;
}

.ai-quiz-results .legend .total {
    margin-left: auto; /* 총 투표 수를 오른쪽으로 정렬 */
    font-size: 0.95em;
    color: var(--aifaq-text);
}

/* 기존 스타일 유지 또는 삭제 */
.site-main .wp-block-group__inner-container { padding: 0px !important; }
@media (max-width: 768px) {
  .site-main .wp-block-group__inner-container { padding: 0px !important; }
}
