// 신고대상, 프로세스, 수수료, 후기, FAQ 섹션들

// ─── 신고대상 안내 ────────────────────────────────────────────────────
function TargetSection() {
  const [tab, setTab] = React.useState('freelancer');
  const tabs = {
    freelancer: {
      label: '프리랜서',
      sub: '3.3% 원천징수 소득자',
      kind: 'freelancer',
      desc: '3.3% 원천징수한 소득이 있다면 모두 해당됩니다. 5월 신고로 떼인 세금을 환급받을 수 있어요.',
      jobs: ['배달대행 기사', '대리운전 기사', '보험설계사', '방문판매원', '학원강사', '프리랜서 디자이너', '프리랜서 작가', '강의·과외']
    },
    business: {
      label: '개인사업자',
      sub: '사업자등록증 보유',
      kind: 'business',
      desc: '사업자등록증을 가진 모든 개인사업자는 종합소득세 신고 대상입니다. 업종·매출 규모에 따라 장부 의무가 달라요.',
      jobs: ['음식점·카페', '온라인 셀러', '소매·도매', '미용·뷰티', '학원·교습소', '건설·인테리어', '병의원·약국', '기타 서비스업']
    },
    other: {
      label: '기타 소득자',
      sub: '근로 외 소득자',
      kind: 'worker',
      desc: '근로소득 외에 다른 소득이 있거나, 연말정산을 하지 못한 경우에도 5월 종합소득세로 정산해야 합니다.',
      jobs: ['임대소득', '이자·배당소득', '연금소득', '기타소득(강연료 등)', '연말정산 미이행', '중도퇴사자', '복수 근무지', '해외 소득']
    }
  };
  const cur = tabs[tab];

  return (
    <section className="section section-target" id="target">
      <div className="section-head">
        <div className="section-eyebrow">신고 대상 안내</div>
        <h2 className="section-title">
          이런 분들이 <span className="title-hl">신고 대상</span>이에요
        </h2>
        <p className="section-sub">탭을 눌러 신고대상에 해당되는지 확인해보세요!</p>
      </div>

      <div className="tabs">
        {Object.entries(tabs).map(([key, t]) =>
        <button key={key}
        className={`tab ${tab === key ? 'active' : ''}`}
        onClick={() => setTab(key)}>
            <span className="tab-label">{t.label}</span>
            <span className="tab-sub">{t.sub}</span>
          </button>
        )}
      </div>

      <div className="target-card" key={tab}>
        <div className="target-card-art">
          <div className="target-card-bg" />
          <PersonBlob kind={cur.kind} scale={1.1} />
          {/* 둘러싼 작은 서류들 */}
          <div className="target-orbit target-orbit-1">
            <PaperDoc accent="#2563EB" scale={0.4} />
          </div>
          <div className="target-orbit target-orbit-2">
            <PaperDoc accent="#FCD34D" scale={0.35} />
          </div>
          <div className="target-orbit target-orbit-3">
            <PaperDoc accent="#FBCFE8" scale={0.3} />
          </div>
        </div>
        <div className="target-card-body">
          <div className="target-card-tag">
            <CheckCircle size={20} color="#2563EB" />
            <span>{cur.label} · {cur.sub}</span>
          </div>
          <h3 className="target-card-title">{cur.label} 신고가 필요해요</h3>
          <p className="target-card-desc">{cur.desc}</p>
          <div className="target-jobs">
            {cur.jobs.map((j) =>
            <div key={j} className="job-chip">
                <span className="job-dot" />
                <span>{j}</span>
              </div>
            )}
          </div>
        </div>
      </div>
    </section>);

}

// ─── 업무 프로세스 ────────────────────────────────────────────────────
function ProcessSection() {
  const [active, setActive] = React.useState(0);
  const steps = [
  {
    num: '01',
    title: '간편인증으로 신청',
    desc: '카카오·네이버·통신사 인증으로\n1분 만에 자료 제출 완료',
    sub: '필요시 추가 서류를 요청드릴 수 있어요',
    art: 'auth'
  },
  {
    num: '02',
    title: '예상 세액 확인',
    desc: '담당 세무사가 검토 후\n예상 환급액 / 납부액 안내',
    sub: '카카오톡으로 결과를 받아보세요',
    art: 'review'
  },
  {
    num: '03',
    title: '수수료 결제',
    desc: '예상 세액 확인 후 진행 의사를\n밝히신 시점에 결제',
    sub: '결제 후 본 신고가 진행돼요',
    art: 'pay'
  },
  {
    num: '04',
    title: '신고 완료',
    desc: '국세청 신고 완료 및\n환급 일정 안내',
    sub: '환급금은 보통 6월 중 입금돼요',
    art: 'done'
  }];


  React.useEffect(() => {
    const id = setInterval(() => setActive((a) => (a + 1) % steps.length), 3500);
    return () => clearInterval(id);
  }, []);

  return (
    <section className="section section-process" id="process">
      <div className="section-head">
        <div className="section-eyebrow">업무 프로세스</div>
        <h2 className="section-title">
          이렇게 <span className="title-hl">간단</span>합니다
        </h2>
        <p className="section-sub">신청부터 신고 완료까지 평균 2~3일</p>
      </div>

      <div className="process-grid">
        {steps.map((s, i) =>
        <div key={i}
        className={`process-step ${active === i ? 'active' : ''}`}
        onMouseEnter={() => setActive(i)}>
            <div className="process-num">{s.num}</div>
            <div className="process-art">
              <ProcessArt kind={s.art} active={active === i} />
            </div>
            <h3 className="process-title">{s.title}</h3>
            <p className="process-desc">{s.desc}</p>
            <div className="process-sub">{s.sub}</div>
            {i < steps.length - 1 && <div className="process-arrow">→</div>}
          </div>
        )}
      </div>
    </section>);

}

function ProcessArt({ kind, active }) {
  if (kind === 'auth') {
    return (
      <svg viewBox="0 0 160 120" width="160" height="120">
        <rect x="40" y="10" width="80" height="100" rx="12" fill="#FFFFFF" stroke="#DBEAFE" strokeWidth="2" />
        <rect x="50" y="22" width="60" height="6" rx="3" fill="#2563EB" />
        <rect x="50" y="36" width="60" height="20" rx="6" fill="#F1F5F9" />
        <circle cx="60" cy="46" r="5" fill="#FCD34D" />
        <rect x="70" y="44" width="32" height="4" rx="2" fill="#94A3B8" />
        <rect x="50" y="60" width="60" height="20" rx="6" fill="#F1F5F9" />
        <circle cx="60" cy="70" r="5" fill="#22C55E" />
        <rect x="70" y="68" width="32" height="4" rx="2" fill="#94A3B8" />
        <rect x="50" y="88" width="60" height="14" rx="7" fill="#2563EB" />
        <FingerTapInline x={108} y={70} active={active} />
      </svg>);

  }
  if (kind === 'review') {
    return (
      <svg viewBox="0 0 160 120" width="160" height="120">
        <rect x="20" y="20" width="120" height="80" rx="10" fill="#FFFFFF" stroke="#DBEAFE" strokeWidth="2" />
        <rect x="32" y="32" width="50" height="6" rx="3" fill="#1E40AF" />
        <rect x="32" y="44" width="96" height="3" rx="1.5" fill="#CBD5E1" />
        <rect x="32" y="52" width="80" height="3" rx="1.5" fill="#CBD5E1" />
        <rect x="32" y="66" width="40" height="26" rx="6" fill="#DBEAFE" />
        <text x="52" y="78" textAnchor="middle" fontSize="9" fontWeight="700" fill="#1E40AF">예상</text>
        <text x="52" y="89" textAnchor="middle" fontSize="10" fontWeight="800" fill="#2563EB">+421,300</text>
        <rect x="76" y="66" width="52" height="26" rx="6" fill="#FEF3C7" />
        <text x="102" y="78" textAnchor="middle" fontSize="9" fontWeight="700" fill="#92400E">환급</text>
        <text x="102" y="89" textAnchor="middle" fontSize="10" fontWeight="800" fill="#B45309">조회중</text>
        {active && <circle cx="80" cy="60" r="40" fill="none" stroke="#2563EB" strokeWidth="1.5" opacity=".3" className="ping" />}
      </svg>);

  }
  if (kind === 'pay') {
    return (
      <svg viewBox="0 0 160 120" width="160" height="120">
        <rect x="24" y="36" width="112" height="64" rx="10" fill="#1E3A8A" />
        <rect x="24" y="48" width="112" height="12" fill="#0F172A" />
        <rect x="36" y="72" width="40" height="6" rx="2" fill="#FCD34D" />
        <rect x="36" y="82" width="60" height="4" rx="2" fill="#FFFFFF" opacity=".6" />
        <circle cx="116" cy="84" r="8" fill="#FBCFE8" opacity=".9" />
        <circle cx="124" cy="84" r="8" fill="#FCD34D" opacity=".9" />
        <rect x="40" y="14" width="32" height="22" rx="4" fill="#22C55E" />
        <text x="56" y="28" textAnchor="middle" fontSize="10" fontWeight="800" fill="#FFFFFF">완료</text>
      </svg>);

  }
  // done
  return (
    <svg viewBox="0 0 160 120" width="160" height="120">
      <circle cx="80" cy="60" r="38" fill="#DBEAFE" />
      <circle cx="80" cy="60" r="28" fill="#2563EB" />
      <path d="M68 60 L76 68 L92 52" stroke="#FFFFFF" strokeWidth="4" fill="none" strokeLinecap="round" strokeLinejoin="round" />
      {/* 컨페티 */}
      <circle cx="36" cy="32" r="3" fill="#FCD34D" />
      <rect x="120" y="28" width="6" height="6" rx="1" fill="#FBCFE8" transform="rotate(20 123 31)" />
      <circle cx="130" cy="80" r="3" fill="#22C55E" />
      <rect x="32" y="92" width="6" height="6" rx="1" fill="#3B82F6" transform="rotate(-20 35 95)" />
    </svg>);

}

function FingerTapInline({ x, y, active }) {
  return (
    <g transform={`translate(${x} ${y})`} className={active ? 'finger-anim' : ''}>
      <circle cx="0" cy="0" r="14" fill="#FCD34D" opacity=".4" />
      <circle cx="0" cy="0" r="8" fill="#FCD34D" />
    </g>);

}

// ─── 수수료 ────────────────────────────────────────────────────────────
function FeeSection({ tweaks }) {
  const { feeSimple, feeDouble } = tweaks;
  const fees = [
  {
    type: 'simple',
    title: '간편장부 대상자',
    sub: '신고유형:',
    price: feeSimple,
    from: true,
    who: ['프리랜서·3.3% 소득자', '소규모 개인사업자', '연 수입 일정 기준 이하'],
    icon: 'simple',
    bg: '#DBEAFE'
  },
  {
    type: 'double',
    title: '복식부기 대상자',
    sub: '신고유형:',
    price: feeDouble,
    from: true,
    who: ['중규모 이상 개인사업자', '전문직 사업자', '연 수입 일정 기준 초과'],
    icon: 'double',
    bg: '#1E40AF',
    dark: true
  }];


  return (
    <section className="section section-fee" id="fee">
      <div className="section-head">
        <div className="section-eyebrow">신고 수수료 안내</div>
        <h2 className="section-title">
          <span className="title-hl">투명</span>한 수수료
        </h2>
        <p className="section-sub">숨은 비용 없이 명확하게 안내드려요</p>
      </div>

      <div className="fee-grid">
        {fees.map((f) =>
        <div key={f.type} className={`fee-card ${f.dark ? 'fee-card-dark' : ''}`} style={{ '--bg': f.bg }}>
            <div className="fee-icon-wrap">
              <FeeIcon kind={f.icon} dark={f.dark} />
            </div>
            <div className="fee-tag">{f.sub}</div>
            <h3 className="fee-title">{f.title}</h3>
            <div className="fee-price">
              <span className="fee-price-from">{f.from ? '최소' : ''}</span>
              <span className="fee-price-num">{f.price.toLocaleString()}</span>
              <span className="fee-price-unit">원~</span>
            </div>
            <ul className="fee-who">
              {f.who.map((w) =>
            <li key={w}>
                  <CheckCircle size={18} color={f.dark ? '#FCD34D' : '#2563EB'} />
                  <span>{w}</span>
                </li>
            )}
            </ul>
            <button className={f.dark ? 'fee-cta fee-cta-dark' : 'fee-cta'}>
              간편인증으로 신청 →
            </button>
          </div>
        )}
      </div>

      <div className="fee-note">
        <span className="fee-note-badge">참고</span>
        신고 수수료는 매출 · 소득 유형 · 신고 유형에 따라 차등 책정되며, 예상 세액 안내 및 상담 후 최종 안내드리며, 상기 수수료는 VAT 별도 금액입니다.
      </div>
    </section>);

}

function FeeIcon({ kind, dark }) {
  if (kind === 'simple') {
    return (
      <svg viewBox="0 0 80 80" width="80" height="80">
        <circle cx="40" cy="40" r="36" fill="#FFFFFF" />
        <rect x="22" y="20" width="36" height="44" rx="6" fill="#2563EB" />
        <rect x="28" y="28" width="24" height="3" rx="1.5" fill="#FFFFFF" opacity=".7" />
        <rect x="28" y="36" width="20" height="3" rx="1.5" fill="#FFFFFF" opacity=".5" />
        <rect x="28" y="44" width="24" height="3" rx="1.5" fill="#FFFFFF" opacity=".5" />
        <circle cx="48" cy="56" r="6" fill="#FCD34D" />
      </svg>);

  }
  return (
    <svg viewBox="0 0 80 80" width="80" height="80">
      <circle cx="40" cy="40" r="36" fill={dark ? '#FCD34D' : '#FFFFFF'} />
      <rect x="18" y="22" width="22" height="40" rx="4" fill={dark ? '#1E3A8A' : '#2563EB'} />
      <rect x="40" y="22" width="22" height="40" rx="4" fill={dark ? '#3B82F6' : '#1E40AF'} />
      <rect x="22" y="28" width="14" height="2" rx="1" fill="#FFFFFF" opacity=".7" />
      <rect x="22" y="34" width="10" height="2" rx="1" fill="#FFFFFF" opacity=".5" />
      <rect x="44" y="28" width="14" height="2" rx="1" fill="#FFFFFF" opacity=".7" />
      <rect x="44" y="34" width="10" height="2" rx="1" fill="#FFFFFF" opacity=".5" />
    </svg>);

}

// ─── 후기 ──────────────────────────────────────────────────────────────
function ReviewSection() {
  const reviews = [
  { name: '김*현', job: '배달기사', rating: 5, body: '매년 세무서 갔다오느라 반차 썼는데, 이번엔 카톡으로 5분 만에 끝났어요. 환급도 작년보다 더 받았네요.', refund: '+412,000원', tag: '환급' },
  { name: '이*수', job: '프리랜서 디자이너', rating: 5, body: '간편인증 하니까 자료가 알아서 쫙 모이더라구요. 처음엔 신기했는데 진짜 편해요.', refund: '+287,500원', tag: '환급' },
  { name: '박*영', job: '학원강사', rating: 5, body: '예상세액 미리 알려주시고 결제 후 신고하는 구조라 안심됐어요. 수수료도 합리적.', refund: '+523,400원', tag: '환급' },
  { name: '정*민', job: '대리운전', rating: 5, body: '서류가 뭔지도 모르겠고 매년 미루기만 했는데 카톡으로 다 처리해주셔서 살았어요.', refund: '+198,200원', tag: '환급' },
  { name: '최*우', job: '온라인 셀러', rating: 4, body: '복식부기 신고 대상이라 걱정했는데 담당자가 꼼꼼히 챙겨주셨습니다. 추천합니다.', refund: '신고완료', tag: '신고' },
  { name: '한*아', job: '보험설계사', rating: 5, body: '상담부터 결제까지 전부 비대면. 사무실 안 가도 되니까 시간 절약 최고예요.', refund: '+315,800원', tag: '환급' }];


  return (
    <section className="section section-review" id="review">
      <div className="section-head">
        <div className="section-eyebrow">고객 후기</div>
        <h2 className="section-title">
          <span className="title-hl">이용</span> 고객님들의 후기
        </h2>
        <p className="section-sub">실제 신고를 마친 고객님들이 남겨주신 이야기</p>
      </div>

      <div className="review-grid">
        {reviews.map((r, i) =>
        <div key={i} className="review-card">
            <div className="review-stars">
              {[1, 2, 3, 4, 5].map((s) => <Star key={s} size={16} filled={s <= r.rating} />)}
            </div>
            <p className="review-body">{r.body}</p>
            <div className="review-meta">
              <div className="review-person">
                <div className="review-avatar" style={{ background: ['#FCD34D', '#FBCFE8', '#A7F3D0', '#BFDBFE', '#DDD6FE', '#FED7AA'][i % 6] }}>
                  {r.name[0]}
                </div>
                <div>
                  <div className="review-name">{r.name}</div>
                  <div className="review-job">{r.job}</div>
                </div>
              </div>
              <div className={`review-refund review-refund-${r.tag === '환급' ? 'refund' : 'done'}`}>
                {r.refund}
              </div>
            </div>
          </div>
        )}
      </div>
    </section>);

}

// ─── FAQ ──────────────────────────────────────────────────────────────
function FaqSection() {
  const [open, setOpen] = React.useState(0);
  const faqs = [
  { q: '간편인증은 안전한가요?', a: '네, 카카오·네이버·통신사 등 공인된 인증기관을 통해서만 자료를 수취합니다. 별도로 비밀번호나 공인인증서를 저장하지 않으며, 자료는 신고 목적 외에는 사용되지 않습니다.' },
  { q: '신고는 얼마나 걸리나요?', a: '간편인증으로 자료 수취 후 평균 2~3일 이내에 예상 세액을 안내드립니다. 결제 후 본 신고는 당일 또는 익일 처리됩니다.' },
  { q: '환급금은 언제 받나요?', a: '5월 신고분의 환급금은 일반적으로 6월 말 ~ 7월 초에 본인 계좌로 입금됩니다. 신고 완료 후 정확한 일정을 카카오톡으로 안내드립니다.' },
  { q: '추가 서류가 필요할 수 있나요?', a: '간편인증으로 대부분의 자료가 자동 수취되지만, 사업자별 특수 사항이 있을 경우 추가 서류를 요청드릴 수 있습니다. 카카오톡으로 안내해드립니다.' },
  { q: '수수료는 언제 결제하나요?', a: '예상 세액 확인 후, 진행 의사를 밝히신 시점에 결제가 진행됩니다. 결제 전에는 어떤 비용도 청구되지 않습니다.' },
  { q: '신고하지 않으면 어떻게 되나요?', a: '신고 의무가 있는데 누락하면 무신고 가산세(20%)와 납부지연 가산세가 부과됩니다. 환급 대상자라도 신고하지 않으면 환급받을 수 없습니다.' }];


  return (
    <section className="section section-faq" id="faq">
      <div className="section-head">
        <div className="section-eyebrow">자주 묻는 질문</div>
        <h2 className="section-title">
          궁금한 점이 있으신가요?
        </h2>
        <p className="section-sub">자주 묻는 질문을 모았어요. 추가 문의는 카카오톡으로 간편하게!</p>
      </div>

      <div className="faq-list">
        {faqs.map((f, i) =>
        <div key={i} className={`faq-item ${open === i ? 'open' : ''}`}>
            <button className="faq-q" onClick={() => setOpen(open === i ? -1 : i)}>
              <span className="faq-q-mark">Q</span>
              <span className="faq-q-text">{f.q}</span>
              <span className="faq-q-toggle">{open === i ? '−' : '+'}</span>
            </button>
            {open === i &&
          <div className="faq-a">
                <span className="faq-a-mark">A</span>
                <p>{f.a}</p>
              </div>
          }
          </div>
        )}
      </div>
    </section>);

}

// ─── 최종 CTA ──────────────────────────────────────────────────────────
function FinalCta() {
  return (
    <section className="section section-final-cta">
      <div className="final-cta-card">
        <div className="final-cta-bg-blob" />
        <div className="final-cta-bg-blob final-cta-bg-blob-2" />
        <div className="final-cta-content">
          <div className="final-cta-eyebrow">5월 종합소득세 신고시즌</div>
          <h2 className="final-cta-title">
            지금 바로<br />
            <span className="title-hl-on-dark">간편인증</span>으로 시작하세요
          </h2>
          <p className="final-cta-sub">3분이면 자료 제출 끝. 예상 환급액 무료로 확인하세요.</p>
          <div className="final-cta-row">
            <button className="cta-primary cta-primary-lg">간편인증으로 시작하기 →</button>
            <a className="cta-kakao" href="https://pf.kakao.com/_NxaUyG/chat" target="_blank" rel="noopener noreferrer">
              <KakaoIcon size={20} />
              카카오톡으로 문의
            </a>
          </div>
        </div>
        <div className="final-cta-art">
          <PhoneAuth scale={0.7} glow />
        </div>
      </div>
    </section>);

}

// ─── 푸터 ──────────────────────────────────────────────────────────────
function Footer() {
  return (
    <footer className="footer">
      <div className="footer-inner">
        <div className="footer-brand">
          <div className="brand-logo">
            <svg viewBox="0 0 32 32" width="28" height="28">
              <rect x="2" y="2" width="28" height="28" rx="8" fill="#2563EB" />
              <path d="M10 12 L16 18 L22 10" stroke="#FFFFFF" strokeWidth="3" fill="none" strokeLinecap="round" strokeLinejoin="round" />
              <rect x="10" y="20" width="12" height="3" rx="1.5" fill="#FCD34D" />
            </svg>
            <div>
              <div className="brand-name">한국세금신고센터</div>
              <div className="brand-en">KOREA TAX CENTER</div>
            </div>
          </div>
          <p className="footer-desc">
            세무그룹 서울택스와 함께하는 프리랜서와 개인사업자를 위한<br />
            세상에서 가장 쉽고 편한 종합소득세 신고대리 서비스
          </p>
          <div className="footer-company">
            <div>세무그룹 서울택스 | 대표세무사: 윤하진 | 사업자등록번호: 269-26-01724</div>
            <div>서울특별시 강남구 역삼로 122, 301호 (역삼동, 하나빌딩)</div>
          </div>
        </div>
      </div>
      <div className="footer-bottom">
        <span>© 세무그룹 서울택스 | 한국세금신고센터 KOREA TAX CENTER. All rights reserved.</span>
      </div>
    </footer>);

}

Object.assign(window, { TargetSection, ProcessSection, FeeSection, ReviewSection, FaqSection, FinalCta, Footer });