<?php
// User token kontrolü - giriş yapmış kullanıcıları index'e yönlendir
$user_token = $_COOKIE['user_token'] ?? null;
if (!empty($user_token)) {
    header("Location: index.php");
    exit();
}

// Veritabanından bot kullanıcıları çek
include 'config.php';
$stmt = $db->query("SELECT user_picture FROM kullanicilar WHERE user_bot = 1 AND user_picture IS NOT NULL AND user_picture != '' AND user_id > 10000 AND user_picture NOT LIKE '%kadin-avatar.png%' AND user_picture NOT LIKE '%no-avatar.png%' ORDER BY RAND() LIMIT 9");
$botUsers = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Thumbnail versiyonlarını kullan (daha hafif)
foreach ($botUsers as &$user) {
    $pic = $user['user_picture'];
    $pic = str_replace('.jpg', '_thumb.jpg', $pic);
    $pic = str_replace('people/', 'people/thumb/', $pic);
    $user['user_picture'] = $pic;
}
unset($user);

// Random kelime seçimi
$kelimeler = array('Dul', 'Bekar', 'Genç', 'Türk');
$randomKelime = $kelimeler[array_rand($kelimeler)];
?>
<!DOCTYPE html>
<html lang="tr">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
  <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=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <title>HeySen - Hoş Geldin</title>
  <style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== CONTAINER ===== */
.welcome-screen {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  padding: 20px 20px 20px;
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

/* Background Decoration */
.welcome-screen::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
  border-radius: 50%;
  animation: floatBg 8s ease-in-out infinite;
  will-change: transform;
}

.welcome-screen::after {
  content: '';
  position: absolute;
  bottom: -100px;
  left: -100px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  animation: floatBg 10s ease-in-out infinite reverse;
  will-change: transform;
}

@keyframes floatBg {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(15px, 15px); }
}

/* ===== LOGO ===== */
.logo-section {
  text-align: center;
  margin-bottom: 15px;
  z-index: 2;
  animation: fadeInDown 0.6s ease;
  flex-shrink: 0;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-section img {
  height: 28px;
}

/* ===== PHOTOS GRID ===== */
.photos-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
  min-height: 0;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.photo-item {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  animation: fadeInScale 0.6s ease backwards, floatPhoto 4s ease-in-out infinite;
  will-change: transform;
}

/* Farklı animasyon gecikmeleri */
.photo-item:nth-child(1) { animation-delay: 0.05s, 0s; }
.photo-item:nth-child(2) { animation-delay: 0.1s, 0.4s; }
.photo-item:nth-child(3) { animation-delay: 0.15s, 0.8s; }
.photo-item:nth-child(4) { animation-delay: 0.2s, 1.2s; }
.photo-item:nth-child(5) { animation-delay: 0.25s, 1.6s; }
.photo-item:nth-child(6) { animation-delay: 0.3s, 2s; }
.photo-item:nth-child(7) { animation-delay: 0.35s, 2.4s; }
.photo-item:nth-child(8) { animation-delay: 0.4s, 2.8s; }
.photo-item:nth-child(9) { animation-delay: 0.45s, 3.2s; }

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes floatPhoto {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Heart floating animation */
.photo-item::after {
  content: '💕';
  position: absolute;
  bottom: 0;
  left: 50%;
  font-size: 14px;
  opacity: 0;
  animation: floatHeart 3s ease-in-out infinite;
  will-change: transform, opacity;
  pointer-events: none;
}

.photo-item:nth-child(1)::after { animation-delay: 0.5s; }
.photo-item:nth-child(2)::after { animation-delay: 1s; }
.photo-item:nth-child(3)::after { animation-delay: 1.5s; }
.photo-item:nth-child(4)::after { animation-delay: 2s; }
.photo-item:nth-child(5)::after { animation-delay: 0s; }
.photo-item:nth-child(6)::after { animation-delay: 2.5s; }
.photo-item:nth-child(7)::after { animation-delay: 0.8s; }
.photo-item:nth-child(8)::after { animation-delay: 1.8s; }
.photo-item:nth-child(9)::after { animation-delay: 1.2s; }

@keyframes floatHeart {
  0% { transform: translateX(-50%) translateY(0); opacity: 0; }
  20% { opacity: 0.8; }
  100% { transform: translateX(-50%) translateY(-80px); opacity: 0; }
}

.online-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  border: 1.5px solid white;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s ease-in-out infinite;
  will-change: transform, box-shadow;
  z-index: 2;
}

@keyframes pulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  50% { 
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

/* ===== CONTENT ===== */
.content-section {
  text-align: center;
  z-index: 2;
  animation: fadeInUp 0.8s ease;
  flex-shrink: 0;
}

.welcome-title {
  font-size: 22px;
  font-weight: 900;
  color: white;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
  margin-bottom: 10px;
  line-height: 1.4;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: white;
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  animation: bounceIn 0.6s ease backwards;
}

.stat-badge:nth-child(1) { animation-delay: 0.6s; }
.stat-badge:nth-child(2) { animation-delay: 0.7s; }

@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.stat-badge.online {
  background: linear-gradient(135deg, #ebf8ff, #e9f5ff);
  color: #667eea;
}

.stat-badge.free {
  background: linear-gradient(135deg, #f0fff4, #e6fffa);
  color: #10b981;
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: statPulse 2s ease-in-out infinite;
  will-change: transform;
}

@keyframes statPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

.stat-badge.online .stat-dot {
  background: #667eea;
}

.stat-badge.free .stat-dot {
  background: #10b981;
}

/* ===== BUTTON ===== */
.btn-get-started {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
  margin-bottom: 10px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 1s ease;
}

/* Shimmer/Shine Effect - GPU optimized */
.btn-get-started::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shine 2.5s ease-in-out infinite;
  transform: translateX(-100%) skewX(-15deg);
  will-change: transform;
}

@keyframes shine {
  0% { transform: translateX(-100%) skewX(-15deg); }
  100% { transform: translateX(200%) skewX(-15deg); }
}

/* Ripple effect on click */
.btn-get-started::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s, opacity 0.6s;
  opacity: 0;
}

.btn-get-started:active::after {
  width: 300px;
  height: 300px;
  opacity: 1;
  transition: 0s;
}

.btn-get-started:active {
  transform: scale(0.98);
}

/* ===== LOGIN LINK ===== */
.login-link {
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  padding-bottom: 0;
  animation: fadeInUp 1.1s ease;
}

.login-link a {
  color: white;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.login-link a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: white;
  transition: width 0.3s ease;
}

.login-link a:hover::after {
  width: 100%;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== RESPONSIVE ===== */
@media (max-height: 750px) {
  .welcome-screen {
    padding: 18px 20px;
  }
  
  .logo-section {
    margin-bottom: 12px;
  }
  
  .photos-grid {
    gap: 8px;
    max-width: 300px;
  }
  
  .photos-container {
    margin-bottom: 12px;
  }
  
  .welcome-title {
    font-size: 20px;
    margin-bottom: 5px;
  }
  
  .welcome-subtitle {
    font-size: 12px;
    margin-bottom: 8px;
  }
  
  .stats-row {
    margin-bottom: 14px;
  }
  
  .btn-get-started {
    padding: 14px;
    font-size: 15px;
  }
}

@media (max-height: 680px) {
  .welcome-screen {
    padding: 15px 20px;
  }
  
  .logo-section {
    margin-bottom: 10px;
  }
  
  .logo-section img {
    height: 26px;
  }
  
  .photos-grid {
    gap: 8px;
    max-width: 270px;
  }
  
  .photos-container {
    margin-bottom: 10px;
  }
  
  .welcome-title {
    font-size: 19px;
    margin-bottom: 4px;
  }
  
  .welcome-subtitle {
    font-size: 12px;
    margin-bottom: 7px;
  }
  
  .stats-row {
    margin-bottom: 12px;
  }
  
  .btn-get-started {
    padding: 13px;
    font-size: 15px;
  }
}

@media (max-height: 620px) {
  .welcome-screen {
    padding: 12px 18px;
  }
  
  .logo-section {
    margin-bottom: 8px;
  }
  
  .logo-section img {
    height: 24px;
  }
  
  .photos-grid {
    gap: 7px;
    max-width: 240px;
  }
  
  .photos-container {
    margin-bottom: 8px;
  }
  
  .welcome-title {
    font-size: 18px;
    margin-bottom: 4px;
  }
  
  .welcome-subtitle {
    font-size: 11px;
    margin-bottom: 6px;
    line-height: 1.3;
  }
  
  .stats-row {
    margin-bottom: 10px;
    gap: 10px;
  }
  
  .stat-badge {
    padding: 5px 10px;
    font-size: 10px;
  }
  
  .stat-dot {
    width: 6px;
    height: 6px;
  }
  
  .btn-get-started {
    padding: 12px;
    font-size: 14px;
    margin-bottom: 8px;
  }
  
  .login-link {
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  .photos-grid {
    max-width: 300px;
  }
}

@media (min-width: 768px) {
  .welcome-screen {
    border-radius: 24px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
    height: auto;
    max-height: 90vh;
  }
}

/* Loading Spinner */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-get-started.loading {
  pointer-events: none;
  opacity: 0.8;
}
  </style>
</head>
<body>

<div class="welcome-screen">
  <!-- Logo -->
  <div class="logo-section">
    <img src="https://app.heysen.net/assets/img/logo.png" alt="HeySen">
  </div>

  <!-- Photos Grid -->
  <div class="photos-container">
    <div class="photos-grid">
      <?php foreach($botUsers as $user): ?>
      <div class="photo-item">
        <span class="online-indicator"></span>
        <img src="<?=$user['user_picture']?>" alt="Profil">
      </div>
      <?php endforeach; ?>
    </div>
  </div>

  <!-- Content -->
  <div class="content-section">
    <h1 class="welcome-title">Seni Bekleyen Binlerce<br><?=$randomKelime?> Kadınla Tanış! 💕</h1>
    <p class="welcome-subtitle">Hemen ücretsiz üye ol ve yeni<br>insanlarla bağlantı kur</p>
    
    <div class="stats-row">
      <div class="stat-badge free">
        <span class="stat-dot"></span>
        <span><?=number_format(rand(2000, 3000), 0, ',', '.')?> Çevrimiçi</span>
      </div>
      <div class="stat-badge online">
        <span class="stat-dot"></span>
        <span>%100 Ücretsiz Üyelik</span>
      </div>
    </div>

    <a href="register.php" class="btn-get-started" id="registerBtn">
      <i class="fas fa-hand-pointer"></i>
      <span class="btn-text">Dokun ve Hesap Oluştur</span>
    </a>

    <div class="login-link">
      Zaten hesabın var mı? <a href="login.php">Giriş Yap</a>
    </div>
  </div>
</div>

<script>
document.getElementById('registerBtn').addEventListener('click', function(e) {
  e.preventDefault();
  
  const btn = this;
  const icon = btn.querySelector('i');
  const text = btn.querySelector('.btn-text');
  
  // Loading durumuna geç
  btn.classList.add('loading');
  icon.className = 'btn-spinner';
  text.textContent = 'Yükleniyor...';
  
  // Direkt yönlendir
  window.location.href = 'register.php';
});

// Android geri tuşunu engelle
history.pushState(null, null, location.href);
window.onpopstate = function() {
  history.pushState(null, null, location.href);
};
</script>

</body>
</html>
