/* ===== Panex — Legal documents (개인정보처리방침 / 이용약관) ===== */

const LEGAL_CONTACT = "kimwilly045@gmail.com";

const LEGAL_META = {
  ko: { effective: "2026년 6월 17일", effLabel: "시행일" },
  en: { effective: "June 17, 2026", effLabel: "Effective" },
};

/* ---------- 한국어 ---------- */
/* 개인정보처리방침 — 실제 동작(비회원·무저장·분석 직후 폐기·외부 AI 처리위탁) 기준으로 작성 */
const PRIVACY_KO = {
  title: "개인정보처리방침",
  intro:
    "리뷰썸(이하 “서비스”)은 이용자의 개인정보를 소중히 다루며, 「개인정보 보호법」 등 관련 법령을 준수합니다. 서비스는 회원가입 없이 이용되며, 분석을 위해 업로드한 대화는 별도로 저장하지 않습니다. 본 방침은 서비스가 어떤 정보를 어떻게 처리하는지 설명합니다.",
  sections: [
    { h: "1. 수집하는 정보와 수집 방법", body: [
      "서비스는 회원가입·로그인 절차가 없으며, 이름·연락처 등 개인정보를 입력받지 않습니다.",
      "이용자가 분석을 위해 직접 업로드하는 “대화 스크린샷 이미지”와 그 이미지에서 추출된 “대화 텍스트”를 처리합니다. 대화 내용에는 대화 상대의 이름(또는 닉네임), 대화에 포함된 개인적인 내용 등이 담길 수 있습니다.",
      "위 정보는 이용자가 업로드 버튼을 눌러 직접 제출하는 경우에만 처리되며, 그 외에 자동으로 수집하는 정보는 없습니다.",
    ]},
    { h: "2. 정보의 이용 목적", body: [
      "업로드된 이미지와 추출된 텍스트는 오직 “대화 분석 결과(점수·온도 흐름·하이라이트·복기·추천 메시지 등)를 생성하여 화면에 보여주는 것”에만 사용됩니다.",
      "광고, 마케팅, 이용자 식별, 프로파일링 등 다른 목적으로는 이용하지 않습니다.",
    ]},
    { h: "3. 보관 및 파기", body: [
      "업로드된 이미지와 추출 텍스트는 분석 처리에 필요한 순간에만 메모리에서 사용되며, 분석이 끝나면 서버에 저장하지 않고 즉시 폐기합니다.",
      "분석 결과 또한 서버에 저장되지 않고 이용자의 브라우저 화면에만 표시되며, 화면을 닫거나 새로고침하면 사라집니다.",
      "따라서 서비스는 이용자의 대화 데이터를 보관하는 데이터베이스를 운영하지 않습니다.",
    ]},
    { h: "4. 처리 위탁 및 국외 이전", body: [
      "정확한 분석을 위해 업로드한 대화 스크린샷 이미지는 아래의 외부 AI 처리업체로 전송되어 처리됩니다. 각 업체는 전송된 데이터를 자사 정책에 따라 처리합니다.",
      "· 대화 분석(이미지 내 텍스트 인식 포함): OpenAI — GPT-4o 멀티모달 분석 API (서버 위치: 국외)",
      "· 서비스 호스팅: Vercel Inc. (서버 위치: 국외)",
      "위 전송은 분석 결과 제공이라는 목적 달성을 위해 필요한 범위에서 이루어지며, 이용자는 본 방침에 동의하지 않을 경우 대화를 업로드하지 않음으로써 서비스 이용을 중단할 수 있습니다. 각 업체의 개인정보 처리에 관한 자세한 내용은 해당 업체의 정책을 따릅니다.",
    ]},
    { h: "5. 쿠키 및 추적 도구", body: [
      "서비스는 서비스 개선을 위한 방문 분석과 운영을 위한 광고 게재를 목적으로 아래의 제3자 도구를 사용하며, 이 과정에서 쿠키 또는 유사 기술이 사용될 수 있습니다.",
      "· 방문 분석: Google Analytics (Google LLC) — 페이지 방문수·이용 통계를 집계합니다. 개별 이용자를 식별하기 위한 것이 아닙니다.",
      "· 광고: Google AdSense (Google LLC) — 서비스 운영을 위해 광고를 게재하며, 이 과정에서 광고용 쿠키가 사용될 수 있습니다. Google은 쿠키를 사용하여 이용자의 이 사이트 및 다른 사이트 방문 기록을 바탕으로 광고를 제공할 수 있습니다.",
      "이용자는 브라우저 설정에서 쿠키를 차단하거나, Google 광고 설정(https://adsettings.google.com) 및 https://policies.google.com/technologies/partner-sites 에서 맞춤형 광고 사용을 거부할 수 있습니다.",
      "위 도구는 분석을 위해 업로드한 대화 내용(이미지·텍스트)에는 접근하지 않으며, 이용자의 대화 데이터는 광고나 분석 목적으로 이용되지 않습니다.",
    ]},
    { h: "6. 이용자의 권리", body: [
      "서비스는 이용자의 개인정보를 저장하지 않으므로 별도의 열람·정정·삭제 요청 대상 데이터가 존재하지 않습니다.",
      "개인정보 처리에 관한 문의나 의견이 있는 경우 아래 연락처로 요청하실 수 있습니다.",
    ]},
    { h: "7. 민감정보에 대한 주의 안내", body: [
      "대화 스크린샷에는 건강·정치 성향 등 민감한 내용이나 제3자의 개인정보가 포함될 수 있습니다. 업로드 전, 분석에 불필요한 개인정보나 민감한 부분은 가리거나 제거해 주시기를 권장합니다.",
      "이용자는 본인이 작성했거나 공유받아 적법하게 이용할 수 있는 대화만 업로드해야 합니다.",
    ]},
    { h: "8. 만 14세 미만 아동", body: [
      "서비스는 만 14세 미만 아동을 대상으로 하지 않으며, 아동의 개인정보를 알면서 수집하지 않습니다.",
    ]},
    { h: "9. 방침의 변경", body: [
      "법령이나 서비스 내용 변경에 따라 본 방침이 개정될 수 있으며, 변경 시 본 페이지를 통해 고지합니다.",
    ]},
    { h: "10. 문의처", body: [
      "개인정보 처리에 관한 문의: " + LEGAL_CONTACT,
    ]},
  ],
};

/* 서비스 이용약관 — AI 분석 결과의 참고·오락 목적, 면책, 이용자 의무 중심 */
const TERMS_KO = {
  title: "서비스 이용약관",
  intro:
    "본 약관은 리뷰썸(이하 “서비스”)의 이용 조건과 절차, 서비스와 이용자의 권리·의무·책임을 규정합니다. 이용자는 서비스를 이용함으로써 본 약관에 동의한 것으로 봅니다.",
  sections: [
    { h: "제1조 (목적)", body: [
      "본 약관은 서비스가 제공하는 AI 기반 대화 분석 기능의 이용과 관련하여 서비스와 이용자 간의 권리·의무 및 책임사항을 정하는 것을 목적으로 합니다.",
    ]},
    { h: "제2조 (서비스의 내용)", body: [
      "서비스는 이용자가 업로드한 대화 스크린샷을 인공지능으로 분석하여 점수, 대화 온도 흐름, 하이라이트, 복기, 추천 메시지 등의 결과를 제공합니다.",
      "분석 결과는 인공지능이 자동으로 생성한 참고용·오락용 정보이며, 사실 여부나 특정 목적에의 적합성을 보장하지 않습니다.",
    ]},
    { h: "제3조 (이용 계약)", body: [
      "서비스는 별도의 회원가입 없이 누구나 이용할 수 있으며, 이용자가 대화를 업로드하여 분석을 요청하는 시점에 본 약관에 따른 이용이 시작됩니다.",
    ]},
    { h: "제4조 (이용자의 의무)", body: [
      "이용자는 본인이 작성했거나 적법하게 이용할 권한이 있는 대화만 업로드해야 합니다.",
      "이용자는 타인의 개인정보, 저작권, 명예 등 권리를 침해하거나 법령을 위반하는 목적으로 서비스를 이용해서는 안 됩니다.",
      "이용자는 서비스의 정상적인 운영을 방해하는 행위(과도한 자동 요청, 비정상적 접근 등)를 해서는 안 됩니다.",
    ]},
    { h: "제5조 (AI 분석 결과의 한계와 면책)", body: [
      "분석 결과는 인공지능 모델이 자동 생성하므로 부정확하거나 사실과 다른 내용(이른바 환각)을 포함할 수 있습니다.",
      "이용자는 분석 결과를 인간관계, 법률, 의료, 재무 등 중요한 의사결정의 유일한 근거로 사용해서는 안 됩니다.",
      "서비스는 분석 결과의 정확성·완전성·신뢰성을 보장하지 않으며, 이용자가 결과를 신뢰하여 행한 판단이나 그로 인해 발생한 손해에 대해 책임지지 않습니다.",
    ]},
    { h: "제6조 (지식재산권)", body: [
      "서비스의 화면 구성, 디자인, 텍스트 등에 대한 권리는 서비스 운영자에게 있습니다.",
      "이용자가 업로드한 대화의 내용에 대한 권리는 이용자 또는 정당한 권리자에게 있으며, 서비스는 이를 분석 목적으로만 일시적으로 처리합니다.",
    ]},
    { h: "제7조 (서비스의 변경 및 중단)", body: [
      "서비스는 운영상·기술상 필요에 따라 서비스의 전부 또는 일부를 변경하거나 중단할 수 있으며, 무상으로 제공되는 서비스의 특성상 이에 대해 별도의 보상을 하지 않습니다.",
    ]},
    { h: "제8조 (책임의 제한)", body: [
      "서비스는 무료로 제공되며, 천재지변, 외부 AI·호스팅 사업자의 장애, 이용자의 귀책사유 등 서비스가 통제할 수 없는 사유로 발생한 손해에 대해 책임지지 않습니다.",
      "관련 법령이 허용하는 최대 범위 내에서, 서비스 이용과 관련하여 발생한 간접·부수적·결과적 손해에 대해 서비스는 책임을 부담하지 않습니다.",
    ]},
    { h: "제9조 (준거법 및 분쟁 해결)", body: [
      "본 약관은 대한민국 법령에 따라 해석되며, 서비스 이용과 관련하여 분쟁이 발생한 경우 관련 법령이 정한 절차에 따라 해결합니다.",
    ]},
    { h: "제10조 (약관의 변경)", body: [
      "서비스는 필요한 경우 본 약관을 변경할 수 있으며, 변경된 약관은 본 페이지에 게시한 시점부터 효력이 발생합니다.",
    ]},
  ],
};

/* ---------- English (translation of the Korean docs above; keep in sync) ---------- */
const PRIVACY_EN = {
  title: "Privacy Policy",
  intro:
    "Revisome (the “Service”) values your privacy and complies with applicable laws, including the Personal Information Protection Act. The Service is used without sign-up, and conversations you upload for analysis are not stored separately. This policy explains what information the Service processes and how.",
  sections: [
    { h: "1. Information We Collect and How", body: [
      "The Service has no sign-up or login, and does not ask you to enter personal information such as your name or contact details.",
      "We process the “conversation screenshot images” you upload for analysis and the “conversation text” extracted from those images. Conversation content may include the name (or nickname) of the person you spoke with and personal details contained in the conversation.",
      "This information is processed only when you submit it directly by pressing the upload button; no other information is collected automatically.",
    ]},
    { h: "2. Purpose of Use", body: [
      "Uploaded images and extracted text are used solely to “generate the conversation analysis result (score, temperature flow, highlights, replay, suggested messages, etc.) and display it on screen.”",
      "We do not use it for advertising, marketing, user identification, profiling, or any other purpose.",
    ]},
    { h: "3. Retention and Disposal", body: [
      "Uploaded images and extracted text are used in memory only for the moment needed to process the analysis, and once analysis is complete they are discarded immediately without being stored on the server.",
      "Analysis results are likewise not stored on the server and are shown only in your browser; they disappear when you close or refresh the page.",
      "Accordingly, the Service does not operate any database that retains your conversation data.",
    ]},
    { h: "4. Outsourced Processing and Overseas Transfer", body: [
      "For accurate analysis, the conversation screenshot images you upload are transmitted to and processed by the external AI provider(s) below. Each provider processes the transmitted data under its own policy.",
      "· Conversation analysis (including recognition of text within images): OpenAI — GPT-4o multimodal analysis API (server location: overseas)",
      "· Hosting: Vercel Inc. (server location: overseas)",
      "These transfers occur only to the extent necessary to provide the analysis result. If you do not agree to this policy, you may stop using the Service by not uploading conversations. Details of each provider's personal data processing follow that provider's own policy.",
    ]},
    { h: "5. Cookies and Tracking Tools", body: [
      "The Service uses the third-party tools below for visit analytics (to improve the Service) and to display ads (to support operation), and cookies or similar technologies may be used in this process.",
      "· Analytics: Google Analytics (Google LLC) — aggregates page-visit counts and usage statistics. It is not intended to identify individual users.",
      "· Advertising: Google AdSense (Google LLC) — displays ads to support operation of the Service, and advertising cookies may be used in this process. Google may use cookies to serve ads based on your visits to this and other sites.",
      "You can block cookies in your browser settings, or opt out of personalized advertising at Google Ads Settings (https://adsettings.google.com) and https://policies.google.com/technologies/partner-sites.",
      "These tools do not access the conversation content (images or text) you upload for analysis, and your conversation data is not used for advertising or analytics purposes.",
    ]},
    { h: "6. Your Rights", body: [
      "Because the Service does not store your personal information, there is no data subject to a separate access, correction, or deletion request.",
      "If you have questions or comments about personal data processing, you may contact us at the address below.",
    ]},
    { h: "7. Notice on Sensitive Information", body: [
      "Conversation screenshots may contain sensitive content such as health or political views, or third parties' personal information. Before uploading, we recommend masking or removing any personal or sensitive parts that are unnecessary for analysis.",
      "You must upload only conversations that you wrote or are otherwise lawfully entitled to use.",
    ]},
    { h: "8. Children Under 14", body: [
      "The Service is not directed to children under the age of 14 and does not knowingly collect children's personal information.",
    ]},
    { h: "9. Changes to This Policy", body: [
      "This policy may be revised in line with changes to applicable laws or the Service; any changes will be announced on this page.",
    ]},
    { h: "10. Contact", body: [
      "Inquiries about personal data processing: " + LEGAL_CONTACT,
    ]},
  ],
};

const TERMS_EN = {
  title: "Terms of Service",
  intro:
    "These Terms govern the conditions and procedures for using Revisome (the “Service”) and the rights, obligations, and responsibilities of the Service and its users. By using the Service, you are deemed to have agreed to these Terms.",
  sections: [
    { h: "Article 1 (Purpose)", body: [
      "These Terms set out the rights, obligations, and responsibilities between the Service and users in relation to the use of the AI-based conversation analysis feature provided by the Service.",
    ]},
    { h: "Article 2 (Service Description)", body: [
      "The Service analyzes conversation screenshots uploaded by the user using artificial intelligence and provides results such as a score, conversation temperature flow, highlights, replay, and suggested messages.",
      "Analysis results are reference and entertainment information automatically generated by AI, and their accuracy or suitability for any particular purpose is not guaranteed.",
    ]},
    { h: "Article 3 (Use Agreement)", body: [
      "The Service may be used by anyone without separate sign-up, and use under these Terms begins at the moment the user uploads a conversation and requests analysis.",
    ]},
    { h: "Article 4 (User Obligations)", body: [
      "Users must upload only conversations that they wrote or are lawfully entitled to use.",
      "Users must not use the Service to infringe others' rights, such as personal information, copyright, or reputation, or for any purpose that violates the law.",
      "Users must not engage in acts that interfere with the normal operation of the Service (excessive automated requests, abnormal access, etc.).",
    ]},
    { h: "Article 5 (Limitations of AI Analysis and Disclaimer)", body: [
      "Because analysis results are automatically generated by an AI model, they may contain inaccurate or factually incorrect content (so-called hallucinations).",
      "Users must not use analysis results as the sole basis for important decisions regarding relationships, law, medicine, finance, or the like.",
      "The Service does not guarantee the accuracy, completeness, or reliability of analysis results, and is not responsible for judgments made in reliance on the results or for any damages arising therefrom.",
    ]},
    { h: "Article 6 (Intellectual Property)", body: [
      "Rights to the Service's screen layout, design, text, and the like belong to the Service operator.",
      "Rights to the content of conversations uploaded by users belong to the user or the rightful holder, and the Service processes them only temporarily for analysis purposes.",
    ]},
    { h: "Article 7 (Changes and Suspension of the Service)", body: [
      "The Service may change or suspend all or part of the Service as needed for operational or technical reasons, and given that the Service is provided free of charge, no separate compensation is provided for this.",
    ]},
    { h: "Article 8 (Limitation of Liability)", body: [
      "The Service is provided free of charge and is not responsible for damages arising from causes beyond its control, such as force majeure, failures of external AI or hosting providers, or causes attributable to the user.",
      "To the maximum extent permitted by applicable law, the Service is not liable for indirect, incidental, or consequential damages arising in connection with use of the Service.",
    ]},
    { h: "Article 9 (Governing Law and Dispute Resolution)", body: [
      "These Terms are interpreted under the laws of the Republic of Korea, and any dispute arising in connection with use of the Service is resolved according to the procedures set by applicable law.",
    ]},
    { h: "Article 10 (Changes to These Terms)", body: [
      "The Service may change these Terms when necessary, and the changed Terms take effect from the time they are posted on this page.",
    ]},
  ],
};

const LEGAL_DOCS = {
  ko: { privacy: PRIVACY_KO, terms: TERMS_KO },
  en: { privacy: PRIVACY_EN, terms: TERMS_EN },
};

function Legal({ doc, onBack, onLegal }){
  const { lang, t } = React.useContext(window.LangCtx);
  const set = LEGAL_DOCS[lang] || LEGAL_DOCS.ko;
  const meta = LEGAL_META[lang] || LEGAL_META.ko;
  const D = set[doc] || set.privacy;
  const other = doc === "privacy" ? "terms" : "privacy";
  const otherTitle = set[other].title;

  return (
    <div className="legal" style={{animation:"fadeIn .3s"}}>
      <nav className="nav">
        <div className="nav-inner wrap">
          <div className="row gap10">
            <span className="logo-text" style={{color:"var(--primary)",cursor:"pointer"}} onClick={onBack}>{t("brand")}</span>
          </div>
          <div className="row gap10">
            <LangToggle/>
            <button className="btn btn-ghost btn-sm" onClick={onBack} style={{height:44,padding:"0 20px",fontSize:15}}>
              <Icon name="back" size={17} color="#0E1626"/> {t("legal_back")}
            </button>
          </div>
        </div>
      </nav>

      <main className="legal-doc wrap">
        <h1 className="legal-title">{D.title}</h1>
        <p className="legal-meta">{meta.effLabel}: {meta.effective}</p>
        {D.intro && <p className="legal-intro">{D.intro}</p>}

        {D.sections.map((s,i)=>(
          <section key={i} className="legal-sec">
            <h2>{s.h}</h2>
            {s.body.map((p,j)=><p key={j}>{p}</p>)}
          </section>
        ))}

        <div className="legal-switch">
          <a onClick={()=>onLegal(other)}>{otherTitle} {t("legal_view")}</a>
        </div>
      </main>
    </div>
  );
}

Object.assign(window, { Legal });
