<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Panel - Alpha Genomics</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;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 {
            --admin-bg: #f0f4f8;
            --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
            --sidebar-width: 270px;
            --accent: #3b82f6;
            --accent-hover: #2563eb;
            --accent-light: rgba(59, 130, 246, 0.1);
            --accent-glow: rgba(59, 130, 246, 0.25);
            --success: #10b981;
            --success-hover: #059669;
            --danger: #ef4444;
            --danger-hover: #dc2626;
            --warning: #f59e0b;
            --warning-hover: #d97706;
            --info: #06b6d4;
            --card-bg: #ffffff;
            --card-border: rgba(0, 0, 0, 0.04);
            --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
            --card-shadow-hover: 0 4px 16px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.04);
            --text-primary: #0f172a;
            --text-secondary: #64748b;
            --text-muted: #94a3b8;
            --border: #e2e8f0;
            --input-border: #cbd5e1;
            --input-focus: #3b82f6;
            --radius: 12px;
            --radius-sm: 8px;
            --radius-xs: 6px;
            --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: var(--admin-bg);
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.6;
            -webkit-font-smoothing: antialiased;
        }

        a { text-decoration: none; color: inherit; }

        .admin-layout { display: flex; min-height: 100vh; }

        /* ========== SIDEBAR ========== */
        .admin-sidebar {
            width: var(--sidebar-width);
            background: var(--sidebar-bg);
            color: #fff;
            position: fixed;
            height: 100vh;
            overflow-y: auto;
            z-index: 100;
            border-right: 1px solid rgba(255,255,255,0.05);
        }

        .admin-sidebar::-webkit-scrollbar { width: 4px; }
        .admin-sidebar::-webkit-scrollbar-track { background: transparent; }
        .admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

        .admin-sidebar-header {
            padding: 28px 24px 22px;
            border-bottom: 1px solid rgba(255,255,255,0.08);
            background: rgba(0,0,0,0.15);
        }

        .admin-sidebar-header h2 {
            font-size: 17px;
            font-weight: 700;
            letter-spacing: -0.02em;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .admin-sidebar-header h2::before {
            content: '';
            display: inline-block;
            width: 8px;
            height: 8px;
            background: var(--accent);
            border-radius: 50%;
            box-shadow: 0 0 8px var(--accent-glow);
        }

        .admin-sidebar-header p {
            font-size: 12px;
            color: rgba(255,255,255,0.45);
            margin-top: 6px;
            font-weight: 400;
        }

        .admin-sidebar-header .admin-role-badge {
            display: inline-block;
            margin-top: 10px;
            padding: 4px 12px;
            background: rgba(59, 130, 246, 0.15);
            border: 1px solid rgba(59, 130, 246, 0.25);
            border-radius: 20px;
            font-size: 11px;
            font-weight: 600;
            color: #93c5fd;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .admin-nav-section {
            padding: 16px 16px 6px;
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: rgba(255,255,255,0.3);
        }

        .admin-nav { list-style: none; padding: 8px 0; }

        .admin-nav li a {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 20px;
            margin: 2px 12px;
            color: rgba(255,255,255,0.55);
            transition: var(--transition);
            font-size: 13px;
            font-weight: 500;
            border-radius: var(--radius-sm);
            position: relative;
        }

        .admin-nav li a:hover {
            background: rgba(255,255,255,0.07);
            color: rgba(255,255,255,0.9);
        }

        .admin-nav li a.active {
            background: rgba(59, 130, 246, 0.15);
            color: #93c5fd;
            font-weight: 600;
        }

        .admin-nav li a.active::before {
            content: '';
            position: absolute;
            left: -12px;
            top: 50%;
            transform: translateY(-50%);
            width: 3px;
            height: 20px;
            background: var(--accent);
            border-radius: 0 3px 3px 0;
        }

        .admin-nav li a i {
            width: 20px;
            text-align: center;
            font-size: 14px;
            opacity: 0.8;
        }

        .admin-nav li a.active i { opacity: 1; }

        .admin-nav-divider {
            height: 1px;
            background: rgba(255,255,255,0.06);
            margin: 10px 24px;
        }

        /* ========== MAIN CONTENT ========== */
        .admin-main {
            margin-left: var(--sidebar-width);
            flex: 1;
            padding: 32px 36px;
            min-height: 100vh;
        }

        /* ========== TOPBAR ========== */
        .admin-topbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 28px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border);
        }

        .admin-topbar h2 {
            font-size: 26px;
            font-weight: 800;
            color: var(--text-primary);
            letter-spacing: -0.03em;
        }

        .admin-topbar span, .admin-topbar a {
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 500;
        }

        .admin-topbar a {
            color: var(--accent);
            transition: var(--transition);
        }

        .admin-topbar a:hover { color: var(--accent-hover); }

        /* ========== STAT CARDS ========== */
        .stat-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
            gap: 18px;
            margin-bottom: 32px;
        }

        .stat-card {
            background: var(--card-bg);
            border-radius: var(--radius);
            padding: 24px;
            box-shadow: var(--card-shadow);
            border: 1px solid var(--card-border);
            text-align: center;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }

        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient(90deg, var(--accent), #8b5cf6);
            opacity: 0;
            transition: var(--transition);
        }

        .stat-card:hover {
            box-shadow: var(--card-shadow-hover);
            transform: translateY(-2px);
        }

        .stat-card:hover::before { opacity: 1; }

        .stat-card .number {
            font-size: 38px;
            font-weight: 800;
            background: linear-gradient(135deg, var(--accent), #8b5cf6);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            line-height: 1.1;
        }

        .stat-card .label {
            font-size: 13px;
            color: var(--text-secondary);
            margin-top: 8px;
            font-weight: 500;
        }

        .stat-card .label i {
            margin-right: 4px;
            font-size: 12px;
            opacity: 0.7;
        }

        /* Alternating stat card colors */
        .stat-card:nth-child(3n+1) .number { background: linear-gradient(135deg, #3b82f6, #6366f1); -webkit-background-clip: text; background-clip: text; }
        .stat-card:nth-child(3n+2) .number { background: linear-gradient(135deg, #10b981, #06b6d4); -webkit-background-clip: text; background-clip: text; }
        .stat-card:nth-child(3n+3) .number { background: linear-gradient(135deg, #f59e0b, #ef4444); -webkit-background-clip: text; background-clip: text; }

        /* ========== ADMIN CARDS ========== */
        .admin-card {
            background: var(--card-bg);
            border-radius: var(--radius);
            padding: 28px;
            box-shadow: var(--card-shadow);
            border: 1px solid var(--card-border);
            margin-bottom: 24px;
            transition: var(--transition);
        }

        .admin-card:hover {
            box-shadow: var(--card-shadow-hover);
        }

        .admin-card h3 {
            font-size: 17px;
            font-weight: 700;
            margin-bottom: 20px;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 10px;
            padding-bottom: 14px;
            border-bottom: 1px solid var(--border);
        }

        .admin-card h3 i {
            color: var(--accent);
            font-size: 16px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--accent-light);
            border-radius: var(--radius-sm);
        }

        /* ========== BUTTONS ========== */
        .btn-sm {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 18px;
            border-radius: var(--radius-xs);
            font-size: 13px;
            font-weight: 600;
            font-family: inherit;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            white-space: nowrap;
            line-height: 1.4;
            letter-spacing: -0.01em;
        }

        .btn-sm i { font-size: 12px; }

        .btn-sm-primary {
            background: var(--accent);
            color: #fff;
            box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
        }

        .btn-sm-primary:hover {
            background: var(--accent-hover);
            color: #fff;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
            transform: translateY(-1px);
        }

        .btn-sm-danger {
            background: var(--danger);
            color: #fff;
            box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
        }

        .btn-sm-danger:hover {
            background: var(--danger-hover);
            color: #fff;
            box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
            transform: translateY(-1px);
        }

        .btn-sm-success {
            background: var(--success);
            color: #fff;
            box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
        }

        .btn-sm-success:hover {
            background: var(--success-hover);
            color: #fff;
            box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
            transform: translateY(-1px);
        }

        .btn-sm-warning {
            background: var(--warning);
            color: #fff;
            box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
        }

        .btn-sm-warning:hover {
            background: var(--warning-hover);
            color: #fff;
            box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
            transform: translateY(-1px);
        }

        .btn-sm-outline {
            background: transparent;
            color: var(--text-secondary);
            border: 1.5px solid var(--border);
        }

        .btn-sm-outline:hover {
            background: var(--admin-bg);
            color: var(--text-primary);
            border-color: var(--text-muted);
        }

        /* ========== TABLES ========== */
        .admin-table-wrap {
            overflow-x: auto;
            border-radius: var(--radius-sm);
        }

        table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
        }

        table th {
            padding: 13px 16px;
            text-align: left;
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: var(--text-secondary);
            background: #f8fafc;
            border-bottom: 2px solid var(--border);
        }

        table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
        table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

        table td {
            padding: 14px 16px;
            text-align: left;
            font-size: 13px;
            color: var(--text-primary);
            border-bottom: 1px solid #f1f5f9;
            vertical-align: middle;
        }

        table tr { transition: var(--transition); }

        table tbody tr:hover {
            background: #f8fafc;
        }

        table tbody tr:last-child td { border-bottom: none; }

        .actions {
            display: flex;
            gap: 6px;
            align-items: center;
        }

        .admin-img-preview {
            width: 56px;
            height: 40px;
            object-fit: cover;
            border-radius: var(--radius-xs);
            border: 2px solid var(--border);
        }

        /* ========== FORMS ========== */
        .form-group {
            margin-bottom: 22px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            font-size: 13px;
            color: var(--text-primary);
            letter-spacing: -0.01em;
        }

        .form-group input,
        .form-group textarea,
        .form-group select {
            width: 100%;
            padding: 11px 16px;
            border: 1.5px solid var(--input-border);
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-family: inherit;
            color: var(--text-primary);
            background: #fff;
            transition: var(--transition);
        }

        .form-group input:focus,
        .form-group textarea:focus,
        .form-group select:focus {
            outline: none;
            border-color: var(--input-focus);
            box-shadow: 0 0 0 3px var(--accent-light);
        }

        .form-group input::placeholder,
        .form-group textarea::placeholder {
            color: var(--text-muted);
        }

        .form-group textarea {
            min-height: 120px;
            resize: vertical;
        }

        .form-group select {
            cursor: pointer;
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 14px center;
            padding-right: 36px;
        }

        /* ========== ALERTS ========== */
        .alert {
            padding: 14px 20px;
            border-radius: var(--radius-sm);
            margin-bottom: 22px;
            font-size: 14px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 10px;
            border: 1px solid transparent;
        }

        .alert::before {
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            font-size: 15px;
            flex-shrink: 0;
        }

        .alert-success {
            background: #ecfdf5;
            color: #065f46;
            border-color: #a7f3d0;
        }

        .alert-success::before { content: '\f058'; color: #10b981; }

        .alert-error {
            background: #fef2f2;
            color: #991b1b;
            border-color: #fecaca;
        }

        .alert-error::before { content: '\f06a'; color: #ef4444; }

        .alert-warning {
            background: #fffbeb;
            color: #92400e;
            border-color: #fde68a;
        }

        .alert-warning::before { content: '\f071'; color: #f59e0b; }

        .alert-info {
            background: #ecfeff;
            color: #155e75;
            border-color: #a5f3fc;
        }

        .alert-info::before { content: '\f05a'; color: #06b6d4; }

        /* ========== PAGINATION ========== */
        .pagination {
            display: flex;
            gap: 6px;
            align-items: center;
            flex-wrap: wrap;
            margin-top: 20px;
        }

        .pagination .btn-sm {
            min-width: 38px;
            justify-content: center;
        }

        /* ========== FILE UPLOAD AREA ========== */
        .file-upload-area {
            display: flex;
            gap: 10px;
            align-items: center;
            margin-top: 8px;
        }

        .file-upload-area input[type="file"] {
            font-size: 13px;
            padding: 6px;
            border: 1.5px dashed var(--input-border);
            border-radius: var(--radius-xs);
            background: #f8fafc;
            cursor: pointer;
            flex: 1;
        }

        .file-upload-area input[type="file"]:hover {
            border-color: var(--accent);
            background: var(--accent-light);
        }

        /* ========== QUICK ACTIONS ========== */
        .quick-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .quick-actions .btn-sm {
            padding: 10px 20px;
            font-size: 13px;
        }

        /* ========== MOBILE TOGGLE ========== */
        .admin-mobile-toggle {
            display: none;
            position: fixed;
            top: 14px;
            left: 14px;
            z-index: 200;
            width: 42px;
            height: 42px;
            background: var(--accent);
            color: #fff;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 18px;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(59,130,246,0.3);
            align-items: center;
            justify-content: center;
        }

        .admin-sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            z-index: 99;
        }

        /* ========== RESPONSIVE ========== */
        @media (max-width: 1024px) {
            .stat-grid { grid-template-columns: repeat(3, 1fr); }
        }

        @media (max-width: 768px) {
            .admin-mobile-toggle { display: flex; }
            .admin-sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
            }
            .admin-sidebar.open { transform: translateX(0); }
            .admin-sidebar-overlay.open { display: block; }
            .admin-main {
                margin-left: 0;
                padding: 70px 16px 24px;
            }
            .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
            .stat-card { padding: 18px; }
            .stat-card .number { font-size: 28px; }
            .admin-topbar h2 { font-size: 20px; }
            .admin-card { padding: 20px; }
            table th, table td { padding: 10px 12px; font-size: 12px; }
            .quick-actions .btn-sm { padding: 8px 14px; font-size: 12px; }
        }

        @media (max-width: 480px) {
            .stat-grid { grid-template-columns: 1fr 1fr; }
        }
    </style>
</head>
<body>

<button class="admin-mobile-toggle" onclick="document.querySelector('.admin-sidebar').classList.toggle('open'); document.querySelector('.admin-sidebar-overlay').classList.toggle('open');">
    <i class="fas fa-bars"></i>
</button>
<div class="admin-sidebar-overlay" onclick="document.querySelector('.admin-sidebar').classList.remove('open'); this.classList.remove('open');"></div>

<div class="admin-layout">
    <aside class="admin-sidebar">
        <div class="admin-sidebar-header">
            <h2>Admin Panel</h2>
            <p>Alpha Genomics CMS</p>
            <div class="admin-role-badge"><?= htmlspecialchars($_SESSION['admin_role'] ?? 'admin') ?></div>
        </div>
        <ul class="admin-nav">
            <div class="admin-nav-section">Overview</div>
            <li><a href="/admin" class="<?= $_SERVER['REQUEST_URI'] === '/admin' ? 'active' : '' ?>"><i class="fas fa-tachometer-alt"></i> Dashboard</a></li>

            <div class="admin-nav-divider"></div>
            <div class="admin-nav-section">Content</div>
            <li><a href="/admin/sliders" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/sliders') === 0 ? 'active' : '' ?>"><i class="fas fa-images"></i> Sliders</a></li>
            <li><a href="/admin/sections" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/sections') === 0 ? 'active' : '' ?>"><i class="fas fa-th-large"></i> Sections</a></li>
            <li><a href="/admin/announcements" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/announcements') === 0 ? 'active' : '' ?>"><i class="fas fa-bullhorn"></i> Announcements</a></li>
            <li><a href="/admin/services" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/services') === 0 ? 'active' : '' ?>"><i class="fas fa-flask"></i> Services</a></li>
            <li><a href="/admin/workshops" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/workshops') === 0 ? 'active' : '' ?>"><i class="fas fa-chalkboard-teacher"></i> Workshops</a></li>
            <li><a href="/admin/articles" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/articles') === 0 ? 'active' : '' ?>"><i class="fas fa-newspaper"></i> Articles</a></li>
            <li><a href="/admin/categories" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/categories') === 0 ? 'active' : '' ?>"><i class="fas fa-tags"></i> Categories</a></li>

            <div class="admin-nav-divider"></div>
            <div class="admin-nav-section">Media & People</div>
            <li><a href="/admin/gallery" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/gallery') === 0 ? 'active' : '' ?>"><i class="fas fa-camera"></i> Gallery</a></li>
            <li><a href="/admin/resources" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/resources') === 0 ? 'active' : '' ?>"><i class="fas fa-folder-open"></i> Resources</a></li>
            <li><a href="/admin/facilities" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/facilities') === 0 ? 'active' : '' ?>"><i class="fas fa-microscope"></i> Facilities</a></li>
            <li><a href="/admin/team" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/team') === 0 ? 'active' : '' ?>"><i class="fas fa-users"></i> Team</a></li>
            <li><a href="/admin/alumni" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/alumni') === 0 ? 'active' : '' ?>"><i class="fas fa-user-graduate"></i> Alumni</a></li>

            <div class="admin-nav-divider"></div>
            <div class="admin-nav-section">Engagement</div>
            <li><a href="/admin/registrations" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/registrations') === 0 ? 'active' : '' ?>"><i class="fas fa-clipboard-list"></i> Registrations</a></li>
            <li><a href="/admin/newsletter" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/newsletter') === 0 ? 'active' : '' ?>"><i class="fas fa-mail-bulk"></i> Newsletter</a></li>
            <li><a href="/admin/messages" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/messages') === 0 ? 'active' : '' ?>"><i class="fas fa-envelope"></i> Messages</a></li>

            <div class="admin-nav-divider"></div>
            <div class="admin-nav-section">System</div>
            <li><a href="/admin/menu" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/menu') === 0 ? 'active' : '' ?>"><i class="fas fa-bars"></i> Menu Builder</a></li>
            <li><a href="/admin/seo" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/seo') === 0 ? 'active' : '' ?>"><i class="fas fa-search"></i> SEO</a></li>
            <li><a href="/admin/audit" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/audit') === 0 ? 'active' : '' ?>"><i class="fas fa-history"></i> Audit Log</a></li>
            <li><a href="/admin/users" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/users') === 0 ? 'active' : '' ?>"><i class="fas fa-user-shield"></i> Users & Roles</a></li>
            <li><a href="/admin/settings" class="<?= strpos($_SERVER['REQUEST_URI'], '/admin/settings') === 0 ? 'active' : '' ?>"><i class="fas fa-cog"></i> Settings</a></li>

            <div class="admin-nav-divider"></div>
            <li><a href="/" target="_blank"><i class="fas fa-external-link-alt"></i> View Website</a></li>
            <li><a href="/admin/logout" style="color: rgba(239,68,68,0.7);"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
        </ul>
    </aside>
    <main class="admin-main">
