<?php 
require_once 'core/db.php'; 
// Eğer kullanıcı zaten giriş yapmışsa direkt panele yönlendir
if(isset($_SESSION['user_id'])) {
    header("Location: index.php");
    exit;
}
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Diyaliz Merkezi | Giriş Sistemi</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --primary-color: #2563eb;
            --bg-gradient: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
        }

        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg-gradient);
            height: 100vh;
            margin: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-card {
            background: #ffffff;
            padding: 2.5rem;
            border-radius: 1rem;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            width: 100%;
            max-width: 400px;
        }

        .brand {
            text-align: center;
            margin-bottom: 2rem;
        }

        .brand i {
            color: var(--primary-color);
            font-size: 3rem;
            margin-bottom: 1rem;
        }

        .brand h2 {
            margin: 0;
            color: #1e293b;
            font-weight: 600;
        }

        .input-group {
            margin-bottom: 1.5rem;
        }

        .input-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: #475569;
            font-size: 0.875rem;
            font-weight: 600;
        }

        .input-wrapper {
            position: relative;
        }

        .input-wrapper i {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: #94a3b8;
        }

        .input-wrapper input {
            width: 100%;
            padding: 0.75rem 1rem 0.75rem 2.75rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            outline: none;
            transition: all 0.2s;
            box-sizing: border-box;
        }

        .input-wrapper input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        .btn-submit {
            width: 100%;
            background: var(--primary-color);
            color: white;
            padding: 0.75rem;
            border: none;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        .btn-submit:hover {
            background: #1d4ed8;
        }

        .alert {
            padding: 0.75rem;
            border-radius: 0.5rem;
            margin-bottom: 1.5rem;
            font-size: 0.875rem;
            text-align: center;
        }

        .alert-error {
            background: #fee2e2;
            color: #b91c1c;
            border: 1px solid #fecaca;
        }

        .alert-info {
            background: #e0f2fe;
            color: #0369a1;
            border: 1px solid #bae6fd;
        }
    </style>
</head>
<body>

<div class="login-card">
    <div class="brand">
        <i class="fas fa-kidney"></i>
        <h2>Diyaliz ERP</h2>
        <p style="color: #64748b; font-size: 0.875rem;">Lütfen kimlik bilgilerinizle giriş yapın</p>
    </div>

    <?php if(isset($_GET['hata'])): ?>
        <div class="alert alert-error">
            <i class="fas fa-exclamation-circle"></i> Kullanıcı adı veya şifre hatalı!
        </div>
    <?php endif; ?>

    <?php if(isset($_GET['durum']) && $_GET['durum'] == 'cikis'): ?>
        <div class="alert alert-info">
            <i class="fas fa-info-circle"></i> Güvenli çıkış yapıldı.
        </div>
    <?php endif; ?>

    <form action="islem.php" method="POST">
        <div class="input-group">
            <label for="kullanici_adi">Kullanıcı Adı</label>
            <div class="input-wrapper">
                <i class="fas fa-user"></i>
                <input type="text" id="kullanici_adi" name="kullanici_adi" placeholder="admin" required>
            </div>
        </div>

        <div class="input-group">
            <label for="sifre">Şifre</label>
            <div class="input-wrapper">
                <i class="fas fa-lock"></i>
                <input type="password" id="sifre" name="sifre" placeholder="••••••••" required>
            </div>
        </div>

        <button type="submit" name="giris_yap" class="btn-submit">
            Sisteme Giriş Yap
        </button>
    </form>
</div>

</body>
</html>