<?php
if (!defined('PDO::ATTR_ERRMODE')) { die("Erişim yasak."); }

// Veritabanından Gerçek Verileri Çekelim
$toplam_hasta = $pdo->query("SELECT COUNT(*) FROM hastalar WHERE durum='aktif'")->fetchColumn();
$bugunku_seanslar = $pdo->query("SELECT COUNT(*) FROM seans_programi WHERE gun = DAYNAME(NOW())")->fetchColumn(); // SQL İngilizce gün ismi döndürürse dikkat
$kritik_stok = $pdo->query("SELECT COUNT(*) FROM stok WHERE stok_miktari <= kritik_seviye")->fetchColumn();
$aktif_cihazlar = $pdo->query("SELECT COUNT(*) FROM cihazlar WHERE durum='aktif'")->fetchColumn();
?>

<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 25px; margin-bottom: 30px;">
    
    <div class="card" style="border-left: 5px solid #3b82f6;">
        <div style="display: flex; justify-content: space-between;">
            <div>
                <div style="color: #64748b; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;">Aktif Kayıtlı Hasta</div>
                <div style="font-size: 2rem; font-weight: 700; margin-top: 10px;"><?php echo $toplam_hasta; ?></div>
            </div>
            <i class="fas fa-users" style="font-size: 2.5rem; color: #dbeafe;"></i>
        </div>
    </div>

    <div class="card" style="border-left: 5px solid #10b981;">
        <div style="display: flex; justify-content: space-between;">
            <div>
                <div style="color: #64748b; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;">Bugünkü Seans Planı</div>
                <div style="font-size: 2rem; font-weight: 700; margin-top: 10px;"><?php echo $bugunku_seanslar; ?></div>
            </div>
            <i class="fas fa-calendar-day" style="font-size: 2.5rem; color: #d1fae5;"></i>
        </div>
    </div>

    <div class="card" style="border-left: 5px solid #ef4444;">
        <div style="display: flex; justify-content: space-between;">
            <div>
                <div style="color: #64748b; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;">Kritik Stok Uyarısı</div>
                <div style="font-size: 2rem; font-weight: 700; margin-top: 10px;"><?php echo $kritik_stok; ?></div>
            </div>
            <i class="fas fa-exclamation-triangle" style="font-size: 2.5rem; color: #fee2e2;"></i>
        </div>
    </div>

    <div class="card" style="border-left: 5px solid #f59e0b;">
        <div style="display: flex; justify-content: space-between;">
            <div>
                <div style="color: #64748b; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;">Çalışan Cihaz Sayısı</div>
                <div style="font-size: 2rem; font-weight: 700; margin-top: 10px;"><?php echo $aktif_cihazlar; ?></div>
            </div>
            <i class="fas fa-microscope" style="font-size: 2.5rem; color: #fef3c7;"></i>
        </div>
    </div>
</div>

<div class="card">
    <h3 style="margin-top:0;">Hızlı Erişim & Durum</h3>
    <p>Sisteme başarıyla giriş yaptınız. Lütfen sol menüden yapmak istediğiniz işlemi seçin.</p>
    <div style="display: flex; gap: 10px;">
        <a href="?sayfa=hasta-ekle" style="background: #3b82f6; color:white; padding: 10px 20px; border-radius: 8px; text-decoration:none; font-size: 14px; font-weight:600;">+ Yeni Hasta Kaydı</a>
        <a href="?sayfa=seans-takvimi" style="background: #f1f5f9; color:#1e293b; padding: 10px 20px; border-radius: 8px; text-decoration:none; font-size: 14px; font-weight:600;">Seans Takvimini Gör</a>
    </div>
</div>