<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/../../error.log');
error_reporting(E_ALL);

session_start();

// ✅ This gives you $pdo
include __DIR__ . '/config/db_new.php';

// ✅ Auth guard
include __DIR__ . '/config/auth.php';
require_page_access();

$success_message = '';
$error_message = '';

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_details'])) {
    try {
        // Check if record exists
        $stmt = $pdo->query("SELECT id FROM website_details LIMIT 1");
        $existing = $stmt->fetch(PDO::FETCH_ASSOC);
        
        if ($existing) {
            
            $sql = "UPDATE website_details SET 
                call_for_papers_ijrsi = ?,
                call_for_papers_ijriss = ?,
                call_for_papers_ijrias = ?,
                submission_deadline_ijrsi = ?,
                submission_deadline_ijriss = ?,
                submission_deadline_ijrias = ?,
                volumes_issue_ijrsi = ?,
                volumes_issue_ijriss = ?,
                volumes_issue_ijrias = ?,
                doi_ijrsi = ?,
                doi_ijriss = ?,
                doi_ijrias = ?,
            
                submission_deadline_education_issue = ?,
                submission_deadline_public_health_issue = ?,
                submission_deadline_economics_issue = ?,
                submission_deadline_management_issue = ?,
                submission_deadline_psyscology_issue = ?,
                submission_deadline_communication_issue = ?,
                submission_deadline_sociology_issue = ?,
                submission_deadline_microbiology_issue = ?,
                submission_deadline_cse_issue = ?,
                submission_deadline_modern_chemistry_issue = ?,
                submission_deadline_physics_research_issue = ?,
                submission_deadline_environmental_science_issue = ?,
                submission_deadline_agriculture_issue = ?,
            
                updated_at = NOW()
                WHERE id = ?";
            
            $stmt = $pdo->prepare($sql);
            // $stmt->execute([
            //     $_POST['call_for_papers_ijrsi'],
            //     $_POST['call_for_papers_ijriss'],
            //     $_POST['call_for_papers_ijrias'],
            //     $_POST['submission_deadline_ijrsi'],
            //     $_POST['submission_deadline_ijriss'],
            //     $_POST['submission_deadline_ijrias'],
            //     $_POST['volumes_issue_ijrsi'],
            //     $_POST['volumes_issue_ijriss'],
            //     $_POST['volumes_issue_ijrias'],
            //     $_POST['doi_ijrsi'],
            //     $_POST['doi_ijriss'],
            //     $_POST['doi_ijrias'],
            //     $existing['id']
            
            $stmt->execute([
                $_POST['call_for_papers_ijrsi'],
                $_POST['call_for_papers_ijriss'],
                $_POST['call_for_papers_ijrias'],
                $_POST['submission_deadline_ijrsi'],
                $_POST['submission_deadline_ijriss'],
                $_POST['submission_deadline_ijrias'],
                $_POST['volumes_issue_ijrsi'],
                $_POST['volumes_issue_ijriss'],
                $_POST['volumes_issue_ijrias'],
                $_POST['doi_ijrsi'],
                $_POST['doi_ijriss'],
                $_POST['doi_ijrias'],
            
                $_POST['submission_deadline_education_issue'],
                $_POST['submission_deadline_public_health_issue'],
                $_POST['submission_deadline_economics_issue'],
                $_POST['submission_deadline_management_issue'],
                $_POST['submission_deadline_psyscology_issue'],
                $_POST['submission_deadline_communication_issue'],
                $_POST['submission_deadline_sociology_issue'],
                $_POST['submission_deadline_microbiology_issue'],
                $_POST['submission_deadline_cse_issue'],
                $_POST['submission_deadline_modern_chemistry_issue'],
                $_POST['submission_deadline_physics_research_issue'],
                $_POST['submission_deadline_environmental_science_issue'],
                $_POST['submission_deadline_agriculture_issue'],
            
                $existing['id']
            ]);
            
            
            
           
        } else {
            // Insert new record
           $sql = "INSERT INTO website_details (
                call_for_papers_ijrsi,
                call_for_papers_ijriss,
                call_for_papers_ijrias,
                submission_deadline_ijrsi,
                submission_deadline_ijriss,
                submission_deadline_ijrias,
                volumes_issue_ijrsi,
                volumes_issue_ijriss,
                volumes_issue_ijrias,
                doi_ijrsi,
                doi_ijriss,
                doi_ijrias,
            
                submission_deadline_education_issue,
                submission_deadline_public_health_issue,
                submission_deadline_economics_issue,
                submission_deadline_management_issue,
                submission_deadline_psyscology_issue,
                submission_deadline_communication_issue,
                submission_deadline_sociology_issue,
                submission_deadline_microbiology_issue,
                submission_deadline_cse_issue,
                submission_deadline_modern_chemistry_issue,
                submission_deadline_physics_research_issue,
                submission_deadline_environmental_science_issue,
                submission_deadline_agriculture_issue
            ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            
            $stmt = $pdo->prepare($sql);
            $stmt->execute([
                $_POST['call_for_papers_ijrsi'],
                $_POST['call_for_papers_ijriss'],
                $_POST['call_for_papers_ijrias'],
                $_POST['submission_deadline_ijrsi'],
                $_POST['submission_deadline_ijriss'],
                $_POST['submission_deadline_ijrias'],
                $_POST['volumes_issue_ijrsi'],
                $_POST['volumes_issue_ijriss'],
                $_POST['volumes_issue_ijrias'],
                $_POST['doi_ijrsi'],
                $_POST['doi_ijriss'],
                $_POST['doi_ijrias']
            ]);
        }
        
        $success_message = 'Website details updated successfully!';
    } catch (PDOException $e) {
        error_log("Database error: " . $e->getMessage());
        $error_message = 'Error updating website details: ' . $e->getMessage();
    }
}

// Fetch current website details
try {
    $stmt = $pdo->query("SELECT * FROM website_details ORDER BY id DESC LIMIT 1");
    $websiteDetails = $stmt->fetch(PDO::FETCH_ASSOC);
    
    // If no record exists, create default values
    if (!$websiteDetails) {
        $websiteDetails = [
            'call_for_papers_ijrsi' => '',
            'call_for_papers_ijriss' => '',
            'call_for_papers_ijrias' => '',
            'submission_deadline_ijrsi' => '',
            'submission_deadline_ijriss' => '',
            'submission_deadline_ijrias' => '',
            'volumes_issue_ijrsi' => '',
            'volumes_issue_ijriss' => '',
            'volumes_issue_ijrias' => '',
            'doi_ijrsi' => '',
            'doi_ijriss' => '',
            'doi_ijrias' => '',
            'submission_deadline_education_issue' => '',
            'submission_deadline_public_health_issue' => '',
            'submission_deadline_economics_issue' => '',
            'submission_deadline_management_issue' => '',
            'submission_deadline_psyscology_issue' => '',
            'submission_deadline_communication_issue' => '',
            'submission_deadline_sociology_issue' => '',
            'submission_deadline_microbiology_issue' => '',
            'submission_deadline_cse_issue' => '',
            'submission_deadline_modern_chemistry_issue' => '',
            'submission_deadline_physics_research_issue' => '',
            'submission_deadline_environmental_science_issue' => '',
            'submission_deadline_agriculture_issue' => '',
        ];
    }
} catch (PDOException $e) {
    error_log("Database error: " . $e->getMessage());
    $websiteDetails = [];
}

$active_section = 'website_details';
$user_name = $_SESSION['username'] ?? 'Admin';
$user_role = $_SESSION['role'] ?? 'admin';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Website Details - RSIS CRM</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            margin: 0;
            height: 100vh;
            overflow: hidden;
            transition: background-color 0.3s;
        }
        body.dark {
            background-color: #1a202c;
            color: #e2e8f0;
        }
        .sidebar {
            width: 250px;
            background: #2d3748;
            color: white;
            transition: all 0.3s ease-in-out;
            height: 100%;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 10;
            overflow-y: auto;
        }
        .sidebar.hidden {
            transform: translateX(-250px);
        }
        .sidebar.collapsed {
            width: 70px;
        }
        .sidebar.collapsed .sidebar-title {
            display: none;
        }
        .sidebar.collapsed nav ul li a span {
            display: none;
        }
        .content {
            margin-left: 250px;
            padding: 20px;
            transition: margin-left 0.3s ease-in-out;
            height: 100vh;
            overflow-y: auto;
        }
        .content.shifted {
            margin-left: 0;
        }
        .content.collapsed-sidebar {
            margin-left: 70px;
        }
        .nav-item {
            padding: 10px 15px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .nav-item:hover {
            background: #4a5568;
        }
        .nav-item.active {
            background: #4a5568;
            border-left: 4px solid #4299e1;
        }
        .bg-white {
            background-color: white;
        }
        body.dark .bg-white {
            background-color: #2d3748;
        }
        body.dark .text-gray-700 {
            color: #d1d5db;
        }
        body.dark .bg-gray-50 {
            background-color: #3f3f3f;
        }
        body.dark input, body.dark select, body.dark textarea {
            background-color: #374151;
            color: #e5e7eb;
            border-color: #4b5563;
        }
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-250px);
            }
            .sidebar.mobile-open {
                transform: translateX(0);
            }
            .content {
                margin-left: 0;
            }
        }
        .journal-section {
            border-left: 4px solid;
            padding-left: 1rem;
            margin-bottom: 2rem;
        }
        .journal-section.ijrsi {
            border-color: #3b82f6;
        }
        .journal-section.ijriss {
            border-color: #10b981;
        }
        .journal-section.ijrias {
            border-color: #f59e0b;
        }
    </style>
</head>
<body class="bg-gray-100 mt-5">
    <!-- Mobile Toggle Button -->
    <button id="sidebarToggleBtn" onclick="toggleMobileSidebar()" 
        class="fixed top-3 left-3 z-20 bg-gray-800 text-white px-3 py-2 rounded-md md:hidden">
        ☰
    </button>
    
    <?php include __DIR__ . '/include/sidebar.php'; ?>

    <!-- Main Content -->
    <div class="content" id="content">
        <!-- Header -->

        <main class="p-6 overflow-y-auto">
            <div class="flex justify-between items-center mb-6">
                <h1 class="text-3xl font-semibold text-gray-700">
                    <i class="fas fa-globe mr-2"></i>Website Details Management
                </h1>
            </div>

            <!-- Success/Error Messages -->
            <?php if ($success_message): ?>
                <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-6 rounded" role="alert">
                    <div class="flex items-center">
                        <i class="fas fa-check-circle mr-2"></i>
                        <p><?php echo htmlspecialchars($success_message); ?></p>
                    </div>
                </div>
            <?php endif; ?>

            <?php if ($error_message): ?>
                <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded" role="alert">
                    <div class="flex items-center">
                        <i class="fas fa-exclamation-circle mr-2"></i>
                        <p><?php echo htmlspecialchars($error_message); ?></p>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Website Details Form -->
            <form method="POST" class="space-y-6">
                <!-- IJRSI Section -->
                <div class="bg-white p-6 rounded-lg shadow journal-section ijrsi">
                    <h2 class="text-2xl font-bold mb-4 text-blue-600 flex items-center">
                        <i class="fas fa-book mr-2"></i>IJRSI (International Journal of Research in Science and Innovation)
                    </h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-bullhorn mr-1"></i>Call for Papers
                            </label>
                            <input type="text" 
                                   name="call_for_papers_ijrsi" 
                                   value="<?php echo htmlspecialchars($websiteDetails['call_for_papers_ijrsi'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-blue-500 focus:border-blue-500"
                                   placeholder="e.g., Open for Submissions">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-calendar-alt mr-1"></i>Submission Deadline
                            </label>
                            <input type="text" 
                                   name="submission_deadline_ijrsi" 
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_ijrsi'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-blue-500 focus:border-blue-500"
                                   placeholder="e.g., Rolling Submissions / 31 Dec 2025">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-book-open mr-1"></i>Volumes/Issue
                            </label>
                            <input type="text" 
                                   name="volumes_issue_ijrsi" 
                                   value="<?php echo htmlspecialchars($websiteDetails['volumes_issue_ijrsi'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-blue-500 focus:border-blue-500"
                                   placeholder="e.g., Volume 12, Issue 1">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-barcode mr-1"></i>DOI
                            </label>
                            <input type="text" 
                                   name="doi_ijrsi" 
                                   value="<?php echo htmlspecialchars($websiteDetails['doi_ijrsi'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-blue-500 focus:border-blue-500"
                                   placeholder="e.g., 10.1234/ijrsi">
                        </div>
                    </div>
                </div>

                <!-- IJRISS Section -->
                <div class="bg-white p-6 rounded-lg shadow journal-section ijriss">
                    <h2 class="text-2xl font-bold mb-4 text-green-600 flex items-center">
                        <i class="fas fa-book mr-2"></i>IJRISS (International Journal of Research and Innovation in Social Science)
                    </h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-bullhorn mr-1"></i>Call for Papers
                            </label>
                            <input type="text" 
                                   name="call_for_papers_ijriss" 
                                   value="<?php echo htmlspecialchars($websiteDetails['call_for_papers_ijriss'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-green-500 focus:border-green-500"
                                   placeholder="e.g., Open for Submissions">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-calendar-alt mr-1"></i>Submission Deadline
                            </label>
                            <input type="text" 
                                   name="submission_deadline_ijriss" 
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_ijriss'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-green-500 focus:border-green-500"
                                   placeholder="e.g., Rolling Submissions / 31 Dec 2025">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-book-open mr-1"></i>Volumes/Issue
                            </label>
                            <input type="text" 
                                   name="volumes_issue_ijriss" 
                                   value="<?php echo htmlspecialchars($websiteDetails['volumes_issue_ijriss'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-green-500 focus:border-green-500"
                                   placeholder="e.g., Volume 12, Issue 1">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-barcode mr-1"></i>DOI
                            </label>
                            <input type="text" 
                                   name="doi_ijriss" 
                                   value="<?php echo htmlspecialchars($websiteDetails['doi_ijriss'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-green-500 focus:border-green-500"
                                   placeholder="e.g., 10.1234/ijriss">
                        </div>
                    </div>
                </div>

                <!-- IJRIAS Section -->
                <div class="bg-white p-6 rounded-lg shadow journal-section ijrias">
                    <h2 class="text-2xl font-bold mb-4 text-yellow-600 flex items-center">
                        <i class="fas fa-book mr-2"></i>IJRIAS (International Journal of Research and Innovation in Applied Science)
                    </h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-bullhorn mr-1"></i>Call for Papers
                            </label>
                            <input type="text" 
                                   name="call_for_papers_ijrias" 
                                   value="<?php echo htmlspecialchars($websiteDetails['call_for_papers_ijrias'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-yellow-500 focus:border-yellow-500"
                                   placeholder="e.g., Open for Submissions">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-calendar-alt mr-1"></i>Submission Deadline
                            </label>
                            <input type="text" 
                                   name="submission_deadline_ijrias" 
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_ijrias'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-yellow-500 focus:border-yellow-500"
                                   placeholder="e.g., Rolling Submissions / 31 Dec 2025">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-book-open mr-1"></i>Volumes/Issue
                            </label>
                            <input type="text" 
                                   name="volumes_issue_ijrias" 
                                   value="<?php echo htmlspecialchars($websiteDetails['volumes_issue_ijrias'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-yellow-500 focus:border-yellow-500"
                                   placeholder="e.g., Volume 12, Issue 1">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                <i class="fas fa-barcode mr-1"></i>DOI
                            </label>
                            <input type="text" 
                                   name="doi_ijrias" 
                                   value="<?php echo htmlspecialchars($websiteDetails['doi_ijrias'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-yellow-500 focus:border-yellow-500"
                                   placeholder="e.g., 10.1234/ijrias">
                        </div>
                    </div>
                </div>
                
                
                <!-- Subject-wise Submission Deadlines -->
                <div class="bg-white p-6 rounded-lg shadow mt-8">
                    <h2 class="text-2xl font-bold mb-6 text-indigo-600 flex items-center">
                        <i class="fas fa-calendar-check mr-2"></i>
                        Subject-wise Submission Deadlines
                    </h2>
                
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                
                        <!-- Education -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Education Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_education_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_education_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Public Health -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Public Health Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_public_health_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_public_health_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Economics -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Economics Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_economics_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_economics_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Management -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Management Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_management_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_management_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Psychology -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Psychology Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_psyscology_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_psyscology_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Communication -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Communication Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_communication_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_communication_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Sociology -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Sociology Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_sociology_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_sociology_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Microbiology -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Microbiology Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_microbiology_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_microbiology_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- CSE -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                CSE Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_cse_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_cse_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Modern Chemistry -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Modern Chemistry Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_modern_chemistry_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_modern_chemistry_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Physics Research -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Physics Research Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_physics_research_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_physics_research_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Environmental Science -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Environmental Science Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_environmental_science_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_environmental_science_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                        <!-- Agriculture -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">
                                Agriculture Issue
                            </label>
                            <input type="date"
                                   name="submission_deadline_agriculture_issue"
                                   value="<?php echo htmlspecialchars($websiteDetails['submission_deadline_agriculture_issue'] ?? ''); ?>"
                                   class="w-full border-gray-300 rounded-md shadow-sm p-2 focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                
                    </div>
                </div>
                
                <!-- Submit Button -->
                <div class="flex justify-end">
                    <button type="submit" 
                            name="update_details" 
                            class="bg-blue-600 text-white px-8 py-3 rounded-lg hover:bg-blue-700 flex items-center text-lg font-semibold shadow-lg">
                        <i class="fas fa-save mr-2"></i>Save Website Details
                    </button>
                </div>
            </form>

            <!-- Current Values Display -->
            <div class="bg-white p-6 rounded-lg shadow mt-8">
                <h2 class="text-2xl font-bold mb-4 flex items-center">
                    <i class="fas fa-eye mr-2 text-purple-600"></i>Current Website Details
                </h2>
                <div class="overflow-x-auto">
                    <table class="w-full text-sm text-left text-gray-700">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-4 py-3 font-semibold">Field</th>
                                <th class="px-4 py-3 font-semibold">IJRSI</th>
                                <th class="px-4 py-3 font-semibold">IJRISS</th>
                                <th class="px-4 py-3 font-semibold">IJRIAS</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="border-b hover:bg-gray-50">
                                <td class="px-4 py-3 font-semibold">Call for Papers</td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['call_for_papers_ijrsi'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['call_for_papers_ijriss'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['call_for_papers_ijrias'] ?? 'Not set'); ?></td>
                            </tr>
                            <tr class="border-b hover:bg-gray-50">
                                <td class="px-4 py-3 font-semibold">Submission Deadline</td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['submission_deadline_ijrsi'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['submission_deadline_ijriss'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['submission_deadline_ijrias'] ?? 'Not set'); ?></td>
                            </tr>
                            <tr class="border-b hover:bg-gray-50">
                                <td class="px-4 py-3 font-semibold">Volumes/Issue</td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['volumes_issue_ijrsi'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['volumes_issue_ijriss'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['volumes_issue_ijrias'] ?? 'Not set'); ?></td>
                            </tr>
                            <tr class="border-b hover:bg-gray-50">
                                <td class="px-4 py-3 font-semibold">DOI</td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['doi_ijrsi'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['doi_ijriss'] ?? 'Not set'); ?></td>
                                <td class="px-4 py-3"><?php echo htmlspecialchars($websiteDetails['doi_ijrias'] ?? 'Not set'); ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <?php if (isset($websiteDetails['updated_at'])): ?>
                    <p class="mt-4 text-sm text-gray-600">
                        <i class="fas fa-clock mr-1"></i>Last Updated: <?php echo htmlspecialchars(date('F j, Y, g:i a', strtotime($websiteDetails['updated_at']))); ?>
                    </p>
                <?php endif; ?>
            </div>
        </main>
    </div>

    <script>
        // Toggle Sidebar for Mobile
        function toggleMobileSidebar() {
            const sidebar = document.getElementById('sidebar');
            sidebar.classList.toggle('mobile-open');
        }

        // Dark Mode Toggle
        document.getElementById('darkModeToggle').addEventListener('click', function() {
            document.body.classList.toggle('dark');
            const icon = this.querySelector('i');
            icon.classList.toggle('fa-moon');
            icon.classList.toggle('fa-sun');
            
            // Save preference to localStorage
            if (document.body.classList.contains('dark')) {
                localStorage.setItem('darkMode', 'enabled');
            } else {
                localStorage.setItem('darkMode', 'disabled');
            }
        });

        // Load dark mode preference
        if (localStorage.getItem('darkMode') === 'enabled') {
            document.body.classList.add('dark');
            const icon = document.getElementById('darkModeToggle').querySelector('i');
            icon.classList.remove('fa-moon');
            icon.classList.add('fa-sun');
        }

        // Form validation
        document.querySelector('form').addEventListener('submit', function(e) {
            const inputs = this.querySelectorAll('input[type="text"]');
            let hasValue = false;
            
            inputs.forEach(input => {
                if (input.value.trim() !== '') {
                    hasValue = true;
                }
            });
            
            if (!hasValue) {
                e.preventDefault();
                alert('Please fill in at least one field before saving.');
                return false;
            }
        });
    </script>
</body>
</html>