<?php
declare(strict_types=1);
define('BASE_PATH', __DIR__ . '/..');
require_once BASE_PATH . '/src/bootstrap.php';

use PostbackServer\Translation;

$lang = Translation::getLanguage();
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($lang) ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= Translation::get('footer_terms') ?> – PostbackFlow</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<style>
:root {
  --bg:#040812;--surface:#0d1424;--surface2:#131d30;--border:#1a2640;
  --primary:#6366f1;--pl:#818cf8;--accent:#22d3ee;--text:#f1f5f9;--muted:#64748b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 100px 20px 60px;
}
.glow {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: rgba(4, 8, 18, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-logo {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pl), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}
.nav-back {
  color: var(--pl);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text), var(--pl));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 30px;
}
h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 30px;
  margin-bottom: 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
p {
  margin-bottom: 16px;
  color: #cbd5e1;
  font-size: 0.95rem;
}
ul {
  margin-bottom: 16px;
  padding-left: 20px;
  color: #cbd5e1;
  font-size: 0.95rem;
}
li {
  margin-bottom: 6px;
}
footer {
  text-align: center;
  margin-top: 60px;
  font-size: 0.8rem;
  color: var(--muted);
}
</style>
</head>
<body>
<div class="glow"></div>
<nav>
  <a href="/" class="nav-logo">⚡ PostbackFlow</a>
  <a href="/" class="nav-back">← <?= $lang === 'vi' ? 'Quay lại Trang chủ' : 'Back to Home' ?></a>
</nav>

<div class="container">
  <div class="card">
    <?php if ($lang === 'vi'): ?>
      <h1>Điều Khoản Dịch Vụ</h1>
      <div class="meta">Cập nhật lần cuối: <?= date('d/m/Y') ?></div>

      <p>Chào mừng bạn sử dụng phần mềm và dịch vụ PostbackFlow. Bằng việc đăng ký tài khoản và truy cập vào hệ thống của chúng tôi, bạn đồng ý tuân thủ các điều khoản dịch vụ dưới đây.</p>

      <h2>1. Quyền và Trách nhiệm Sử dụng Tài khoản</h2>
      <p>Bạn tự chịu trách nhiệm về việc bảo mật thông tin đăng nhập, token người dùng và các API key được tạo trên hệ thống của mình:</p>
      <ul>
        <li>Không chia sẻ tài khoản cho bên thứ ba ngoài nội bộ doanh nghiệp của bạn.</li>
        <li>Không sử dụng dịch vụ vào các mục đích vi phạm pháp luật hoặc thực hiện các cuộc tấn công DDoS, spam hệ thống của chúng tôi hoặc các đối tác liên quan.</li>
      </ul>

      <h2>2. Giới hạn Sử dụng và Gói Cước</h2>
      <p>Hạn mức chuyển đổi (conversions quota) hàng tháng và số lượng chiến dịch được áp dụng nghiêm ngặt theo gói cước bạn đang kích hoạt:</p>
      <ul>
        <li>Nếu vượt quá hạn mức gói Free hoặc các gói trả phí, các conversion vượt hạn mức sẽ được lưu tạm trong hàng đợi "Pending Upgrade" và chỉ được xử lý gửi đi khi bạn nâng cấp gói.</li>
        <li>Chúng tôi có quyền tạm ngưng dịch vụ nếu tài khoản của bạn tạo lượng click rác (traffic spam) quá mức cho phép gây ảnh hưởng đến hiệu năng chung của hạ tầng máy chủ.</li>
      </ul>

      <h2>3. Tuyên bố Miễn trừ Trách nhiệm Pháp lý (Disclaimer)</h2>
      <p>PostbackFlow cung cấp dịch vụ phân tích dữ liệu, chuyển hướng link và đồng bộ hóa postback theo mô hình "Như hiện có" (As-Is):</p>
      <ul>
        <li><strong>Không cam kết bồi thường:</strong> Chúng tôi hoàn toàn miễn trừ trách nhiệm bồi thường tài chính hoặc bất kỳ thiệt hại trực tiếp/gián tiếp nào phát sinh trong quá trình chạy quảng cáo của bạn (bao gồm nhưng không giới hạn ở: tài khoản quảng cáo bị khóa, chết link tracking, lỗi máy chủ trung gian Cloudflare, sập hosting phễu bán hàng của bạn...).</li>
        <li><strong>Tự chủ ngân sách quảng cáo:</strong> Bạn hoàn toàn chịu trách nhiệm kiểm tra, giám sát ngân sách quảng cáo và hoạt động của link trước khi đổ traffic lớn. Các tính năng như Smart Cap Alert hoặc Outage Protection chỉ đóng vai trò hỗ trợ và không thể thay thế việc giám sát thủ công của Media Buyer.</li>
      </ul>

      <h2>4. Thay đổi và Điều chỉnh Điều khoản</h2>
      <p>Chúng tôi giữ quyền cập nhật điều khoản này bất kỳ lúc nào để phù hợp với quy định mới của các ad networks. Các thay đổi sẽ có hiệu lực ngay khi được đăng tải lên trang web này.</p>

      <h2>5. Bản quyền và Liên hệ</h2>
      <p>Mọi câu hỏi liên quan đến Điều khoản dịch vụ vui lòng liên hệ: support@postbackflow.com.</p>
    <?php else: ?>
      <h1>Terms of Service</h1>
      <div class="meta">Last Updated: <?= date('F j, Y') ?></div>

      <p>Welcome to PostbackFlow. By registering an account and accessing our tracking services, you agree to comply with and be bound by the following Terms of Service.</p>

      <h2>1. Account Usage & Responsibility</h2>
      <p>You are fully responsible for maintaining the confidentiality of your login credentials, user tokens, and generated API keys:</p>
      <ul>
        <li>You must not share your account details with unauthorized third parties.</li>
        <li>You must not use our service for any illegal activities or to execute DDoS attacks, click fraud, or traffic spam against our platform or partner systems.</li>
      </ul>

      <h2>2. Usage Limits & Subscription Plans</h2>
      <p>Conversion quotas and campaign features are strictly governed by your active subscription plan:</p>
      <ul>
        <li>Conversions exceeding monthly quotas are marked as "Pending Upgrade" and will not be forwarded to ad networks until you upgrade your plan.</li>
        <li>We reserve the right to temporarily suspend accounts sending excessively high volumes of junk traffic that degrade our server hardware performance.</li>
      </ul>

      <h2>3. Limitation of Liability & Disclaimer</h2>
      <p>PostbackFlow tracking, routing, and postback synchronization services are provided on an "As-Is" and "As-Available" basis:</p>
      <ul>
        <li><strong>No Financial Indemnity:</strong> We are not liable for any direct, indirect, or incidental financial losses resulting from your advertising campaigns (including, but not limited to: ad account suspensions, domain flags, link downtime, third-party hosting crashes, or server outages).</li>
        <li><strong>Media Buying Risk:</strong> You are solely responsible for managing your ad budgets. Anomaly protection rules and Cap alerts are secondary backup utilities and do not replace active manual monitoring by the media buyer.</li>
      </ul>

      <h2>4. Modifications</h2>
      <p>We reserve the right to update these terms at any time to comply with ad network policy changes. Updates are effective immediately upon posting to this website.</p>

      <h2>5. Contact Us</h2>
      <p>If you have any questions regarding these Terms of Service, please contact us at support@postbackflow.com.</p>
    <?php endif; ?>
  </div>

  <footer>
    <p>© <?= date('Y') ?> PostbackFlow. All rights reserved.</p>
  </footer>
</div>
</body>
</html>
