/* global React */
const { useState: useOVFAQState } = React;

// ============================================================
// Overseas CDN, Enquiry + FAQ + Final CTA
// ============================================================
const OV_END_CSS = `
/* ---------- Enquiry Form ---------- */
.OV-enq{position:relative;background:#0F2A47;color:#fff;padding:var(--section-pad-y-d) 0;font-family:'Inter','Noto Sans HK','Noto Sans TC',sans-serif;overflow:hidden}
.OV-enq::before{content:'';position:absolute;top:-220px;right:-220px;width:600px;height:600px;background:radial-gradient(circle,rgba(167,139,250,0.18) 0%,transparent 70%);pointer-events:none}
.OV-enq::after{content:'';position:absolute;bottom:-220px;left:-220px;width:500px;height:500px;background:radial-gradient(circle,rgba(124,58,237,0.13) 0%,transparent 70%);pointer-events:none}

.OV-enq-inner{position:relative;display:grid;grid-template-columns:0.9fr 1.1fr;gap:72px;align-items:start}
.OV-enq-h2{margin:0;font-size:clamp(36px,4.2vw,56px);line-height:1.08;font-weight:700;letter-spacing:-1.6px;color:#fff;text-wrap:balance}
.OV-enq-h2 .accent{background:linear-gradient(135deg,#C4B5FD 0%,#A855F7 100%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent}
.OV-enq-lede{margin-top:22px;font-size:16.5px;line-height:1.7;color:rgba(255,255,255,0.74);max-width:480px;text-wrap:pretty}

.OV-enq-form{background:rgba(255,255,255,0.04);border:1px solid rgba(196,181,253,0.16);border-radius:22px;padding:38px 36px;backdrop-filter:blur(8px)}
.OV-enq-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px 16px}
.OV-enq-field{display:flex;flex-direction:column;gap:8px}
.OV-enq-field.full{grid-column:1 / -1}
.OV-enq-field label{font-size:13px;font-weight:600;color:rgba(196,181,253,0.7);letter-spacing:.3px;text-transform:uppercase;font-family:'Chakra Petch','Inter',sans-serif}
.OV-enq-field label .req{color:#C4B5FD;margin-left:3px}
.OV-enq-field input,.OV-enq-field select,.OV-enq-field textarea{appearance:none;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.14);border-radius:10px;padding:12px 14px;color:#fff;font-family:inherit;font-size:14.5px;line-height:1.5;transition:border-color .15s,background .15s}
.OV-enq-field input:focus,.OV-enq-field select:focus,.OV-enq-field textarea:focus{outline:0;border-color:#C4B5FD;background:rgba(255,255,255,0.10)}
.OV-enq-field input::placeholder,.OV-enq-field textarea::placeholder{color:rgba(255,255,255,0.75)}
.OV-enq-field select{background-image:url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='12'%20height='8'%20viewBox='0%200%2012%208'%3E%3Cpath%20d='M1%201l5%205%205-5'%20stroke='%235EEAD4'%20stroke-width='1.8'%20fill='none'%20stroke-linecap='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 14px center;padding-right:38px}
.OV-enq-field textarea{min-height:96px;resize:vertical}

.OV-enq-phone{display:grid;grid-template-columns:96px 1fr;gap:8px}
.OV-enq-phone select{padding-right:30px;background-position:right 8px center}

.OV-enq-submit{margin-top:24px;display:flex;justify-content:space-between;align-items:center;gap:18px;flex-wrap:wrap}
.OV-enq-btn{appearance:none;border:0;cursor:pointer;display:inline-flex;align-items:center;gap:10px;padding:16px 32px;font-family:'Noto Sans HK','Inter',sans-serif;font-size:15px;font-weight:700;color:#0F2A47;background:linear-gradient(135deg,#C4B5FD 0%,#A855F7 100%);border-radius:999px;text-decoration:none;letter-spacing:.2px;box-shadow:0 8px 22px rgba(167,139,250,0.32);transition:all .15s}
.OV-enq-btn:hover{background:linear-gradient(135deg,#A855F7 0%,#9333EA 100%);transform:translateY(-1px);box-shadow:0 12px 28px rgba(167,139,250,0.45)}

@media (max-width: 1024px){
  .OV-enq{padding:var(--section-pad-y-t) 0}
  .OV-enq-inner{grid-template-columns:1fr;gap:48px}
}
@media (max-width: 640px){
  .OV-enq{padding:var(--section-pad-y-m) 0}
  .OV-enq-form{padding:28px 22px}
  .OV-enq-grid{grid-template-columns:1fr}
}

/* ---------- FAQ ---------- */
.OV-faq{position:relative;background:linear-gradient(180deg,#F6F4FB 0%,#FAFAFE 100%);padding:var(--section-pad-y-d) 0;font-family:'Inter','Noto Sans HK','Noto Sans TC',sans-serif;color:#0F2A47;border-top:1px solid rgba(15,42,71,0.06)}
.OV-faq-head{max-width:780px;margin-bottom:48px}
.OV-faq-h2{margin:0;font-size:clamp(36px,4.2vw,56px);line-height:1.08;font-weight:700;letter-spacing:-1.6px;color:#0F2A47;text-wrap:balance}
.OV-faq-lede{margin-top:18px;font-size:16px;line-height:1.7;color:#475569;max-width:560px}

.OV-faq-list{border-top:1px solid rgba(15,42,71,0.12)}
.OV-faq-item{border-bottom:1px solid rgba(15,42,71,0.12)}
.OV-faq-q{appearance:none;background:transparent;border:0;width:100%;padding:24px 0;display:grid;grid-template-columns:1fr 24px;align-items:center;gap:32px;text-align:left;cursor:pointer;font-family:inherit;color:inherit}
.OV-faq-q-text{font-size:18px;font-weight:600;color:#0F2A47;letter-spacing:-.2px;line-height:1.45;text-wrap:balance}
.OV-faq-toggle{width:24px;height:24px;color:#A855F7;display:flex;align-items:center;justify-content:center;transition:transform .25s ease}
.OV-faq-item.open .OV-faq-toggle{transform:rotate(45deg)}
.OV-faq-toggle svg{width:18px;height:18px}
.OV-faq-a{display:grid;grid-template-rows:0fr;transition:grid-template-rows .3s ease}
.OV-faq-item.open .OV-faq-a{grid-template-rows:1fr}
.OV-faq-a > div{overflow:hidden;min-height:0}
.OV-faq-a p{margin:0 0 24px;font-size:15.5px;line-height:1.8;color:#475569;text-wrap:pretty;max-width:880px}
.OV-faq-a p strong{color:#0F2A47;font-weight:600}

@media (max-width: 1024px){ .OV-faq{padding:var(--section-pad-y-t) 0} }
@media (max-width: 640px){
  .OV-faq{padding:var(--section-pad-y-m) 0}
  .OV-faq-q-text{font-size:16px}
  .OV-faq-a p{font-size:14.5px}
}

/* ---------- Final CTA ---------- */
.OV-fcta{background:#0F2A47;color:#fff;padding:var(--section-pad-y-d) 0;position:relative;overflow:hidden;font-family:'Inter','Noto Sans HK','Noto Sans TC',sans-serif}
.OV-fcta::before{content:'';position:absolute;top:-200px;right:-200px;width:600px;height:600px;background:radial-gradient(circle,rgba(139,92,246,0.18) 0%,transparent 70%);pointer-events:none}
.OV-fcta::after{content:'';position:absolute;bottom:-180px;left:-180px;width:500px;height:500px;background:radial-gradient(circle,rgba(139,92,246,0.10) 0%,transparent 70%);pointer-events:none}
.OV-fcta-inner{position:relative;display:grid;grid-template-columns:1.3fr 1fr;gap:64px;align-items:end}
.OV-fcta-h2{margin:0;font-size:clamp(36px,4.4vw,60px);line-height:1.05;font-weight:700;letter-spacing:-1.8px;color:#fff;text-wrap:balance}
.OV-fcta-h2 .accent{color:#c4b5fd}
.OV-fcta-body{margin-top:22px;font-size:16.5px;line-height:1.75;color:rgba(255,255,255,0.78);max-width:540px;text-wrap:pretty}
.OV-fcta-tel{margin-top:18px;font-size:14px;color:rgba(255,255,255,0.6)}
.OV-fcta-tel a{color:#fff;text-decoration:none;border-bottom:1px dotted rgba(255,255,255,0.4);font-weight:600;margin-left:8px}
.OV-fcta-actions{display:flex;flex-direction:column;gap:12px;align-items:stretch}
.OV-fcta-btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;padding:18px 28px;font-size:15.5px;font-weight:600;letter-spacing:.3px;border-radius:999px;text-decoration:none;transition:all .15s;white-space:nowrap;border:1.5px solid transparent}
.OV-fcta-btn.primary{color:#0F2A47;background:#fff;border-color:#fff}
.OV-fcta-btn.primary:hover{background:#c4b5fd;border-color:#c4b5fd;transform:translateY(-1px)}
.OV-fcta-btn.outline{color:#fff;background:transparent;border-color:rgba(255,255,255,0.40)}
.OV-fcta-btn.outline:hover{border-color:#fff;background:rgba(255,255,255,0.06)}

@media (max-width: 900px){ .OV-fcta-inner{grid-template-columns:1fr;gap:36px;align-items:start} }
`;

const OV_FAQS = [
  { q: '甚麼是海外 CDN？', a: '海外 CDN 是專為加速網站、API 及影音內容傳送至全球用戶的內容傳遞網絡服務。它將你的內容快取於分佈全球的邊緣節點，海外用戶可從最就近的位置取得內容，毋須繞道源站，從而大幅縮短跨境載入時間。' },
  { q: 'UD 海外 CDN 的節點覆蓋哪些地區？', a: 'UD 海外 CDN 節點分佈於亞洲、歐洲及美洲主要市場，配合超過 300Gb 國際出口頻寬。詳細覆蓋地圖可向銷售團隊索取，亦可透過 14 天免費試用實測你目標市場的延遲表現。' },
  { q: 'UD 海外 CDN 如何收費？', a: '海外 CDN 提供兩種計費模式：「按用量計費」由每 GB HK$0.40 起，毋須長期合約，適合流量波動較大或初步試用的客戶；「月費計劃」由 HK$628 / 月（包 1 TB）起，最受歡迎的經濟型為 HK$2,878 / 月（包 5 TB）。所有費用均透明列於月度發票，並無隱藏收費。' },
  { q: '海外 CDN 支援常見的網店與內容管理系統嗎？', a: '支援。UD 海外 CDN 兼容 WordPress、Shopify、Magento、WooCommerce 等主流網店與內容管理系統，亦支援應用程式介面、即時動態內容以及主流影音串流協定。' },
  { q: '海外 CDN 能否與中國 CDN 一併使用？', a: '可以。UD 同時提供海外 CDN 與中國 CDN，並可透過「智能 CDN」自動將不同地區的流量分配至最佳節點，達致全球（包括中國內地）一致的瀏覽體驗。' },
  { q: 'UD 海外 CDN 包含哪些安全防護？', a: '所有海外 CDN 流量均隱藏源伺服器真實位址，並內建免費憑證、網頁應用程式防火牆與阻斷服務攻擊防護，毋須額外加購安全模組。' },
  { q: '申請後需時多久才可上線？', a: '完成網域驗證及指向設定後，一般可於同一個工作天內生效，實際時間視乎全球網域傳播所需時間而定。' },
  { q: 'UD 海外 CDN 與國際大廠有何分別？', a: '國際大廠通常以美元計價、以英文非同步工單支援為主。UD 海外 CDN 採用港幣計價、提供 24×7 中文真人支援，並可與 UD 中國 CDN 無縫結合，特別適合以香港為基地、業務同時跨越大中華與全球市場的企業。' },
];

function OverseasEnquiry() {
  return (
    <>
      <style>{OV_END_CSS}</style>
      <section className="OV-enq" id="enquiry" data-screen-label="07 Enquiry">
        <div className="container OV-enq-inner">
          <div>
            <h2 className="OV-enq-h2">與我們的 <span className="accent">CDN 專家</span>對談</h2>
            <p className="OV-enq-lede">
              若你有跨境流量、多地區部署、影音串流或客製化海外加速需求，歡迎填寫表格，香港團隊會盡快跟進。
            </p>
          </div>

          <CdnEnquiryForm prefix="ov" />
        </div>
      </section>
    </>
  );
}

function OverseasFAQ() {
  const [open, setOpen] = useOVFAQState(0);
  return (
    <section className="OV-faq" id="faq" data-screen-label="07 FAQ">
      <div className="container">
        <div className="OV-faq-head">
          <h2 className="OV-faq-h2">常見問題</h2>
          <p className="OV-faq-lede">如以上未能解答你的疑問，歡迎直接聯絡我們的香港工程團隊。</p>
        </div>
        <div className="OV-faq-list">
          {OV_FAQS.map((f, i) => (
            <div className={`OV-faq-item ${open === i ? 'open' : ''}`} key={i}>
              <button className="OV-faq-q" onClick={() => setOpen(open === i ? -1 : i)} aria-expanded={open === i}>
                <span className="OV-faq-q-text">{f.q}</span>
                <span className="OV-faq-toggle" aria-hidden="true">
                  <svg viewBox="0 0 18 18" fill="none">
                    <line x1="9" y1="2" x2="9" y2="16" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" />
                    <line x1="2" y1="9" x2="16" y2="9" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" />
                  </svg>
                </span>
              </button>
              <div className="OV-faq-a"><div><p>{f.a}</p></div></div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function OverseasFinalCTA() {
  return (
    <>
      <section className="OV-fcta" data-screen-label="08 Final CTA">
        <div className="container OV-fcta-inner">
          <div>
            <h2 className="OV-fcta-h2">立即讓你的網站<br /><span className="accent">直達全球用戶</span></h2>
            <p className="OV-fcta-body">14 天免費試用、按用量收費、毋須長期合約。由我們的香港團隊為你規劃最合適的海外 CDN 配置。</p>
            <p className="OV-fcta-tel">服務查詢熱線：<a href="tel:+85225547545" data-cta="open-call-sales">(+852) 2554 7545</a></p>
          </div>
          <div className="OV-fcta-actions">
            <a className="OV-fcta-btn primary" href="https://passport.8338.hk/zh-hant/signup" data-cta="start-trial">免費試用 →</a>
            <a className="OV-fcta-btn outline" href={window.__udRoot('zh-Hant/contact', 'contact.html')} data-cta="contact-sales">與 CDN 專家對談</a>
          </div>
        </div>
      </section>
    </>
  );
}

window.OverseasEnquiry = OverseasEnquiry;
window.OverseasFAQ = OverseasFAQ;
window.OverseasFinalCTA = OverseasFinalCTA;
