<?php
$page_title  = "Our Success Stories — CY Consultancy Centre";
$page_desc   = "500+ successful visa approvals. Real students, real dreams achieved. CY Consultancy Centre since 2008.";
$active_page = "success";
include 'includes/header.php';
$B = BASE_PATH;

// Load success stories from DB
$db_stories = [];
$db = site_db();
if ($db) {
    $res = $db->query("SELECT * FROM success_stories WHERE status='active' ORDER BY sort_order,id DESC");
    if ($res) $db_stories = $res->fetch_all(MYSQLI_ASSOC);
}

// Success/visa approval images — first batch are the visa congratulations posts
$success_images = [
  "gallery/gallery_034.jpg","gallery/gallery_035.jpg","gallery/gallery_036.jpg",
  "gallery/gallery_037.jpg","gallery/gallery_038.jpg","gallery/gallery_039.jpg",
  "gallery/gallery_040.jpg","gallery/gallery_041.jpg","gallery/gallery_042.jpg",
  "gallery/gallery_043.jpg","gallery/gallery_044.jpg","gallery/gallery_045.jpg",
  "gallery/gallery_046.jpg","gallery/gallery_047.jpg","gallery/gallery_048.jpg",
  "gallery/gallery_049.jpg","gallery/gallery_052.jpg","gallery/gallery_053.jpg",
  "gallery/gallery_054.jpg","gallery/gallery_055.jpg","gallery/gallery_056.jpg",
  "gallery/gallery_057.jpg","gallery/gallery_058.jpg","gallery/gallery_059.jpg",
  "gallery/gallery_060.jpg","gallery/gallery_061.jpg","gallery/gallery_062.jpg",
  "gallery/gallery_063.jpg","gallery/gallery_064.jpg","gallery/gallery_065.jpg",
  "gallery/gallery_066.jpg","gallery/gallery_067.jpg","gallery/gallery_068.jpg",
  "gallery/gallery_069.jpg","gallery/gallery_070.jpg","gallery/gallery_071.jpg",
  "gallery/gallery_072.jpg","gallery/gallery_073.jpg","gallery/gallery_074.jpg",
  "gallery/gallery_075.jpg","gallery/gallery_076.jpg","gallery/gallery_077.jpg",
  "gallery/gallery_078.jpg","gallery/gallery_079.jpg","gallery/gallery_080.jpg",
];
?>
<style>
.success-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}
.success-card {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.05);
  transition: all .4s cubic-bezier(.16,1,.3,1);
  cursor: pointer;
  position: relative;
}
.success-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 24px 60px rgba(230,57,70,.12);
}
.success-card img {
  width: 100%; height: 200px;
  object-fit: cover; display: block;
  transition: transform .5s cubic-bezier(.16,1,.3,1);
}
.success-card:hover img { transform: scale(1.06); }
.success-badge {
  position: absolute; top: 12px; left: 12px;
  background: var(--r); color: #fff;
  padding: 4px 10px; border-radius: 50px;
  font-size: 10px; font-weight: 800;
  display: flex; align-items: center; gap: 4px;
}
.sc-body { padding: 14px; }
.sc-body .sc-title { font-size: 13px; font-weight: 700; color: var(--n); margin-bottom: 3px; }
.sc-body .sc-dest  { font-size: 11px; color: var(--tx3); display: flex; align-items: center; gap: 4px; }

/* Stats banner */
.success-stats {
  background: linear-gradient(135deg, var(--n), var(--n2));
  padding: 48px 24px;
  text-align: center;
  color: #fff;
}
.ss-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  max-width: 800px;
  margin: 32px auto 0;
}
.ss-item .ss-num {
  font-family: 'Playfair Display', serif;
  font-size: 48px; font-weight: 700;
  color: var(--g); line-height: 1;
}
.ss-item .ss-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.5); margin-top: 6px;
}
@media(max-width:768px) {
  .success-grid { grid-template-columns: repeat(2,1fr); gap:12px; }
  .ss-grid { grid-template-columns: repeat(2,1fr); }
}
@media(max-width:480px) {
  .success-grid { grid-template-columns: 1fr; }
}
</style>

<!-- PAGE HERO -->
<div class="page-hero" style="padding:140px 24px 60px;text-align:center">
  <span class="tag" style="position:relative;z-index:1;color:var(--g)">Real Results</span>
  <h1 style="color:#fff;font-size:clamp(28px,4vw,48px);margin-bottom:10px;position:relative;z-index:1">
    Our Success Stories 🎉
  </h1>
  <p style="color:rgba(255,255,255,.55);max-width:520px;margin:0 auto 16px;position:relative;z-index:1">
    500+ Bangladeshi students achieved their study abroad dream with CY Consultancy Centre. Here are their stories.
  </p>
  <div class="breadcrumb">
    <a href="<?= $B ?>index.php">Home</a>
    <i class="fas fa-chevron-right"></i>
    <span>Our Success</span>
  </div>
</div>

<!-- STATS BANNER -->
<div class="success-stats">
  <div data-aos="fade-up">
    <span class="tag" style="color:var(--g)">By The Numbers</span>
    <h2 style="color:#fff;font-size:clamp(22px,3vw,34px)">CY Consultancy in Numbers</h2>
  </div>
  <div class="ss-grid">
    <div class="ss-item" data-aos="fade-up" data-aos-delay="0">
      <div class="ss-num counter" data-target="500">0</div>
      <div class="ss-label">Visas Approved</div>
    </div>
    <div class="ss-item" data-aos="fade-up" data-aos-delay="100">
      <div class="ss-num">95%</div>
      <div class="ss-label">Success Rate</div>
    </div>
    <div class="ss-item" data-aos="fade-up" data-aos-delay="200">
      <div class="ss-num counter" data-target="17">0</div>
      <div class="ss-label">Years Experience</div>
    </div>
    <div class="ss-item" data-aos="fade-up" data-aos-delay="300">
      <div class="ss-num counter" data-target="12">0</div>
      <div class="ss-label">Countries</div>
    </div>
  </div>
</div>

<!-- SUCCESS GRID -->
<section class="sec" style="background:var(--bgf)">
  <div style="max-width:1280px;margin:0 auto">
    <div class="sh" data-aos="fade-up">
      <span class="tag">Visa Approvals</span>
      <h2>Congratulations to Our Students!</h2>
      <p>Every photo is a dream fulfilled — a Bangladeshi student reaching their global destination.</p>
    </div>
    <div class="success-grid">
      <?php foreach($success_images as $idx => $img): ?>
      <div class="success-card" data-aos="zoom-in" data-aos-delay="<?= min(($idx % 8) * 60, 400) ?>"
           onclick="openLightbox(<?= $idx ?>)">
        <img src="<?= $B ?>assets/images/<?= $img ?>" alt="Success Story <?= $idx+1 ?>" loading="lazy">
        <div class="success-badge"><i class="fas fa-check-circle"></i> Visa Approved!</div>
        <div class="sc-body">
          <div class="sc-title">CY Consultancy Student</div>
          <div class="sc-dest"><i class="fas fa-plane" style="color:var(--r);font-size:9px"></i> Study Abroad 🇲🇹 🇬🇧 🇨🇦</div>
        </div>
      </div>
      <?php endforeach; ?>
    </div>

    <div style="text-align:center;margin-top:40px" data-aos="fade-up">
      <a href="<?= $B ?>gallery.php" class="btn btn-r"><i class="fas fa-images"></i> View Full Gallery</a>
      &nbsp;
      <a href="<?= $B ?>contact.php" class="btn btn-g"><i class="fas fa-arrow-right"></i> Start Your Journey</a>
    </div>
  </div>
</section>

<!-- LIGHTBOX -->
<div id="lightbox" style="position:fixed;inset:0;z-index:99999;background:rgba(5,9,15,.95);display:none;align-items:center;justify-content:center;backdrop-filter:blur(12px);opacity:0;transition:opacity .3s">
  <button onclick="closeLightbox()" style="position:absolute;top:20px;right:24px;color:#fff;font-size:28px;background:rgba(255,255,255,.1);border:none;width:48px;height:48px;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center"><i class="fas fa-times"></i></button>
  <button onclick="lbNav(-1)" style="position:absolute;top:50%;left:20px;transform:translateY(-50%);color:#fff;font-size:20px;background:rgba(255,255,255,.1);border:none;width:50px;height:50px;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center"><i class="fas fa-chevron-left"></i></button>
  <img id="lb-img" src="" style="max-width:90vw;max-height:86vh;border-radius:16px;display:block;transition:opacity .2s,transform .2s">
  <button onclick="lbNav(1)" style="position:absolute;top:50%;right:20px;transform:translateY(-50%);color:#fff;font-size:20px;background:rgba(255,255,255,.1);border:none;width:50px;height:50px;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center"><i class="fas fa-chevron-right"></i></button>
  <div id="lb-counter" style="position:absolute;bottom:24px;left:50%;transform:translateX(-50%);color:rgba(255,255,255,.6);font-size:12px;font-weight:700;background:rgba(255,255,255,.08);padding:6px 16px;border-radius:50px"></div>
</div>
<script>
var lbImages = [<?php foreach($success_images as $img): ?>"<?= $B ?>assets/images/<?= $img ?>",<?php endforeach; ?>];
var lbCurrent = 0;
function openLightbox(idx){
  lbCurrent=idx;
  var lb=document.getElementById('lightbox');
  document.getElementById('lb-img').src=lbImages[idx];
  lb.style.display='flex'; requestAnimationFrame(function(){lb.style.opacity='1';});
  document.body.style.overflow='hidden';
  document.getElementById('lb-counter').textContent=(idx+1)+' / '+lbImages.length;
}
function closeLightbox(){
  var lb=document.getElementById('lightbox');
  lb.style.opacity='0'; setTimeout(function(){lb.style.display='none';document.body.style.overflow='';},300);
}
function lbNav(d){
  lbCurrent=(lbCurrent+d+lbImages.length)%lbImages.length;
  var img=document.getElementById('lb-img');
  img.style.opacity='0'; img.style.transform='scale(.9)';
  setTimeout(function(){img.src=lbImages[lbCurrent];img.style.opacity='1';img.style.transform='scale(1)';document.getElementById('lb-counter').textContent=(lbCurrent+1)+' / '+lbImages.length;},150);
}
document.addEventListener('keydown',function(e){if(document.getElementById('lightbox').style.display==='flex'){if(e.key==='ArrowLeft')lbNav(-1);if(e.key==='ArrowRight')lbNav(1);if(e.key==='Escape')closeLightbox();}});
</script>

<?php include 'includes/footer.php'; ?>
