<?php require_once 'includes/config.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Terms & Conditions — <?= SITE_NAME ?></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@700;800;900&family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= SITE_URL ?>/assets/css/style.css">
<link rel="icon" type="image/png" href="https://studytrack.edurx.icu/studytrack/images/studytrack.png">
<style>
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{background:#08080f;color:#e2e8f0;font-family:'Poppins',sans-serif;overflow-x:hidden}
a{text-decoration:none;color:inherit}
:root{--vi:#7c6af0;--vi2:#a78bfa;--cy:#22d3ee;--card:#13131f;--card2:#1a1a2e;--border:rgba(255,255,255,.07);--border2:rgba(255,255,255,.12);--ink:#e2e8f0;--ink-dim:#94a3b8;--ink-ghost:#475569;--glow-vi:rgba(124,106,240,.35);--r:14px;--r2:20px}

/* NAV */
.nav{position:sticky;top:0;z-index:999;background:rgba(8,8,15,.92);backdrop-filter:blur(20px);border-bottom:1px solid var(--border);padding:0 24px}
.nav-inner{max-width:1100px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;height:68px}
.nav-logo{display:flex;align-items:center;gap:10px}
.nav-logo img{width:34px;height:34px;border-radius:9px}
.nav-logo-text{font-family:'Nunito',sans-serif;font-size:18px;font-weight:800;background:linear-gradient(135deg,#fff 30%,var(--vi2));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
.nav-logo-by{font-size:9px;font-weight:500;color:var(--ink-ghost);letter-spacing:.5px;text-transform:uppercase;display:block;line-height:1}
.nav-links{display:flex;align-items:center;gap:4px}
.nav-links a{padding:7px 14px;border-radius:9px;font-size:14px;font-weight:500;color:var(--ink-dim);transition:all .2s}
.nav-links a:hover{color:var(--ink);background:rgba(255,255,255,.05)}
.nav-pill{background:linear-gradient(135deg,var(--vi),#9333ea)!important;color:#fff!important;box-shadow:0 0 24px var(--glow-vi);font-weight:600!important}

/* HERO */
.legal-hero{padding:72px 24px 60px;text-align:center;position:relative;overflow:hidden;background:linear-gradient(180deg,rgba(124,106,240,.08) 0%,transparent 100%);border-bottom:1px solid var(--border)}
.legal-eyebrow{display:inline-block;font-size:12px;font-weight:700;color:var(--vi2);text-transform:uppercase;letter-spacing:2px;margin-bottom:16px}
.legal-title{font-family:'Nunito',sans-serif;font-size:clamp(30px,5vw,48px);font-weight:900;color:var(--ink);letter-spacing:-.5px;margin-bottom:14px}
.legal-title span{background:linear-gradient(110deg,var(--vi2),var(--cy));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
.legal-sub{font-size:15px;color:var(--ink-dim);line-height:1.75;max-width:560px;margin:0 auto 22px}
.legal-meta{display:flex;gap:20px;justify-content:center;flex-wrap:wrap;font-size:12px;color:var(--ink-ghost)}
.legal-meta span{display:flex;align-items:center;gap:6px}

/* BODY LAYOUT */
.legal-wrap{max-width:1060px;margin:0 auto;padding:48px 24px 100px;display:grid;grid-template-columns:200px 1fr;gap:32px;align-items:start}

/* TOC */
.toc-panel{position:sticky;top:88px;background:var(--card);border:1px solid var(--border2);border-radius:var(--r2);padding:20px 16px;overflow:hidden}
.toc-panel::before{content:'';position:absolute;top:0;left:0;right:0;height:3px;background:linear-gradient(90deg,var(--vi),var(--cy))}
.toc-heading{font-size:10px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:var(--ink-ghost);margin-bottom:13px}
.toc-list{list-style:none;display:flex;flex-direction:column;gap:1px}
.toc-list a{display:block;padding:7px 10px;border-radius:8px;font-size:12px;color:var(--ink-ghost);transition:all .18s;line-height:1.4}
.toc-list a:hover{color:var(--vi2);background:rgba(124,106,240,.08);padding-left:14px}
.toc-list a.active{color:var(--vi2);background:rgba(124,106,240,.1);font-weight:600}

/* SECTIONS */
.legal-body{min-width:0;display:flex;flex-direction:column;gap:12px}
.legal-section{background:var(--card);border:1px solid var(--border2);border-radius:var(--r2);padding:30px;transition:border-color .2s;scroll-margin-top:100px}
.legal-section:hover{border-color:rgba(124,106,240,.25)}
.sec-top{display:flex;align-items:center;gap:13px;margin-bottom:18px}
.sec-badge{width:36px;height:36px;border-radius:11px;flex-shrink:0;background:rgba(124,106,240,.1);border:1px solid rgba(124,106,240,.2);display:flex;align-items:center;justify-content:center;font-size:17px}
.sec-title{font-family:'Nunito',sans-serif;font-size:17px;font-weight:800;color:var(--ink)}
.legal-section p{font-size:14px;line-height:1.85;color:var(--ink-dim);margin-bottom:12px}
.legal-section p:last-child{margin-bottom:0}
.legal-section ul{list-style:none;display:flex;flex-direction:column;gap:8px;margin:12px 0}
.legal-section ul li{font-size:14px;line-height:1.75;color:var(--ink-dim);padding-left:20px;position:relative}
.legal-section ul li::before{content:'';position:absolute;left:2px;top:9px;width:7px;height:7px;border-radius:50%;background:linear-gradient(135deg,var(--vi2),var(--cy));opacity:.75}
.note{background:rgba(124,106,240,.07);border:1px solid rgba(124,106,240,.18);border-left:3px solid var(--vi2);border-radius:10px;padding:13px 15px;margin:13px 0;font-size:13px;line-height:1.7;color:var(--ink-dim)}
.warn{background:rgba(245,158,11,.07);border:1px solid rgba(245,158,11,.18);border-left:3px solid #f59e0b;border-radius:10px;padding:13px 15px;margin:13px 0;display:flex;gap:9px;align-items:flex-start;font-size:13px;line-height:1.7;color:var(--ink-dim)}
.warn-icon{font-size:15px;flex-shrink:0;margin-top:1px}
strong.hi{color:var(--ink)}

/* FOOTER */
.st-footer{background:#0f0f1a;border-top:1px solid var(--border);padding:48px 24px 24px}
.st-footer-inner{max-width:1100px;margin:0 auto}
.st-footer-grid{display:grid;grid-template-columns:1.6fr repeat(3,1fr);gap:40px;margin-bottom:36px}
.st-footer-desc{font-size:13px;color:var(--ink-ghost);line-height:1.75;margin-top:12px;max-width:220px}
.st-footer-col h5{font-size:11px;font-weight:700;color:var(--ink-ghost);text-transform:uppercase;letter-spacing:1.5px;margin-bottom:13px}
.st-footer-col a{display:block;font-size:13px;color:var(--ink-dim);margin-bottom:8px;transition:color .15s}
.st-footer-col a:hover{color:var(--vi2)}
.st-footer-bottom{border-top:1px solid var(--border);padding-top:20px;display:flex;align-items:center;justify-content:space-between;font-size:12px;color:var(--ink-ghost);flex-wrap:wrap;gap:8px}

@media(max-width:780px){.legal-wrap{grid-template-columns:1fr}.toc-panel{display:none}}
@media(max-width:768px){.nav-links{display:none!important}.st-footer-grid{grid-template-columns:1fr 1fr}}
@media(max-width:480px){.st-footer-grid{grid-template-columns:1fr}}
</style>
</head>
<body>

<nav class="nav">
  <div class="nav-inner">
    <a href="<?= SITE_URL ?>/home" class="nav-logo">
      <img src="https://studytrack.edurx.icu/studytrack/images/studytrack.png" alt="StudyTrack">
      <div><div class="nav-logo-text">StudyTrack</div><span class="nav-logo-by">by EduRx</span></div>
    </a>
    <div class="nav-links">
      <?php if(isLoggedIn()): ?>
        <a href="<?= SITE_URL ?>/dashboard">Dashboard</a>
        <a href="<?= SITE_URL ?>/logout">Sign Out</a>
      <?php else: ?>
        <a href="<?= SITE_URL ?>/login">Sign In</a>
        <a href="<?= SITE_URL ?>/register" class="nav-pill">Get Started Free</a>
      <?php endif; ?>
    </div>
  </div>
</nav>

<div class="legal-hero">
  <div class="legal-eyebrow">📄 Legal</div>
  <h1 class="legal-title">Terms &amp; <span>Conditions</span></h1>
  <p class="legal-sub">Please read these terms carefully before using <?= SITE_NAME ?>. By creating an account, you agree to be bound by these terms.</p>
  <div class="legal-meta">
    <span>📅 Effective: January 1, 2025</span>
    <span>🔄 Updated: March 1, 2026</span>
    <span>⏱️ 5 min read</span>
  </div>
</div>

<div class="legal-wrap">
  <aside class="toc-panel" aria-label="Table of contents">
    <div class="toc-heading">Contents</div>
    <ul class="toc-list">
      <li><a href="#s1">1. Acceptance</a></li>
      <li><a href="#s2">2. Use of Service</a></li>
      <li><a href="#s3">3. User Accounts</a></li>
      <li><a href="#s4">4. Your Content</a></li>
      <li><a href="#s4b">4b. Pro Subscriptions &amp; Payments</a></li>
      <li><a href="#s5">5. Prohibited Conduct</a></li>
      <li><a href="#s6">6. Intellectual Property</a></li>
      <li><a href="#s7">7. Disclaimers</a></li>
      <li><a href="#s8">8. Limitation of Liability</a></li>
      <li><a href="#s9">9. Termination</a></li>
      <li><a href="#s10">10. Changes to Terms</a></li>
      <li><a href="#s11">11. Contact Us</a></li>
    </ul>
  </aside>

  <div class="legal-body">
    <div class="legal-section" id="s1">
      <div class="sec-top"><div class="sec-badge">✅</div><div class="sec-title">1. Acceptance of Terms</div></div>
      <p>Welcome to <strong class="hi"><?= SITE_NAME ?></strong> — a study tracking platform built for Sri Lankan A/L students, offering both a free plan and an optional paid "Pro" plan. By registering an account or accessing any part of this platform, you confirm that you have read, understood, and agree to be bound by these Terms and Conditions.</p>
      <p>If you are under 18 years of age, you confirm that you have obtained permission from a parent or legal guardian to use this service, and to make any payments for a Pro subscription.</p>
      <div class="note">🎓 <?= SITE_NAME ?>'s core study-tracking features are free to use. The optional Pro plan unlocks additional AI-powered features for a subscription fee, as described in Section 4b below.</div>
    </div>
    <div class="legal-section" id="s2">
      <div class="sec-top"><div class="sec-badge">🛠️</div><div class="sec-title">2. Use of Service</div></div>
      <p><?= SITE_NAME ?> provides tools to help A/L students track study sessions, monitor exam results, manage tasks, and analyse academic progress. The service is provided on an "as is" basis for personal, non-commercial use only. You may use the platform to:</p>
      <ul>
        <li>Log and track your personal study sessions, subjects, and durations</li>
        <li>Record exam marks and monitor your academic performance over time</li>
        <li>Create and manage personal tasks, priorities, and study goals</li>
        <li>View analytics, progress charts, and study streak data</li>
        <li>Access A/L examination countdowns and admin announcements</li>
      </ul>
    </div>
    <div class="legal-section" id="s3">
      <div class="sec-top"><div class="sec-badge">👤</div><div class="sec-title">3. User Accounts</div></div>
      <p>To use <?= SITE_NAME ?>, you must register with a valid email address and verify your account via a one-time OTP code. You are responsible for:</p>
      <ul>
        <li>Maintaining the confidentiality of your account password</li>
        <li>All activity that occurs under your account</li>
        <li>Providing accurate and truthful registration information</li>
        <li>Notifying us immediately if you suspect any unauthorised access</li>
      </ul>
      <div class="warn"><span class="warn-icon">⚠️</span><span>You may not share your credentials with others or create accounts on behalf of third parties. Each student must maintain their own individual account.</span></div>
      <p>We reserve the right to suspend or terminate accounts that violate these terms or are used for any purpose other than personal academic tracking.</p>
    </div>
    <div class="legal-section" id="s4">
      <div class="sec-top"><div class="sec-badge">📝</div><div class="sec-title">4. Your Content</div></div>
      <p>All study data, marks, notes, and tasks you enter into <?= SITE_NAME ?> remain your property. We do not claim ownership over your personal academic data.</p>
      <p>By using the platform, you grant <?= SITE_NAME ?> a limited licence to store and process your data solely for the purpose of providing the service to you. We will never sell, share, or use your personal academic data for any commercial purpose.</p>
      <p>You are responsible for ensuring that data you enter is accurate. <?= SITE_NAME ?> is not responsible for any decisions made based on data you have entered incorrectly.</p>
    </div>
    <div class="legal-section" id="s4b">
      <div class="sec-top"><div class="sec-badge">💳</div><div class="sec-title">4b. Pro Subscriptions &amp; Payments</div></div>
      <p><?= SITE_NAME ?> offers an optional paid subscription plan, "<strong class="hi"><?= SITE_NAME ?> Pro</strong>", which unlocks unlimited access to AI-powered study tips, AI chat, and AI-driven performance analysis. The free plan continues to include all core study-tracking features, with a limited number of AI requests per day.</p>
      <ul>
        <li>Pro is billed either <strong>monthly</strong> or <strong>yearly</strong>, at the price shown on the <a href="<?= SITE_URL ?>/upgrade" style="color:var(--vi2)">Upgrade page</a> at the time of purchase.</li>
        <li>Payments are processed securely by <strong>PayHere</strong>, a licensed Sri Lankan payment gateway. <?= SITE_NAME ?> does not store your card, bank, or wallet details — these are handled entirely by PayHere.</li>
        <li>Pro access activates automatically once payment is confirmed, and remains active until the end of the billing period you paid for.</li>
        <li>Subscriptions do <strong>not</strong> auto-renew unless you initiate a new payment — there is no automatic recurring billing at this time. You will need to manually renew before your Pro period expires to keep uninterrupted access.</li>
        <li>Pro is a digital service delivered immediately upon payment confirmation. Please see our <a href="<?= SITE_URL ?>/refund-policy" style="color:var(--vi2)">Refund &amp; Return Policy</a> for details on cancellations and refunds.</li>
      </ul>
    </div>
    <div class="legal-section" id="s5">
      <div class="sec-top"><div class="sec-badge">🚫</div><div class="sec-title">5. Prohibited Conduct</div></div>
      <p>When using <?= SITE_NAME ?>, you agree <strong class="hi">not</strong> to:</p>
      <ul>
        <li>Attempt to access, tamper with, or disrupt the platform's servers or databases</li>
        <li>Use automated scripts, bots, or scrapers to interact with the service</li>
        <li>Attempt to reverse engineer, decompile, or exploit the platform's source code</li>
        <li>Submit false, misleading, or harmful content through any platform form</li>
        <li>Use the platform for any unlawful purpose or in violation of Sri Lankan law</li>
        <li>Create multiple accounts to bypass restrictions or bans</li>
        <li>Impersonate another person or misrepresent your identity</li>
      </ul>
    </div>
    <div class="legal-section" id="s6">
      <div class="sec-top"><div class="sec-badge">©️</div><div class="sec-title">6. Intellectual Property</div></div>
      <p>The <?= SITE_NAME ?> platform — including its design, code, graphics, interface, and written content — is owned by <?= SITE_NAME ?> and is protected by applicable intellectual property laws.</p>
      <p>You may not copy, reproduce, distribute, or create derivative works from any part of the platform without express written permission. The <?= SITE_NAME ?> name and logo are trademarks and may not be used without prior authorisation.</p>
    </div>
    <div class="legal-section" id="s7">
      <div class="sec-top"><div class="sec-badge">⚖️</div><div class="sec-title">7. Disclaimer of Warranties</div></div>
      <p><?= SITE_NAME ?> is provided on an <strong class="hi">"as is" and "as available"</strong> basis, without warranties of any kind — express or implied. We do not warrant that the service will be uninterrupted, error-free, or free from security vulnerabilities.</p>
      <div class="warn"><span class="warn-icon">📌</span><span><?= SITE_NAME ?> is a study tracking tool only — not a substitute for guidance from qualified teachers or educational institutions. Academic decisions should not be based solely on data from this platform.</span></div>
    </div>
    <div class="legal-section" id="s8">
      <div class="sec-top"><div class="sec-badge">🛡️</div><div class="sec-title">8. Limitation of Liability</div></div>
      <p>To the fullest extent permitted by applicable law, <?= SITE_NAME ?> and its operators shall not be liable for any indirect, incidental, special, consequential, or punitive damages arising from your use of — or inability to use — the platform.</p>
      <p>This includes loss of data, academic outcomes, or any decisions made based on information provided by the platform. For users on the free plan, our total liability to you for any claim shall not exceed zero. For Pro subscribers, our total liability shall not exceed the amount you paid for your current Pro subscription period.</p>
    </div>
    <div class="legal-section" id="s9">
      <div class="sec-top"><div class="sec-badge">🔚</div><div class="sec-title">9. Termination</div></div>
      <p>You may delete your account at any time by contacting us. Upon deletion, your personal data will be removed from our active systems within a reasonable period.</p>
      <p>We reserve the right to suspend or permanently terminate your account, without prior notice, if we reasonably believe you have violated these Terms or engaged in conduct harmful to other users or the platform itself.</p>
    </div>
    <div class="legal-section" id="s10">
      <div class="sec-top"><div class="sec-badge">🔄</div><div class="sec-title">10. Changes to These Terms</div></div>
      <p>We may update these Terms and Conditions from time to time. When we make significant changes, we will update the "Updated" date shown at the top of this page. Continued use of <?= SITE_NAME ?> after any changes constitutes your acceptance of the revised terms.</p>
      <p>We encourage you to review this page periodically to stay informed.</p>
    </div>
    <div class="legal-section" id="s11">
      <div class="sec-top"><div class="sec-badge">📬</div><div class="sec-title">11. Contact Us</div></div>
      <p>If you have any questions about these Terms and Conditions, please reach out:</p>
      <ul>
        <li>Platform: <strong class="hi"><?= SITE_NAME ?></strong></li>
        <li>Website: <a href="<?= SITE_URL ?>/home" style="color:var(--vi2)"><?= SITE_URL ?></a></li>
        <li>Email: <a href="mailto:support@edurx.icu" style="color:var(--vi2)">support@edurx.icu</a></li>
      </ul>
      <div class="note" style="margin-top:16px">📚 Thank you for using <?= SITE_NAME ?>. We built this platform to help Sri Lankan A/L students succeed — we hope it serves you well on your journey.</div>
    </div>
  </div>
</div>

<footer class="st-footer">
  <div class="st-footer-inner">
    <div class="st-footer-grid">
      <div>
        <a href="<?= SITE_URL ?>/home" class="nav-logo"><img src="https://studytrack.edurx.icu/studytrack/images/studytrack.png" alt="" style="width:30px;height:30px;border-radius:8px"><div><div class="nav-logo-text" style="font-size:16px">StudyTrack</div><span class="nav-logo-by">by EduRx</span></div></a>
        <p class="st-footer-desc">Free study tracker for Sri Lankan A/L students.</p>
      </div>
      <div class="st-footer-col"><h5>Platform</h5><a href="<?= SITE_URL ?>/register">Register</a><a href="<?= SITE_URL ?>/login">Sign In</a><a href="<?= SITE_URL ?>/home">Home</a></div>
      <div class="st-footer-col"><h5>Legal</h5><a href="<?= SITE_URL ?>/terms" style="color:var(--vi2)">Terms & Conditions</a><a href="<?= SITE_URL ?>/privacy">Privacy Policy</a><a href="<?= SITE_URL ?>/refund-policy">Refund &amp; Return Policy</a></div>
      <div class="st-footer-col"><h5>Support</h5><a href="<?= SITE_URL ?>/forgot-password">Forgot Password</a><a href="<?= SITE_URL ?>/contact">Contact Us</a></div>
    </div>
    <div class="st-footer-bottom"><span>© <?= date('Y') ?> <?= SITE_NAME ?>. All rights reserved.</span><span>Built with ❤️ for Sri Lankan A/L students</span></div>
  </div>
</footer>

<script>
(function(){
  var sections=document.querySelectorAll('.legal-section[id]');
  var links=document.querySelectorAll('.toc-list a');
  if(!sections.length) return;
  var io=new IntersectionObserver(function(entries){
    entries.forEach(function(e){
      if(!e.isIntersecting) return;
      links.forEach(function(l){l.classList.remove('active')});
      var a=document.querySelector('.toc-list a[href="#'+e.target.id+'"]');
      if(a) a.classList.add('active');
    });
  },{rootMargin:'-15% 0px -75% 0px'});
  sections.forEach(function(s){io.observe(s)});
  links.forEach(function(a){a.addEventListener('click',function(e){e.preventDefault();var t=document.querySelector(a.getAttribute('href'));if(t)t.scrollIntoView({behavior:'smooth',block:'start'})})});
})();
</script>
</body>
</html>