<?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>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Careers - Review Stream</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;600&display=swap" rel="stylesheet">
<!-- 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;
    background: #fafafa;
    color: #333;
    margin: 0;
	margin-bottom: 120px !important;
  }
  .content-layout { display: flex; gap: 20px; flex-wrap: wrap; }
  .main-content { flex: 3; min-width: 250px; }
  .sidebar { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 15px; }
  .hero {
    position: relative;
    background: url('https://images.pexels.com/photos/3184292/pexels-photo-3184292.jpeg?auto=compress&cs=tinysrgb&h=500') center/cover no-repeat;
    color: white;
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
    margin-bottom: 25px;
  }
  .hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
  }
  .hero-content {
    position: relative;
    padding: 60px 20px;
  }
  .hero h1 {
    font-size: 2em;
    margin-bottom: 10px;
  }
  .hero p {
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.1em;
  }
  .card {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    margin-bottom: 25px;
  }
  .values-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
  }
  .values-list li {
    background: #e8f5e9;
    margin: 8px 0;
    padding: 10px 15px;
    border-radius: 8px;
  }
  .banner-img {
    width: 100%;
    border-radius: 10px;
    margin: 15px 0;
  }
  .job-listing {
    display: grid;
    gap: 15px;
  }
  .job-card {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
  }
  .cta-card {
    text-align: center;
    background: #e8f5e9;
  }
  /* Sidebar reviews stars */
  .star-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    font-size: 12px;
    line-height: 16px;
    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;
    }
	
	
	
	 /* Collapsible menu */
  .menu { display: none; flex-direction: column; }
  .menu.active { display: flex; }
  .menu a { padding: 8px 0; text-decoration: none; color: #333; }
  .menu-toggle { font-size: 1.5em; cursor: pointer; }
  @media(min-width: 768px){
    .menu { display: flex !important; flex-direction: row; }
    .menu a { margin-left: 15px; }
    .menu-toggle { display: none; }
  }
  
	
	
	
 .topbar { 
  display:flex; 
  justify-content:space-between; 
  align-items:center; 
  padding:10px 20px; 
  background:#007BFF; 
  color:white; 
  }
 
  .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: 6px !important; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);"></i>
</div> REVIEW STREAM
  </div>
  <div class="menu-toggle" onclick="document.querySelector('.menu').classList.toggle('active')">
    <i class="fas fa-bars"></i>
  </div>
  
  
  <div class="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="user-settings.php">My Settings</a>
      <a href="logout.php">Logout</a>
    <?php else: ?>
      <a href="login.php">Login</a>
    <?php endif; ?>
    <button class="dark-mode-toggle" onclick="document.body.classList.toggle('dark-mode')">🌓</button>
  </div>
</div>



<div class="container">
  <div class="content-layout">
    <div class="main-content">

      <div class="hero">
        <div class="hero-content">
          <h1>Grow with Us</h1>
          <p>We're building tools to make reviews more authentic and communities more empowered. Come join our mission to make trust the norm online.</p>
        </div>
      </div>

      <div class="card">
        <h2>Our Mission & Values</h2>
        <p>We’re passionate about transparency, innovation, and real impact. At Review Stream, your ideas help millions make smarter choices every day.</p>
        <ul class="values-list">
          <li>🤝 Collaboration & openness</li>
          <li>🌱 Growth & continuous learning</li>
          <li>🌍 Inclusion & respect</li>
          <li>🚀 User-first innovation</li>
        </ul>
      </div>

      <div class="card">
        <h2>Life at Review Stream</h2>
        <img src="https://images.pexels.com/photos/3182763/pexels-photo-3182763.jpeg?auto=compress&cs=tinysrgb&h=400" alt="Team working together" class="banner-img">
        <p>Whether remote or in person, we stay connected through daily stand-ups, creative brainstorms, and fun team meetups. Together, we share a common goal: building trust across the internet.</p>
      </div>

      <div class="card">
        <h2>Current Openings</h2>
        <div class="job-listing">
          <div class="job-card">
            <h4>Frontend Developer</h4>
            <p>Create beautiful user experiences using modern JavaScript frameworks. Remote-friendly, full-time.</p>
          </div>
          <div class="job-card">
            <h4>Content Moderator</h4>
            <p>Help keep our community safe by reviewing user content. Detail-oriented and ethical mindset required. Part-time or contract.</p>
          </div>
          <div class="job-card">
            <h4>Community Manager</h4>
            <p>Engage users, foster discussion, and boost community growth. Great communication skills needed. Remote or hybrid.</p>
          </div>
        </div>
      </div>

      <div class="card cta-card">
        <h2>Don't see your dream role?</h2>
        <p>We love meeting talented people. Send your CV to <a href="mailto:careers@previewstream.online">careers@previewstream.online</a> and tell us why you'd be a great fit!</p>
      </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>
</div>

<?php include 'footer.php'; ?>
</body>
</html>
