<?php
/**
 * SMM Paket Satış Scripti - Admin Panel
 * Gelişmiş Dashboard - İstatistikler, Şüpheli Aktiviteler, Grafikler
 * @version 2.0.0
 */

require_once __DIR__ . '/../config.php';

// Çıkış
if (isset($_GET['cikis'])) {
    session_destroy();
    session_start();
    setFlash('success', 'Başarıyla çıkış yaptınız.');
    redirect(SITE_URL . '/admin/');
    exit;
}

$showLogin = !isLoggedIn() || !isAdmin();
$loginErrors = [];
$loginData = ['login' => ''];

// Giriş işlemi
if ($showLogin && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['login_form'])) {
    if (!validateCSRFToken($_POST['csrf_token'] ?? '')) {
        $loginErrors[] = 'Güvenlik doğrulaması başarısız.';
    }
    
    $login = trim($_POST['login'] ?? '');
    $password = $_POST['password'] ?? '';
    $loginData['login'] = $login;
    
    if (empty($login)) $loginErrors[] = 'Kullanıcı adı veya e-posta gerekli.';
    if (empty($password)) $loginErrors[] = 'Şifre gerekli.';
    
    if (empty($loginErrors)) {
        try {
            $stmt = $db->prepare("SELECT * FROM users WHERE (username = ? OR email = ?) AND role = 'admin' AND status = 'active' LIMIT 1");
            $stmt->execute([$login, $login]);
            $user = $stmt->fetch();
            
            if ($user && password_verify($password, $user['password'])) {
                $_SESSION['user_id'] = $user['id'];
                $_SESSION['user_name'] = $user['full_name'] ?: $user['username'];
                $_SESSION['user_email'] = $user['email'];
                $_SESSION['user_role'] = $user['role'];
                $_SESSION['username'] = $user['username'];
                
                setFlash('success', 'Hoş geldiniz!');
                redirect(SITE_URL . '/admin/');
                exit;
            } else {
                $loginErrors[] = 'Kullanıcı adı veya şifre hatalı.';
            }
        } catch (PDOException $e) {
            $loginErrors[] = 'Bir hata oluştu.';
        }
    }
}

// =============================================
// GİRİŞ SAYFASI
// =============================================
if ($showLogin):
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="theme-color" content="#0f172a">
    <title>Admin Giriş - <?php echo clean(SITE_NAME); ?></title>
    
    <?php if ($settings->getFaviconUrl()): ?>
    <link rel="icon" href="<?php echo clean($settings->getFaviconUrl()); ?>">
    <?php endif; ?>
    
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <style>
    :root {
        --primary: <?php echo $theme['primary_color']; ?>;
        --secondary: <?php echo $theme['secondary_color']; ?>;
        --primary-rgb: <?php echo hexToRgb($theme['primary_color']); ?>;
        --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }
    
    body {
        font-family: 'Inter', sans-serif;
        background: #0f172a;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        position: relative;
        overflow-x: hidden;
    }

    html { height: -webkit-fill-available; }

    .bg-gradient {
        position: fixed;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(ellipse at center, rgba(var(--primary-rgb), 0.12) 0%, transparent 50%);
        animation: rotate 40s linear infinite;
        pointer-events: none;
    }

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

    .login-container {
        position: relative;
        z-index: 10;
        width: 100%;
        max-width: 420px;
    }

    .login-card {
        background: rgba(30, 41, 59, 0.95);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 20px;
        padding: 40px 30px;
        box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    }

    .login-header { text-align: center; margin-bottom: 35px; }

    .login-logo {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-size: 24px;
        font-weight: 800;
        color: #fff;
        margin-bottom: 10px;
    }

    .login-logo i { color: var(--primary); }
    .login-logo img { height: 40px; }

    .login-subtitle {
        color: rgba(255,255,255,0.5);
        font-size: 14px;
        margin-bottom: 12px;
    }

    .login-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: rgba(var(--primary-rgb), 0.1);
        border: 1px solid rgba(var(--primary-rgb), 0.3);
        padding: 6px 14px;
        border-radius: 50px;
        font-size: 12px;
        font-weight: 600;
        color: var(--primary);
    }

    .error-box {
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid rgba(239, 68, 68, 0.3);
        border-radius: 12px;
        padding: 12px 15px;
        margin-bottom: 20px;
    }

    .error-box ul { list-style: none; margin: 0; padding: 0; }

    .error-box li {
        color: #ef4444;
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 5px;
    }

    .error-box li:last-child { margin-bottom: 0; }

    .success-box {
        background: rgba(16, 185, 129, 0.1);
        border: 1px solid rgba(16, 185, 129, 0.3);
        border-radius: 12px;
        padding: 12px 15px;
        margin-bottom: 20px;
        color: #10b981;
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .form-group { margin-bottom: 18px; }

    .form-label {
        display: block;
        color: rgba(255,255,255,0.8);
        font-weight: 500;
        font-size: 13px;
        margin-bottom: 8px;
    }

    .input-group { position: relative; }

    .input-icon {
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: rgba(255,255,255,0.3);
        font-size: 15px;
        pointer-events: none;
        transition: color 0.3s;
    }

    .form-control {
        width: 100%;
        background: rgba(15, 23, 42, 0.8);
        border: 1px solid rgba(255,255,255,0.1);
        border-radius: 12px;
        padding: 14px 45px;
        color: #fff;
        font-size: 14px;
        font-family: inherit;
        transition: all 0.3s;
    }

    .form-control:focus {
        outline: none;
        border-color: var(--primary);
        background: rgba(var(--primary-rgb), 0.05);
        box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    }

    .form-control:focus ~ .input-icon { color: var(--primary); }
    .form-control::placeholder { color: rgba(255,255,255,0.3); }

    .password-toggle {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: rgba(255,255,255,0.3);
        cursor: pointer;
        padding: 5px;
        font-size: 15px;
        transition: color 0.3s;
    }

    .password-toggle:hover { color: var(--primary); }

    .btn-login {
        width: 100%;
        background: var(--gradient);
        border: none;
        color: #fff;
        padding: 14px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        transition: all 0.3s;
        margin-top: 8px;
    }

    .btn-login:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.4);
    }

    .btn-login:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

    .btn-login .spinner {
        width: 18px;
        height: 18px;
        border: 2px solid rgba(255,255,255,0.3);
        border-top-color: #fff;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

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

    .login-footer {
        text-align: center;
        margin-top: 25px;
        padding-top: 20px;
        border-top: 1px solid rgba(255,255,255,0.08);
    }

    .back-link {
        color: rgba(255,255,255,0.5);
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        transition: color 0.3s;
    }

    .back-link:hover { color: var(--primary); }

    @media (max-width: 480px) {
        body { padding: 15px; }
        .login-card { padding: 30px 20px; border-radius: 16px; }
        .login-logo { font-size: 20px; }
        .login-logo img { height: 35px; }
    }
    </style>
</head>
<body>
    <div class="bg-gradient"></div>

    <div class="login-container">
        <div class="login-card">
            <div class="login-header">
                <div class="login-logo">
                    <?php if ($settings->getLogoUrl()): ?>
                        <img src="<?php echo clean($settings->getLogoUrl()); ?>" alt="">
                    <?php else: ?>
                        <i class="fas fa-bolt"></i>
                        <span><?php echo clean(SITE_NAME); ?></span>
                    <?php endif; ?>
                </div>
                <p class="login-subtitle">Yönetim Paneli</p>
                <div class="login-badge">
                    <i class="fas fa-shield-alt"></i>
                    Admin Girişi
                </div>
            </div>

            <?php if ($flash = getFlash()): ?>
                <div class="success-box">
                    <i class="fas fa-check-circle"></i>
                    <?php echo clean($flash['message']); ?>
                </div>
            <?php endif; ?>

            <?php if (!empty($loginErrors)): ?>
                <div class="error-box">
                    <ul>
                        <?php foreach ($loginErrors as $error): ?>
                            <li><i class="fas fa-exclamation-circle"></i> <?php echo clean($error); ?></li>
                        <?php endforeach; ?>
                    </ul>
                </div>
            <?php endif; ?>

            <form method="POST" id="loginForm">
                <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
                <input type="hidden" name="login_form" value="1">

                <div class="form-group">
                    <label class="form-label">Kullanıcı Adı veya E-posta</label>
                    <div class="input-group">
                        <input type="text" name="login" class="form-control" placeholder="admin" value="<?php echo clean($loginData['login']); ?>" required autofocus>
                        <i class="fas fa-user input-icon"></i>
                    </div>
                </div>

                <div class="form-group">
                    <label class="form-label">Şifre</label>
                    <div class="input-group">
                        <input type="password" name="password" id="password" class="form-control" placeholder="••••••••" required>
                        <i class="fas fa-lock input-icon"></i>
                        <button type="button" class="password-toggle" onclick="togglePassword()">
                            <i class="fas fa-eye" id="toggleIcon"></i>
                        </button>
                    </div>
                </div>

                <button type="submit" class="btn-login" id="submitBtn">
                    <i class="fas fa-sign-in-alt"></i>
                    <span>Giriş Yap</span>
                </button>
            </form>

            <div class="login-footer">
                <a href="<?php echo SITE_URL; ?>" class="back-link">
                    <i class="fas fa-arrow-left"></i>
                    Siteye Dön
                </a>
            </div>
        </div>
    </div>

    <script>
    function togglePassword() {
        const input = document.getElementById('password');
        const icon = document.getElementById('toggleIcon');
        input.type = input.type === 'password' ? 'text' : 'password';
        icon.classList.toggle('fa-eye');
        icon.classList.toggle('fa-eye-slash');
    }

    document.getElementById('loginForm').addEventListener('submit', function() {
        const btn = document.getElementById('submitBtn');
        btn.disabled = true;
        btn.innerHTML = '<div class="spinner"></div><span>Giriş yapılıyor...</span>';
    });
    </script>
</body>
</html>
<?php exit; endif;

// =============================================
// DASHBOARD - GELİŞMİŞ İSTATİSTİKLER
// =============================================

try {
    // Temel İstatistikler - Sadece TAMAMLANAN siparişler
    $stats = [
        // Gelir - Sadece completed
        'total_revenue' => $db->query("SELECT COALESCE(SUM(amount), 0) FROM orders WHERE status = 'completed'")->fetchColumn() ?: 0,
        'today_revenue' => $db->query("SELECT COALESCE(SUM(amount), 0) FROM orders WHERE DATE(created_at) = CURDATE() AND status = 'completed'")->fetchColumn() ?: 0,
        'week_revenue' => $db->query("SELECT COALESCE(SUM(amount), 0) FROM orders WHERE created_at >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND status = 'completed'")->fetchColumn() ?: 0,
        'month_revenue' => $db->query("SELECT COALESCE(SUM(amount), 0) FROM orders WHERE MONTH(created_at) = MONTH(CURDATE()) AND YEAR(created_at) = YEAR(CURDATE()) AND status = 'completed'")->fetchColumn() ?: 0,
        
        // Sipariş Sayıları
        'total_orders' => $db->query("SELECT COUNT(*) FROM orders")->fetchColumn() ?: 0,
        'completed_orders' => $db->query("SELECT COUNT(*) FROM orders WHERE status = 'completed'")->fetchColumn() ?: 0,
        'pending_orders' => $db->query("SELECT COUNT(*) FROM orders WHERE status = 'pending'")->fetchColumn() ?: 0,
        'processing_orders' => $db->query("SELECT COUNT(*) FROM orders WHERE status = 'processing'")->fetchColumn() ?: 0,
        'cancelled_orders' => $db->query("SELECT COUNT(*) FROM orders WHERE status IN ('cancelled', 'refunded')")->fetchColumn() ?: 0,
        'today_orders' => $db->query("SELECT COUNT(*) FROM orders WHERE DATE(created_at) = CURDATE()")->fetchColumn() ?: 0,
        
        // Kullanıcılar
        'total_users' => $db->query("SELECT COUNT(*) FROM users WHERE role = 'user'")->fetchColumn() ?: 0,
        
        // KDV Toplamı
        'total_kdv' => $db->query("SELECT COALESCE(SUM(kdv_amount), 0) FROM orders WHERE status = 'completed' AND kdv_amount IS NOT NULL")->fetchColumn() ?: 0,
        
        // İndirim Toplamı
        'total_discount' => $db->query("SELECT COALESCE(SUM(discount_amount), 0) FROM orders WHERE status = 'completed'")->fetchColumn() ?: 0,
    ];
    
    // API Maliyet ve Kar Hesaplaması
    $apiStats = $db->query("
        SELECT 
            COUNT(*) as total_api_orders,
            COALESCE(SUM(amount), 0) as total_api_revenue,
            COALESCE(SUM(api_charge), 0) as total_api_cost
        FROM orders 
        WHERE api_order_id IS NOT NULL AND status = 'completed'
    ")->fetch(PDO::FETCH_ASSOC);
    
    $stats['api_orders'] = $apiStats['total_api_orders'] ?? 0;
    $stats['api_revenue'] = $apiStats['total_api_revenue'] ?? 0;
    $stats['api_cost'] = $apiStats['total_api_cost'] ?? 0;
    $stats['api_profit'] = $stats['api_revenue'] - $stats['api_cost'];
    $stats['api_profit_margin'] = $stats['api_revenue'] > 0 ? round(($stats['api_profit'] / $stats['api_revenue']) * 100, 1) : 0;
    
    // Manuel Sipariş Geliri
    $stats['manual_revenue'] = $db->query("
        SELECT COALESCE(SUM(amount), 0) FROM orders 
        WHERE api_order_id IS NULL AND status = 'completed'
    ")->fetchColumn() ?: 0;
    
    // Şüpheli Aktiviteler - Aynı IP'den günde 5+ sipariş
    $suspiciousIps = $db->query("
        SELECT ip_address, COUNT(*) as order_count, 
               GROUP_CONCAT(DISTINCT customer_email) as emails,
               GROUP_CONCAT(DISTINCT customer_name) as names,
               MIN(created_at) as first_order,
               MAX(created_at) as last_order,
               SUM(amount) as total_amount
        FROM orders 
        WHERE DATE(created_at) = CURDATE() AND ip_address IS NOT NULL AND ip_address != ''
        GROUP BY ip_address 
        HAVING order_count >= 5
        ORDER BY order_count DESC
        LIMIT 10
    ")->fetchAll(PDO::FETCH_ASSOC);
    
    // Saatlik Sipariş Dağılımı (Son 7 gün)
    $hourlyOrders = $db->query("
        SELECT HOUR(created_at) as hour, COUNT(*) as count
        FROM orders 
        WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
        GROUP BY HOUR(created_at)
        ORDER BY hour
    ")->fetchAll(PDO::FETCH_KEY_PAIR);
    
    // Günlük Sipariş Dağılımı (Son 7 gün)
    $dailyOrders = $db->query("
        SELECT DAYNAME(created_at) as day_name, DAYOFWEEK(created_at) as day_num, COUNT(*) as count
        FROM orders 
        WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
        GROUP BY DAYNAME(created_at), DAYOFWEEK(created_at)
        ORDER BY day_num
    ")->fetchAll(PDO::FETCH_ASSOC);
    
    // Son 7 günlük gelir grafiği
    $weeklyRevenue = $db->query("
        SELECT DATE(created_at) as date, COALESCE(SUM(amount), 0) as revenue, COUNT(*) as orders
        FROM orders 
        WHERE created_at >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND status = 'completed'
        GROUP BY DATE(created_at)
        ORDER BY date
    ")->fetchAll(PDO::FETCH_ASSOC);
    
    // En Popüler Paketler
    $popularPackages = $db->query("
        SELECT p.name, p.price, COUNT(o.id) as sales, SUM(o.amount) as revenue,
               c.icon, c.color, c.name as category
        FROM orders o
        JOIN packages p ON o.package_id = p.id
        JOIN categories c ON p.category_id = c.id
        WHERE o.status = 'completed'
        GROUP BY o.package_id
        ORDER BY sales DESC
        LIMIT 5
    ")->fetchAll(PDO::FETCH_ASSOC);
    
    // Son Siparişler
    $recentOrders = $db->query("
        SELECT o.*, p.name as package_name, c.icon as category_icon, c.color as category_color
        FROM orders o
        JOIN packages p ON o.package_id = p.id
        JOIN categories c ON p.category_id = c.id
        ORDER BY o.created_at DESC LIMIT 8
    ")->fetchAll(PDO::FETCH_ASSOC);
    
    // Dönüşüm Oranı
    $stats['conversion_rate'] = $stats['total_orders'] > 0 
        ? round(($stats['completed_orders'] / $stats['total_orders']) * 100, 1) 
        : 0;
    
    // Ortalama Sipariş Değeri
    $stats['avg_order_value'] = $stats['completed_orders'] > 0 
        ? $stats['total_revenue'] / $stats['completed_orders'] 
        : 0;
    
} catch (PDOException $e) {
    $stats = array_fill_keys([
        'total_revenue', 'today_revenue', 'week_revenue', 'month_revenue',
        'total_orders', 'completed_orders', 'pending_orders', 'processing_orders', 
        'cancelled_orders', 'today_orders', 'total_users', 'total_kdv', 'total_discount',
        'api_orders', 'api_revenue', 'api_cost', 'api_profit', 'api_profit_margin',
        'manual_revenue', 'conversion_rate', 'avg_order_value'
    ], 0);
    $recentOrders = [];
    $suspiciousIps = [];
    $hourlyOrders = [];
    $dailyOrders = [];
    $weeklyRevenue = [];
    $popularPackages = [];
}

// Saatlik veriyi 0-23 için doldur
$hourlyData = [];
for ($i = 0; $i < 24; $i++) {
    $hourlyData[$i] = $hourlyOrders[$i] ?? 0;
}

// Günlük veriyi Türkçe gün isimleriyle doldur
$dayNames = ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'];
$dailyData = array_fill(0, 7, 0);
foreach ($dailyOrders as $day) {
    $idx = $day['day_num'] - 1;
    $dailyData[$idx] = $day['count'];
}

$statusConfig = [
    'pending' => ['label' => 'Bekliyor', 'color' => '#f59e0b', 'icon' => 'fa-clock'],
    'paid' => ['label' => 'Ödendi', 'color' => '#3b82f6', 'icon' => 'fa-credit-card'],
    'processing' => ['label' => 'İşleniyor', 'color' => '#8b5cf6', 'icon' => 'fa-spinner'],
    'completed' => ['label' => 'Tamamlandı', 'color' => '#10b981', 'icon' => 'fa-check-circle'],
    'cancelled' => ['label' => 'İptal', 'color' => '#ef4444', 'icon' => 'fa-times-circle'],
    'refunded' => ['label' => 'İade', 'color' => '#6b7280', 'icon' => 'fa-undo'],
];

$adminPageTitle = 'Dashboard';
require_once __DIR__ . '/header.php';
?>
<style>
/* Ana İstatistikler */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--primary));
}

.stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    margin-bottom: 15px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-footer strong { color: var(--text-primary); }

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
}

.stat-change.up { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.stat-change.down { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* İkincil İstatistikler */
.secondary-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.secondary-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.secondary-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.secondary-stat-info h4 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 2px;
}

.secondary-stat-info span {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

/* API Kar Kartı */
.profit-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 25px;
}

.profit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.profit-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profit-title i { color: var(--primary); }

.profit-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.profit-item {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.profit-item-value {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 5px;
}

.profit-item-value.green { color: #10b981; }
.profit-item-value.red { color: #ef4444; }
.profit-item-value.blue { color: #3b82f6; }
.profit-item-value.purple { color: #8b5cf6; }

.profit-item-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Şüpheli Aktiviteler */
.suspicious-card {
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 14px;
    overflow: hidden;
}

.suspicious-header {
    padding: 16px 20px;
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.suspicious-title {
    font-size: 14px;
    font-weight: 700;
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suspicious-badge {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

.suspicious-body {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.suspicious-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.suspicious-item:last-child { border-bottom: none; }

.suspicious-icon {
    width: 40px;
    height: 40px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 16px;
    flex-shrink: 0;
}

.suspicious-info { flex: 1; min-width: 0; }

.suspicious-info h6 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suspicious-info h6 .count {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.suspicious-info p {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suspicious-amount {
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
}

.suspicious-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
}

.suspicious-empty i {
    font-size: 30px;
    margin-bottom: 10px;
    opacity: 0.3;
    color: #10b981;
}

.suspicious-empty p { margin: 0; font-size: 13px; }

/* Grafik Kartları */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title i { color: var(--primary); font-size: 14px; }

.chart-container {
    height: 200px;
    position: relative;
}

/* Mini Grafikler */
.mini-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.mini-chart {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.mini-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.mini-chart-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-chart-title i { color: var(--primary); font-size: 12px; }

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 80px;
    gap: 4px;
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.bar {
    width: 100%;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s;
}

.bar-label {
    font-size: 9px;
    color: var(--text-secondary);
}

/* Orders Card */
.orders-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

.orders-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.orders-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.orders-title i { color: var(--primary); }

.orders-body { max-height: 400px; overflow-y: auto; }

.order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.order-item:hover { background: rgba(255,255,255,0.02); }
.order-item:last-child { border-bottom: none; }

.order-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.order-info { flex: 1; min-width: 0; }

.order-info h6 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-info span {
    font-size: 11px;
    color: var(--text-secondary);
}

.order-meta { text-align: right; flex-shrink: 0; }

.order-amount {
    font-size: 14px;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 3px;
}

.order-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 10px;
    font-weight: 600;
}

/* Popüler Paketler */
.popular-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

.popular-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.popular-title {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popular-title i { color: #f59e0b; }

.popular-body { padding: 0; }

.popular-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.popular-item:last-child { border-bottom: none; }

.popular-rank {
    width: 24px;
    height: 24px;
    background: var(--bg-hover);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

.popular-item:nth-child(1) .popular-rank { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.popular-item:nth-child(2) .popular-rank { background: linear-gradient(135deg, #9ca3af, #6b7280); color: #fff; }
.popular-item:nth-child(3) .popular-rank { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }

.popular-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.popular-info { flex: 1; min-width: 0; }

.popular-info h6 {
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popular-info span {
    font-size: 10px;
    color: var(--text-secondary);
}

.popular-stats { text-align: right; }

.popular-stats .sales {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}

.popular-stats .revenue {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Quick Actions */
.actions-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-top: 25px;
}

.actions-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.actions-title i { color: var(--primary); }

.actions-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 15px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
    transform: translateY(-3px);
}

.action-btn i { font-size: 20px; }

/* Responsive */
@media (max-width: 1400px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .profit-grid { grid-template-columns: repeat(2, 1fr); }
    .actions-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1199px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .secondary-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .mini-charts { grid-template-columns: 1fr; }
    .secondary-stats { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 22px; }
    .profit-grid { grid-template-columns: 1fr 1fr; }
    .actions-grid { grid-template-columns: 1fr 1fr; }
    .action-btn { padding: 15px 10px; font-size: 11px; }
    .action-btn i { font-size: 18px; }
}
</style>

<!-- Ana İstatistikler -->
<div class="stats-grid">
    <div class="stat-card" style="--stat-color: #10b981;">
        <div class="stat-icon" style="background: linear-gradient(135deg, #10b981, #059669);"><i class="fas fa-coins"></i></div>
        <div class="stat-value"><?php echo formatMoney($stats['total_revenue']); ?></div>
        <div class="stat-label">Toplam Gelir (Tamamlanan)</div>
        <div class="stat-footer">
            <span>Bugün: <strong><?php echo formatMoney($stats['today_revenue']); ?></strong></span>
            <span>Bu Hafta: <strong><?php echo formatMoney($stats['week_revenue']); ?></strong></span>
        </div>
    </div>

    <div class="stat-card" style="--stat-color: #3b82f6;">
        <div class="stat-icon" style="background: linear-gradient(135deg, #3b82f6, #1d4ed8);"><i class="fas fa-check-circle"></i></div>
        <div class="stat-value"><?php echo number_format($stats['completed_orders']); ?></div>
        <div class="stat-label">Tamamlanan Sipariş</div>
        <div class="stat-footer">
            <span>Toplam: <strong><?php echo number_format($stats['total_orders']); ?></strong></span>
            <span class="stat-change up"><i class="fas fa-chart-line"></i> %<?php echo $stats['conversion_rate']; ?></span>
        </div>
    </div>

    <div class="stat-card" style="--stat-color: #f59e0b;">
        <div class="stat-icon" style="background: linear-gradient(135deg, #f59e0b, #d97706);"><i class="fas fa-clock"></i></div>
        <div class="stat-value"><?php echo number_format($stats['pending_orders']); ?></div>
        <div class="stat-label">Bekleyen Sipariş</div>
        <div class="stat-footer">
            <span>İşleniyor: <strong><?php echo $stats['processing_orders']; ?></strong></span>
            <a href="<?php echo SITE_URL; ?>/admin/siparisler.php?status=pending" style="color: #f59e0b; font-weight: 600;">Görüntüle →</a>
        </div>
    </div>

    <div class="stat-card" style="--stat-color: #8b5cf6;">
        <div class="stat-icon" style="background: linear-gradient(135deg, #8b5cf6, #7c3aed);"><i class="fas fa-receipt"></i></div>
        <div class="stat-value"><?php echo formatMoney($stats['avg_order_value']); ?></div>
        <div class="stat-label">Ortalama Sipariş</div>
        <div class="stat-footer">
            <span>Bu Ay: <strong><?php echo formatMoney($stats['month_revenue']); ?></strong></span>
        </div>
    </div>
</div>

<!-- İkincil İstatistikler -->
<div class="secondary-stats">
    <div class="secondary-stat">
        <div class="secondary-stat-icon" style="background: rgba(16, 185, 129, 0.15); color: #10b981;">
            <i class="fas fa-percent"></i>
        </div>
        <div class="secondary-stat-info">
            <h4><?php echo formatMoney($stats['total_kdv']); ?></h4>
            <span>Toplam KDV</span>
        </div>
    </div>
    
    <div class="secondary-stat">
        <div class="secondary-stat-icon" style="background: rgba(239, 68, 68, 0.15); color: #ef4444;">
            <i class="fas fa-tag"></i>
        </div>
        <div class="secondary-stat-info">
            <h4><?php echo formatMoney($stats['total_discount']); ?></h4>
            <span>Toplam İndirim</span>
        </div>
    </div>
    
    <div class="secondary-stat">
        <div class="secondary-stat-icon" style="background: rgba(239, 68, 68, 0.15); color: #ef4444;">
            <i class="fas fa-times-circle"></i>
        </div>
        <div class="secondary-stat-info">
            <h4><?php echo number_format($stats['cancelled_orders']); ?></h4>
            <span>İptal/İade</span>
        </div>
    </div>
    
    <div class="secondary-stat">
        <div class="secondary-stat-icon" style="background: rgba(59, 130, 246, 0.15); color: #3b82f6;">
            <i class="fas fa-calendar-day"></i>
        </div>
        <div class="secondary-stat-info">
            <h4><?php echo number_format($stats['today_orders']); ?></h4>
            <span>Bugünkü Sipariş</span>
        </div>
    </div>
</div>

<!-- API Kar/Maliyet Kartı -->
<div class="profit-card">
    <div class="profit-header">
        <h3 class="profit-title"><i class="fas fa-robot"></i> API Sipariş Kar Analizi</h3>
        <span style="font-size: 12px; color: var(--text-secondary);">Sadece tamamlanan API siparişleri</span>
    </div>
    <div class="profit-grid">
        <div class="profit-item">
            <div class="profit-item-value blue"><?php echo number_format($stats['api_orders']); ?></div>
            <div class="profit-item-label">API Sipariş</div>
        </div>
        <div class="profit-item">
            <div class="profit-item-value purple"><?php echo formatMoney($stats['api_revenue']); ?></div>
            <div class="profit-item-label">API Gelir</div>
        </div>
        <div class="profit-item">
            <div class="profit-item-value red"><?php echo formatMoney($stats['api_cost']); ?></div>
            <div class="profit-item-label">API Maliyet</div>
        </div>
        <div class="profit-item">
            <div class="profit-item-value green"><?php echo formatMoney($stats['api_profit']); ?></div>
            <div class="profit-item-label">Net Kar (%<?php echo $stats['api_profit_margin']; ?>)</div>
        </div>
    </div>
    <div style="margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary);">
        <span><i class="fas fa-hand-paper" style="color: #10b981;"></i> Manuel Gelir: <strong style="color: #10b981;"><?php echo formatMoney($stats['manual_revenue']); ?></strong></span>
        <span><i class="fas fa-calculator" style="color: var(--primary);"></i> Toplam Net Gelir: <strong style="color: var(--primary);"><?php echo formatMoney($stats['api_profit'] + $stats['manual_revenue']); ?></strong></span>
    </div>
</div>

<!-- Grafikler -->
<div class="mini-charts">
    <!-- Saatlik Yoğunluk -->
    <div class="mini-chart">
        <div class="mini-chart-header">
            <span class="mini-chart-title"><i class="fas fa-clock"></i> Saatlik Sipariş Yoğunluğu</span>
            <span style="font-size: 10px; color: var(--text-secondary);">Son 7 gün</span>
        </div>
        <div class="bar-chart">
            <?php 
            $maxHourly = max($hourlyData) ?: 1;
            foreach ($hourlyData as $hour => $count): 
                $height = ($count / $maxHourly) * 60;
            ?>
            <div class="bar-item">
                <div class="bar" style="height: <?php echo max(4, $height); ?>px; opacity: <?php echo $count > 0 ? 1 : 0.3; ?>;"></div>
                <span class="bar-label"><?php echo $hour; ?></span>
            </div>
            <?php endforeach; ?>
        </div>
        <div style="margin-top: 10px; font-size: 11px; color: var(--text-secondary); text-align: center;">
            <?php 
            $peakHour = array_search(max($hourlyData), $hourlyData);
            echo "En yoğun saat: <strong style='color: var(--primary);'>" . sprintf('%02d:00', $peakHour) . "</strong>";
            ?>
        </div>
    </div>
    
    <!-- Günlük Yoğunluk -->
    <div class="mini-chart">
        <div class="mini-chart-header">
            <span class="mini-chart-title"><i class="fas fa-calendar-week"></i> Günlük Sipariş Yoğunluğu</span>
            <span style="font-size: 10px; color: var(--text-secondary);">Son 7 gün</span>
        </div>
        <div class="bar-chart">
            <?php 
            $maxDaily = max($dailyData) ?: 1;
            foreach ($dailyData as $idx => $count): 
                $height = ($count / $maxDaily) * 60;
                $dayShort = mb_substr($dayNames[$idx], 0, 3);
            ?>
            <div class="bar-item">
                <div class="bar" style="height: <?php echo max(4, $height); ?>px; opacity: <?php echo $count > 0 ? 1 : 0.3; ?>; background: <?php echo $idx == 0 || $idx == 6 ? '#ef4444' : 'var(--primary)'; ?>;"></div>
                <span class="bar-label"><?php echo $dayShort; ?></span>
            </div>
            <?php endforeach; ?>
        </div>
        <div style="margin-top: 10px; font-size: 11px; color: var(--text-secondary); text-align: center;">
            <?php 
            $peakDay = array_search(max($dailyData), $dailyData);
            echo "En yoğun gün: <strong style='color: var(--primary);'>" . $dayNames[$peakDay] . "</strong>";
            ?>
        </div>
    </div>
</div>

<!-- Dashboard Grid -->
<div class="dashboard-grid">
    <!-- Sol: Son Siparişler -->
    <div class="orders-card">
        <div class="orders-header">
            <h3 class="orders-title"><i class="fas fa-history"></i> Son Siparişler</h3>
            <a href="<?php echo SITE_URL; ?>/admin/siparisler.php" class="btn-secondary-custom" style="padding: 8px 14px; font-size: 12px;">
                Tümü <i class="fas fa-arrow-right ms-1"></i>
            </a>
        </div>
        <div class="orders-body">
            <?php if (empty($recentOrders)): ?>
                <div class="text-center py-5" style="color: var(--text-secondary);">
                    <i class="fas fa-inbox fa-2x mb-3" style="opacity: 0.3;"></i>
                    <p class="mb-0">Henüz sipariş yok</p>
                </div>
            <?php else: ?>
                <?php foreach ($recentOrders as $order): 
                    $status = $statusConfig[$order['status']] ?? $statusConfig['pending'];
                ?>
                <div class="order-item">
                    <div class="order-icon" style="background: <?php echo $order['category_color']; ?>;">
                        <i class="<?php echo $order['category_icon']; ?>"></i>
                    </div>
                    <div class="order-info">
                        <h6><?php echo clean($order['package_name']); ?></h6>
                        <span><?php echo clean($order['customer_name']); ?> • <?php echo $order['order_number']; ?></span>
                    </div>
                    <div class="order-meta">
                        <div class="order-amount"><?php echo formatMoney($order['amount']); ?></div>
                        <div class="order-status" style="background: <?php echo $status['color']; ?>20; color: <?php echo $status['color']; ?>;">
                            <?php echo $status['label']; ?>
                        </div>
                    </div>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
    
    <!-- Sağ: Şüpheli Aktiviteler + Popüler Paketler -->
    <div>
        <!-- Şüpheli Aktiviteler -->
        <div class="suspicious-card" style="margin-bottom: 20px;">
            <div class="suspicious-header">
                <span class="suspicious-title">
                    <i class="fas fa-exclamation-triangle"></i> Şüpheli Aktiviteler
                </span>
                <?php if (!empty($suspiciousIps)): ?>
                <span class="suspicious-badge"><?php echo count($suspiciousIps); ?> IP</span>
                <?php endif; ?>
            </div>
            <div class="suspicious-body">
                <?php if (empty($suspiciousIps)): ?>
                <div class="suspicious-empty">
                    <i class="fas fa-shield-alt"></i>
                    <p>Bugün şüpheli aktivite yok</p>
                    <small style="color: var(--text-secondary); font-size: 10px;">Aynı IP'den günde 5+ sipariş izlenir</small>
                </div>
                <?php else: ?>
                    <?php foreach ($suspiciousIps as $ip): ?>
                    <div class="suspicious-item">
                        <div class="suspicious-icon">
                            <i class="fas fa-user-secret"></i>
                        </div>
                        <div class="suspicious-info">
                            <h6>
                                <?php echo clean($ip['ip_address']); ?>
                                <span class="count"><?php echo $ip['order_count']; ?> sipariş</span>
                            </h6>
                            <p title="<?php echo clean($ip['emails']); ?>"><?php echo clean($ip['emails']); ?></p>
                        </div>
                        <div class="suspicious-amount"><?php echo formatMoney($ip['total_amount']); ?></div>
                    </div>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>
        </div>
        
        <!-- Popüler Paketler -->
        <div class="popular-card">
            <div class="popular-header">
                <span class="popular-title"><i class="fas fa-fire"></i> En Çok Satan Paketler</span>
            </div>
            <div class="popular-body">
                <?php if (empty($popularPackages)): ?>
                <div style="padding: 30px; text-align: center; color: var(--text-secondary);">
                    <p style="margin: 0; font-size: 13px;">Henüz satış yok</p>
                </div>
                <?php else: ?>
                    <?php foreach ($popularPackages as $idx => $pkg): ?>
                    <div class="popular-item">
                        <div class="popular-rank"><?php echo $idx + 1; ?></div>
                        <div class="popular-icon" style="background: <?php echo $pkg['color']; ?>;">
                            <i class="<?php echo $pkg['icon']; ?>"></i>
                        </div>
                        <div class="popular-info">
                            <h6 title="<?php echo clean($pkg['name']); ?>"><?php echo clean($pkg['name']); ?></h6>
                            <span><?php echo clean($pkg['category']); ?> • <?php echo formatMoney($pkg['price']); ?></span>
                        </div>
                        <div class="popular-stats">
                            <div class="sales"><?php echo $pkg['sales']; ?> satış</div>
                            <div class="revenue"><?php echo formatMoney($pkg['revenue']); ?></div>
                        </div>
                    </div>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

<!-- Quick Actions -->
<div class="actions-card">
    <h3 class="actions-title"><i class="fas fa-bolt"></i> Hızlı İşlemler</h3>
    <div class="actions-grid">
        <a href="<?php echo SITE_URL; ?>/admin/paket-ekle.php" class="action-btn">
            <i class="fas fa-plus-circle"></i>
            <span>Yeni Paket</span>
        </a>
        <a href="<?php echo SITE_URL; ?>/admin/siparisler.php?status=pending" class="action-btn">
            <i class="fas fa-clock"></i>
            <span>Bekleyenler</span>
        </a>
        <a href="<?php echo SITE_URL; ?>/admin/kuponlar.php" class="action-btn">
            <i class="fas fa-ticket-alt"></i>
            <span>Kuponlar</span>
        </a>
        <a href="<?php echo SITE_URL; ?>/admin/api-saglayicilar.php" class="action-btn">
            <i class="fas fa-plug"></i>
            <span>API Yönetimi</span>
        </a>
        <a href="<?php echo SITE_URL; ?>/admin/popuplar.php" class="action-btn">
            <i class="fas fa-window-restore"></i>
            <span>Popuplar</span>
        </a>
        <a href="<?php echo SITE_URL; ?>/admin/ayarlar.php" class="action-btn">
            <i class="fas fa-cog"></i>
            <span>Ayarlar</span>
        </a>
    </div>
</div>

<?php require_once __DIR__ . '/footer.php'; ?>