<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
include 'db.php';

// Latest reviews
$latestReviews = $pdo->query("
  SELECT r.comment, r.rating, u.username, c.name AS company_name
  FROM reviews r
  JOIN users u ON r.user_id = u.id
  JOIN companies c ON r.company_id = c.id
  ORDER BY r.id DESC
  LIMIT 5
")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Privacy Policy - Review Stream</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Sans-serif fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet">

<!-- Favicon -->
<link rel="icon" href="/favicon.png" type="image/png" />


<style>
  body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    background: #f7f7f7;
    color: #333;
	padding-bottom: 220px;
  }
  
  
  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #4A90E2;
    color: white;
    padding: 10px 20px;
  }
  .logo {
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .top-menu {
    display: flex;
    align-items: center;
    gap: 15px;
  }
  .top-menu a {
    color: white;
    text-decoration: none;
    font-size: 0.95em;
  }
  .menu-toggle {
    display: none;
    font-size: 1.5em;
    cursor: pointer;
  }
  @media (max-width: 768px) {
    .top-menu {
      display: none;
      flex-direction: column;
      background: #4A90E2;
      position: absolute;
      top: 55px;
      right: 0;
      width: 180px;
      border-radius: 0 0 0 8px;
    }
    .top-menu.show {
      display: flex;
    }
    .menu-toggle {
      display: block;
    }
  }
  .content-layout {
    display: grid;
    grid-template-columns: 220px 1fr 220px;
    gap: 20px;
    padding: 20px;
  }
  @media (max-width: 900px) {
    .content-layout {
      grid-template-columns: 1fr;
    }
    .left-menu { display: none; }
    .left-menu.active { display: block; margin-bottom: 10px; }
  }
  .left-menu {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 0 6px rgba(0,0,0,0.1);
  }
  .left-menu ul { list-style: none; padding: 0; margin: 0; }
  .left-menu li { border-bottom: 1px solid #eee; }
  .left-menu button {
    width: 100%;
    text-align: left;
    padding: 12px 15px;
    background: none;
    border: none;
    font-size: 0.95em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .left-menu button:hover, .left-menu button.active { background: #f1f1f1; }
  .main-content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
  }
  .hero {
    background: #4A90E2;
    color: white;
    padding: 30px 20px;
    text-align: center;
  }
  .hero h2 { margin: 0; font-size: 1.8em; }
  .hero p { margin-top: 8px; font-size: 1em; }
  .policy-content { padding: 25px; }
  .policy-section {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: 0 0 4px rgba(0,0,0,0.05);
  }
  .policy-section h3 {
    margin: 0 0 8px;
    color: #4A90E2;
    font-size: 1.3em;
  }
  .policy-section p {
    margin: 0;
    font-size: 1em;
    line-height: 1.6;
  }
  .sidebar {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  .sidebar-card {
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 0 6px rgba(0,0,0,0.1);
  }
  .star-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    font-size: 12px;
    text-align: center;
    border-radius: 3px;
    margin-right: 2px;
    color: white;
    background-color: #ccc;
  }
  .star-box.filled { background-color: #28a745; }
 
 
 .fixed-footer {
      position: fixed;
      left: 0;
      bottom: 0;
      width: 100%;
      background: #222;
      text-align: center;
      padding: 10px 0;
      color: #fff;
      z-index: 1000;
    }

   .fixed-footer p{
		font-family: 'Poppins', sans-serif !important;
		font-size: 13px !important;
	}

    .footer-menu a {
      margin: 0 10px;
      text-decoration: none;
      color: #fff;
	  font-family: 'Poppins', sans-serif !important;
	  font-size: 13px !important;
    }

    .footer-menu a:hover {
      text-decoration: underline;
    }
 
 
 .logo {
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #a2d4f5, #fefb72); /* light blue to lemon */
  border-radius: 50%;
  width: 36px;
  height: 36px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  margin-right: 8px;
}
</style>
</head>
<body>

<div class="topbar">
  <div class="logo"><div class="logo-icon"><i class="fas fa-shield-alt" style="color: skyblue; font-size: 25px; margin-left: 1px !important; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);"></i>
</div> REVIEW STREAM
  </div>
  <div class="menu-toggle" onclick="document.querySelector('.top-menu').classList.toggle('show')">
    <i class="fas fa-bars"></i>
  </div>
  <div class="top-menu">
   <a href="index.php">Home</a>
    <a href="companies.php">Companies</a>
    <a href="blog.php">Newsroom</a>
    <?php if(isset($_SESSION['user_id'])): ?>
      <a href="logout.php">Logout</a>
    <?php else: ?>
      <a href="login.php">Login</a>
    <?php endif; ?>
  </div>
</div>

<div class="menu-toggle" onclick="document.querySelector('.left-menu').classList.toggle('active')">
  <i class="fas fa-bars"></i> Menu
</div>




<div class="content-layout">
  <div class="left-menu">
    <ul>
      <li><button onclick="showPolicy('businesses')"><i class="fas fa-briefcase"></i> For Businesses</button></li>
      <li><button onclick="showPolicy('data')"><i class="fas fa-database"></i> Data Processing</button></li>
      <li><button onclick="showPolicy('cookies')"><i class="fas fa-cookie-bite"></i> Cookie Policy</button></li>
      <li><button onclick="showPolicy('diversity')"><i class="fas fa-users"></i> Diversity & Inclusion</button></li>
      <li><button onclick="showPolicy('ethics')"><i class="fas fa-scale-balanced"></i> Code of Ethics</button></li>
      <li><button onclick="showPolicy('supplier')"><i class="fas fa-handshake"></i> Supplier Code</button></li>
      <li><button onclick="showPolicy('social')"><i class="fas fa-comments"></i> Social Media</button></li>
      <li><button onclick="showPolicy('accessibility')"><i class="fas fa-universal-access"></i> Accessibility</button></li>
    </ul>
  </div>

  <div class="main-content" id="policyContent">
    <div class="hero">
      <h2>Privacy & Policy Center</h2>
      <p>Learn how we protect your data, promote fairness, and support our community.</p>
    </div>
    <div class="policy-content">
  <section class="policy-section">
    <h3>Welcome</h3>
    <p>
      At Review Stream, we take your trust seriously. This policy section outlines our core commitments to your privacy, ethical practices, inclusivity, and responsible data handling. Whether you're a reviewer, a business owner, or simply browsing, we believe you deserve transparency and respect at every touchpoint.
    </p>
	<br>
    <p>
      Use the menu to explore specific policies that explain how we protect your information, ensure honest interactions, and foster a platform that's fair, safe, and welcoming for everyone. We're always evolving, and your feedback helps shape our policies.
    </p>
	<br>
    <p>
      Thank you for being part of our community. If you have questions or concerns about anything you read here, please don’t hesitate to contact us.
    </p>
  </section>
</div>

  </div>

  <div class="sidebar">
    <div class="sidebar-card">
      <h4>Latest Reviews</h4>
    <?php foreach($latestReviews as $rev): ?>
      <p><strong><?= htmlspecialchars($rev['username']) ?></strong> on <em><?= htmlspecialchars($rev['company_name']) ?></em>:</p>
      <div>
        <?php for($i=1;$i<=5;$i++): ?>
          <span class="star-box <?= $i<=$rev['rating'] ? 'filled' : '' ?>">★</span>
        <?php endfor; ?>
        (<?= $rev['rating'] ?>/5)
      </div>
      <p style="margin-top:2px;"><?= htmlspecialchars(substr($rev['comment'],0,50)) ?>...</p>
      <hr>
    <?php endforeach; ?>
    </div>
    <div class="sidebar-card">
      <h4>Top Rated Companies</h4>
    <?php
    $topCompanies = $pdo->query("
      SELECT c.id, c.name, c.image, ROUND(AVG(r.rating),1) AS avg_rating
      FROM companies c
      JOIN reviews r ON c.id = r.company_id
      GROUP BY c.id
      HAVING COUNT(r.id) >= 1
      ORDER BY avg_rating DESC
      LIMIT 5
    ")->fetchAll();
    foreach($topCompanies as $top): ?>
      <div style="display:flex;align-items:center;gap:8px;margin-bottom:5px;">
        <img src="images/companies/<?= htmlspecialchars($top['image']) ?>" alt="<?= htmlspecialchars($top['name']) ?>" style="width:30px;height:30px;object-fit:contain;">
        <span><?= htmlspecialchars($top['name']) ?> (<?= $top['avg_rating'] ?>/5)</span>
      </div>
    <?php endforeach; ?>
    </div>
  </div>
</div>

<?php include 'footer.php'; ?>
<script>
function showPolicy(section) {
  let content = '';
  switch(section) {
    case 'businesses':
      content = `
        <section class="policy-section"><h3>For Businesses</h3>
        <p>Claim and verify your company profile to showcase credibility and help customers find you more easily. By responding thoughtfully to reviews—both positive and negative—you can demonstrate commitment to transparency and customer satisfaction. Following our guidelines helps foster trust with your audience and promotes constructive dialogue that benefits everyone.</p>
        <p>Our platform offers tools to flag potentially fraudulent reviews, share updates with followers, and highlight verified business achievements to reinforce your brand’s integrity. Engaging actively with your customers builds loyalty, improves your reputation, and sets you apart from competitors in your field.</p>
        </section>
        <section class="policy-section"><h3>Insights</h3>
        <p>Leverage analytics to better understand customer sentiment and market trends. Our insights dashboard helps track review volume, identify recurring themes, and monitor overall brand performance over time. This data enables you to spot areas of improvement, respond strategically, and adapt your services to meet evolving customer needs.</p>
        <p>Use these insights not only to improve customer experience but also to guide product development, team training, and marketing campaigns—helping your business grow sustainably based on real-world feedback.</p>
        </section>`;
      break;
    case 'data':
      content = `
        <section class="policy-section"><h3>Data Processing</h3>
        <p>We collect and process data transparently and responsibly, following standards set by GDPR, CCPA, and other applicable data privacy laws. This includes data you provide during account creation, interactions on the platform, and information automatically collected through cookies and similar technologies.</p>
        <p>Your data helps us deliver personalized content, improve user experience, and ensure platform security. All data is stored securely using encryption and access controls, and we continuously review our practices to stay compliant with the latest regulations.</p>
        </section>
        <section class="policy-section"><h3>Your Rights</h3>
        <p>As a user, you have the right to request access to your personal data, correct inaccuracies, and delete information when appropriate. You can also object to certain processing activities or request data portability. We aim to handle all requests promptly, typically within 30 days.</p>
        <p>To exercise these rights, simply contact our privacy team through your account dashboard or via email. We’re committed to giving you control over your personal data and keeping you informed about how it’s used.</p>
        </section>`;
      break;
    case 'cookies':
      content = `
        <section class="policy-section"><h3>Cookie Policy</h3>
        <p>Cookies help us personalize your experience, remember your preferences, and keep you logged in as you browse. They also enable us to analyze site usage and identify opportunities to improve our services. We may use first-party and third-party cookies, including for analytics and marketing purposes, always in accordance with applicable laws.</p>
        <p>Cookies allow features like remembering items in your dashboard, showing relevant suggestions, and delivering content tailored to your interests—making your visit smoother and more engaging.</p>
        </section>
        <section class="policy-section"><h3>Your Choices</h3>
        <p>You can manage or disable cookies anytime through your browser settings, although doing so might affect certain site features. We also provide an in-platform cookie settings panel to update your preferences easily.</p>
        <p>For more details about types of cookies and how we use them, please see our full Cookie Policy, which is regularly updated to reflect changes in technology and legal requirements.</p>
        </section>`;
      break;
    case 'diversity':
      content = `
        <section class="policy-section"><h3>Diversity & Inclusion</h3>
        <p>We’re dedicated to fostering a community that welcomes and respects everyone, regardless of race, gender, age, disability, religion, or background. We believe that diversity enriches our platform, sparks creativity, and leads to better solutions for users and businesses alike.</p>
        <p>Internally, we promote inclusive hiring practices and continuous learning to create an equitable work environment. Externally, we moderate content to discourage discrimination and promote respectful dialogue. Together, we can make this space truly inclusive and supportive of all voices.</p>
        </section>`;
      break;
    case 'ethics':
      content = `
        <section class="policy-section"><h3>Code of Ethics</h3>
        <p>Integrity, fairness, and accountability are at the core of what we do. We expect all users and businesses to act honestly, avoid misleading claims, and engage respectfully on the platform. Transparency in reviews and communications helps build a reliable and trustworthy community.</p>
        <p>We actively monitor and remove fraudulent content, and we encourage reporting of unethical practices. Upholding these principles ensures a safe, balanced space where everyone can share genuine experiences and insights.</p>
        </section>`;
      break;
    case 'supplier':
      content = `
        <section class="policy-section"><h3>Supplier Code</h3>
        <p>We work with suppliers and partners who share our commitment to ethical conduct, legal compliance, and environmental sustainability. This includes fair labor practices, respect for human rights, and measures to reduce environmental impact throughout the supply chain.</p>
        <p>Our Supplier Code outlines expectations regarding integrity, data protection, anti-corruption, and workplace safety. We regularly review and collaborate with partners to maintain these high standards and drive positive change beyond our platform.</p>
        </section>`;
      break;
    case 'social':
      content = `
        <section class="policy-section"><h3>Social Media</h3>
        <p>Our social media guidelines encourage respectful, constructive conversations that align with our values. Users should avoid offensive language, harassment, and misinformation when engaging on our official pages or mentioning our brand.</p>
        <p>We may moderate or remove content that violates these guidelines to maintain a positive, inclusive space where users can freely share ideas, feedback, and experiences while feeling safe and respected.</p>
        </section>`;
      break;
    case 'accessibility':
      content = `
        <section class="policy-section"><h3>Accessibility</h3>
        <p>Accessibility is central to our design and development process. We strive to make our website usable by everyone, including people with disabilities, by following recognized standards such as WCAG (Web Content Accessibility Guidelines).</p>
        <p>We continuously test and improve features like screen reader compatibility, keyboard navigation, and alternative text for images. We also welcome feedback from our community to identify and address barriers, ensuring a more inclusive experience for all.</p>
        </section>`;
      break;
    default:
      content = `<section class="policy-section"><h3>Section not found</h3><p>Try another option from the menu.</p></section>`;
  }
  document.querySelector('.policy-content').innerHTML = content;
}
</script>

</body>
</html>
