<?php 
date_default_timezone_set('Asia/Kolkata');
$current_time = date('M d, Y, g:i:s A', time());
include('includes/config.php');

// Already logged in? Go to dashboard directly
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true){
    header("Location: crs/index.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Civil Registration System | Government of India</title>
    
    <!-- PWA Manifest -->
    <link rel="manifest" href="/manifest.json">
    <meta name="theme-color" content="#1e3c72">
    <link rel="apple-touch-icon" href="https://dc.crsorgi.gov.in/assets/logo/crs-logo.png">
    
    <!-- Favicon -->
    <link rel="icon" type="image/png" href="https://dc.crsorgi.gov.in/favicon.png">
    
    <!-- Bootstrap & Icons -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0">
    
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        
        body {
            font-family: 'Segoe UI', Tahoma, sans-serif;
            background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        /* Header */
        .header {
            background: white;
            padding: 10px 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }
        .logo-section {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .logo-section img {
            height: 50px;
        }
        .emblem {
            height: 45px;
        }
        
        /* Main Content */
        .main-content {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
        }
        
        .login-container {
            width: 100%;
            max-width: 450px;
        }
        
        .login-card {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            overflow: hidden;
        }
        
        .card-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 30px;
            text-align: center;
            color: white;
        }
        .card-header img {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: white;
            padding: 10px;
            margin-bottom: 15px;
        }
        .card-header h1 {
            font-size: 24px;
            margin-bottom: 5px;
        }
        .card-header p {
            opacity: 0.9;
            font-size: 14px;
        }
        
        .card-body {
            padding: 30px;
        }
        
        /* Buttons */
        .btn-action {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            padding: 15px 25px;
            border-radius: 50px;
            font-size: 16px;
            font-weight: 600;
            text-decoration: none;
            transition: all 0.3s ease;
            margin-bottom: 15px;
            border: none;
            cursor: pointer;
        }
        
        .btn-login {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }
        .btn-login:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
            color: white;
        }
        
        .btn-register {
            background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
            color: white;
            box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
        }
        .btn-register:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(17, 153, 142, 0.5);
            color: white;
        }
        
        .btn-forgot {
            background: transparent;
            color: #666;
            border: 2px solid #ddd;
        }
        .btn-forgot:hover {
            background: #f8f9fa;
            border-color: #667eea;
            color: #667eea;
        }
        
        /* Divider */
        .divider {
            display: flex;
            align-items: center;
            margin: 20px 0;
            color: #999;
            font-size: 14px;
        }
        .divider::before, .divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background: #ddd;
        }
        .divider span {
            padding: 0 15px;
        }
        
        /* Footer Info */
        .footer-info {
            text-align: center;
            padding: 20px;
            border-top: 1px solid #eee;
            color: #666;
            font-size: 13px;
        }
        .footer-info a {
            color: #667eea;
            text-decoration: none;
        }
        
        /* Site Footer */
        .site-footer {
            background: rgba(0,0,0,0.3);
            color: white;
            text-align: center;
            padding: 15px;
            font-size: 13px;
        }
        .site-footer a {
            color: #ffd700;
            text-decoration: none;
        }
        
        /* Responsive */
        @media (max-width: 576px) {
            .logo-section img { height: 40px; }
            .emblem { height: 35px; }
            .card-header { padding: 20px; }
            .card-header h1 { font-size: 20px; }
            .card-body { padding: 20px; }
            .btn-action { padding: 12px 20px; font-size: 14px; }
        }
    </style>
</head>
<body>
    <!-- Header -->
    <header class="header">
        <div class="header-content">
            <div class="logo-section">
                <img src="https://dc.crsorgi.gov.in/assets/logo/crs-logo-light.png" alt="CRS Logo">
                <img src="https://dc.crsorgi.gov.in/assets/images/azadi_logo_light-min.png" alt="Azadi" class="emblem">
            </div>
            <div class="logo-section">
                <img src="https://dc.crsorgi.gov.in/assets/images/emblem.png" alt="National Emblem" class="emblem">
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="main-content">
        <div class="login-container">
            <div class="login-card">
                <div class="card-header">
                    <img src="https://dc.crsorgi.gov.in/assets/logo/crs-logo.png" alt="Logo">
                    <h1>Civil Registration System</h1>
                    <p>Digital Certificate Validation Portal</p>
                </div>
                
                <div class="card-body">
                    <!-- Login Button -->
                    <a href="general-public.php" class="btn-action btn-login">
                        <i class="fas fa-sign-in-alt"></i>
                        Login
                    </a>
                    
                    <!-- Register Button -->
                    <a href="register.php" class="btn-action btn-register">
                        <i class="fas fa-user-plus"></i>
                        Register
                    </a>
                    
                    <div class="divider">
                        <span>या</span>
                    </div>
                    
                    <!-- Forgot Password Button -->
                    <a href="forgot-password.php" class="btn-action btn-forgot">
                        <i class="fas fa-key"></i>
                        Forgot Password?
                    </a>
                </div>
                
                <div class="footer-info">
                    <p>Certificate verification portal by</p>
                    <p><strong>Office of the Registrar General & Census Commissioner, India</strong></p>
                    <p style="margin-top: 10px;">
                        <a href="access-help.php">Site Access Help</a> | 
                        <a href="#">Terms & Conditions</a>
                    </p>
                </div>
            </div>
        </div>
    </main>

    <!-- Footer -->
    <footer class="site-footer">
        <p>© <?php echo date('Y'); ?> - Civil Registration System | 
           <a href="access-help.php">Help</a> | 
           Time: <?php echo $current_time; ?>
        </p>
    </footer>

    <!-- Scripts -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="assets/JS/anti-block.js"></script>
</body>
</html>
