* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --dark-text: #333;
    --border-color: #ddd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark-text);
}

/* LOGIN SECTION */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 500px;
}

.login-box {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.login-box .logo {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 2rem;
}

.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.login-tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    color: #999;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.login-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.login-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.login-tab-content.active {
    display: block;
}

.login-tab-content h2 {
    margin-bottom: 25px;
    color: var(--dark-text);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

.remember-me {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.remember-me label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e9ecef;
    color: var(--dark-text);
}

.btn-secondary:hover {
    background: #dee2e6;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.signup-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.signup-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.signup-link a:hover {
    text-decoration: underline;
}

.demo-credentials {
    background: #f0f7ff;
    border: 2px solid #cce5ff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.demo-credentials h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.demo-credentials p {
    margin: 5px 0;
    font-size: 0.9rem;
}

/* STUDENT DASHBOARD */
.dashboard-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.navbar {
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    gap: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand h2 {
    color: var(--primary-color);
    margin: 0;
}

.navbar-menu {
    display: flex;
    gap: 10px;
    flex: 1;
}

.nav-item {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: var(--light-bg);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.user-name {
    font-weight: 600;
    color: var(--dark-text);
}

.main-content {
    flex: 1;
    padding: 30px;
    background: var(--light-bg);
    overflow-y: auto;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    color: var(--dark-text);
    margin-bottom: 10px;
    font-size: 2rem;
}

.page-header p {
    color: #666;
    font-size: 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--dark-text);
    margin: 0;
}

.stat-info p {
    color: #999;
    margin: 5px 0 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.section h2 {
    color: var(--dark-text);
    margin-bottom: 20px;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input,
.search-bar select {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.search-bar input:focus,
.search-bar select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.test-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.test-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.test-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.test-card p {
    color: #666;
    margin: 8px 0;
    font-size: 0.95rem;
}

.test-meta {
    display: flex;
    justify-content: space-between;
    margin: 15px 0;
    font-size: 0.85rem;
    color: #999;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.test-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.results-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.result-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--border-color);
}

.result-card.pass {
    border-left-color: var(--success-color);
}

.result-card.fail {
    border-left-color: var(--danger-color);
}

.result-card h3 {
    margin-bottom: 10px;
    color: var(--dark-text);
}

.result-score {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 10px 0;
}

.result-details p {
    margin: 8px 0;
    color: #666;
    font-size: 0.95rem;
}

.profile-container {
    max-width: 600px;
}

.profile-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
}

.profile-info h2 {
    color: var(--dark-text);
    margin-bottom: 5px;
}

.profile-info p {
    color: #666;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.profile-stats .stat {
    text-align: center;
}

.profile-stats .stat span {
    display: block;
    color: #666;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.profile-stats .stat strong {
    display: block;
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* ADMIN DASHBOARD */
.admin-dashboard {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
}

.sidebar-brand h2 {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-menu-item {
    padding: 12px 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.admin-menu-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.admin-main {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.admin-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.admin-header h1 {
    color: var(--dark-text);
    margin: 0;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-tab-content {
    display: none;
    padding: 30px;
    background: var(--light-bg);
    flex: 1;
    overflow-y: auto;
}

.admin-tab-content.active {
    display: block;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.admin-stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-stat-card .stat-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
}

.admin-stat-card h3 {
    font-size: 2rem;
    color: var(--dark-text);
    margin: 0;
}

.admin-stat-card p {
    color: #999;
    margin: 0;
}

.admin-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.chart-container h3 {
    margin-bottom: 20px;
    color: var(--dark-text);
}

.admin-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header-with-action h2 {
    color: var(--dark-text);
    margin: 0;
}

.admin-search-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.admin-search-filter input,
.admin-search-filter select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.admin-search-filter input {
    flex: 1;
}

.admin-tests-table-wrapper,
.admin-users-table-wrapper {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead {
    background: var(--light-bg);
    border-bottom: 2px solid var(--border-color);
}

.admin-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-text);
}

.admin-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: #666;
}

.admin-table tbody tr:hover {
    background: var(--light-bg);
}

.admin-table .status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-table .status-badge.active {
    background: #d4edda;
    color: var(--success-color);
}

.admin-table .status-badge.inactive {
    background: #f8d7da;
    color: var(--danger-color);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons button {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.report-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.report-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.report-card .stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.report-card .stat:last-child {
    border-bottom: none;
}

.settings-form {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.settings-form .form-group {
    margin-bottom: 20px;
}

.settings-form .form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark-text);
}

.settings-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

/* MODALS */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-content.large {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    border: none;
    background: none;
}

.close:hover {
    color: #000;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.test-timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--danger-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.questions-container {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 8px;
}

.question-item {
    background: white;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.question-item h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.option-group {
    margin: 10px 0;
}

.option-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.option-group input[type="radio"],
.option-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.filters {
    display: flex;
    gap: 10px;
}

.filters select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.reports-filters {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.reports-filters label {
    font-weight: 600;
    color: var(--dark-text);
}

.reports-filters input[type="date"] {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
    }

    .navbar-menu {
        flex-wrap: wrap;
        width: 100%;
    }

    .navbar-right {
        margin-left: 0;
        flex-direction: column;
        width: 100%;
    }

    .dashboard-sections {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        width: 70px;
    }

    .admin-sidebar .sidebar-brand h2,
    .admin-menu-item span {
        display: none;
    }

    .admin-main {
        margin-left: 70px;
    }

    .admin-stats-grid,
    .stats-grid,
    .tests-grid,
    .results-list {
        grid-template-columns: 1fr;
    }

    .admin-charts {
        grid-template-columns: 1fr;
    }

    .profile-stats {
        grid-template-columns: 1fr;
    }

    .test-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-header-with-action {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-search-filter {
        flex-direction: column;
    }

    .admin-search-filter input,
    .admin-search-filter select {
        width: 100%;
    }

    .reports-filters {
        flex-direction: column;
    }

    .reports-filters input[type="date"] {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 20px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .admin-table {
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px 5px;
    }

    .action-buttons {
        flex-direction: column;
    }
}
```

## 3. JavaScript File (script.js)

```javascript name=script.js
// Advanced Test Series Portal - Main JavaScript

class TestSeriesPortal {
    constructor() {
        this.users = this.loadData('users') || this.initializeDefaultUsers();
        this.tests = this.loadData('tests') || this.initializeDefaultTests();
        this.results = this.loadData('results') || [];
        this.settings = this.loadData('settings') || this.initializeDefaultSettings();
        this.currentUser = null;
        this.currentAdmin = null;
        this.testTimer = null;
        this.init();
    }

    init() {
        this.setupEventListeners();
        this.checkRememberedLogin();
    }

    // Initialize default users
    initializeDefaultUsers() {
        return [
            {
                id: 'user1',
                name: 'John Doe',
                email: 'student@example.com',
                password: 'password123',
                type: 'student',
                joinedDate: new Date().toLocaleDateString(),
                status: 'active'
            },
            {
                id: 'admin1',
                name: 'Admin User',
                email: 'admin@example.com',
                adminId: 'admin001',
                password: 'admin@123',
                type: 'admin',
                joinedDate: new Date().toLocaleDateString(),
                status: 'active'
            }
        ];
    }

    // Initialize default tests
    initializeDefaultTests() {
        return [
            {
                id: 'test1',
                name: 'JavaScript Basics',
                category: 'Programming',
                description: 'Learn the fundamentals of JavaScript',
                duration: 60,
                totalQuestions: 10,
                status: 'active',
                createdBy: 'admin1',
                createdDate: new Date().toLocaleDateString(),
                attempts: 5,
                questions: [
                    {
                        id: 1,
                        text: 'What is JavaScript?',
                        type: 'multiple',
                        marks: 1,
                        correctAnswer: 'option1',
                        options: [
                            { id: 'option1', text: 'A programming language' },
                            { id: 'option2', text: 'A markup language' },
                            { id: 'option3', text: 'A styling language' }
                        ]
                    },
                    {
                        id: 2,
                        text: 'JavaScript runs on the client side.',
                        type: 'true-false',
                        marks: 1,
                        correctAnswer: 'true',
                        options: []
                    }
                ]
            },
            {
                id: 'test2',
                name: 'HTML & CSS Advanced',
                category: 'Web Development',
                description: 'Advanced HTML and CSS concepts',
                duration: 45,
                totalQuestions: 8,
                status: 'active',
                createdBy: 'admin1',
                createdDate: new Date().toLocaleDateString(),
                attempts: 3,
                questions: []
            }
        ];
    }

    // Initialize default settings
    initializeDefaultSettings() {
        return {
            portalName: 'Advanced Test Series Portal',
            maxDuration: 120,
            passPercentage: 50,
            allowReview: true
        };
    }

    // Setup event listeners
    setupEventListeners() {
        // Login tabs
        document.querySelectorAll('.login-tab-btn').forEach(btn => {
            btn.addEventListener('click', (e) => this.switchLoginTab(e.target));
        });

        // Student login
        document.getElementById('studentLoginForm')?.addEventListener('submit', (e) => this.studentLogin(e));

        // Admin login
        document.getElementById('adminLoginForm')?.addEventListener('submit', (e) => this.adminLogin(e));

        // Student signup
        document.getElementById('studentSignupForm')?.addEventListener('submit', (e) => this.studentSignup(e));

        // Student navigation
        document.querySelectorAll('.nav-item').forEach(item => {
            item.addEventListener('click', function() {
                document.querySelectorAll('.nav-item').forEach(i => i.classList.remove('active'));
                this.classList.add('active');
            });
        });

        // Admin navigation
        document.querySelectorAll('.admin-menu-item').forEach(item => {
            item.addEventListener('click', function() {
                document.querySelectorAll('.admin-menu-item').forEach(i => i.classList.remove('active'));
                this.classList.add('active');
            });
        });

        // Modal close buttons
        document.querySelectorAll('.close').forEach(closeBtn => {
            closeBtn.addEventListener('click', (e) => {
                e.target.closest('.modal').classList.remove('show');
            });
        });

        // Admin forms
        document.getElementById('testFormAdmin')?.addEventListener('submit', (e) => this.saveTestAdmin(e));
        document.getElementById('addUserForm')?.addEventListener('submit', (e) => this.addUserAdmin(e));
        document.getElementById('settingsForm')?.addEventListener('submit', (e) => this.saveSettings(e));

        // Take test form
        document.getElementById('takeTestFormStudent')?.addEventListener('submit', (e) => this.submitTest(e));

        // Admin test search
        document.getElementById('adminTestSearch')?.addEventListener('input', (e) => this.searchAdminTests(e.target.value));
        document.getElementById('adminTestFilter')?.addEventListener('change', (e) => this.filterAdminTests(e.target.value));

        // Admin user search
        document.getElementById('adminUserSearch')?.addEventListener('input', (e) => this.searchAdminUsers(e.target.value));
        document.getElementById('adminUserFilter')?.addEventListener('change', (e) => this.filterAdminUsers(e.target.value));

        // Report generation
        document.getElementById('reportFromDate')?.addEventListener('change', () => this.generateReportDateChange());
        document.getElementById('reportToDate')?.addEventListener('change', () => this.generateReportDateChange());

        // Test search and filter in student dashboard
        document.getElementById('testSearch')?.addEventListener('input', (e) => this.searchStudentTests(e.target.value));
        document.getElementById('testCategory')?.addEventListener('change', (e) => this.filterStudentTests(e.target.value));

        // Result sorting
        document.getElementById('resultSort')?.addEventListener('change', (e) => this.sortResults(e.target.value));
    }

    // Switch login tabs
    switchLoginTab(btn) {
        document.querySelectorAll('.login-tab-btn').forEach(b => b.classList.remove('active'));
        document.querySelectorAll('.login-tab-content').forEach(c => c.classList.remove('active'));

        btn.classList.add('active');
        
        const tabName = btn.dataset.tab;
        if (tabName === 'student-login') {
            document.getElementById('studentLoginForm').classList.add('active');
        } else if (tabName === 'admin-login') {
            document.getElementById('adminLoginForm').classList.add('active');
        }
    }

    // Student login
    studentLogin(e) {
        e.preventDefault();
        const email = document.getElementById('studentEmail').value;
        const password = document.getElementById('studentPassword').value;
        const remember = document.getElementById('rememberStudent').checked;

        const user = this.users.find(u => u.email === email && u.password === password && u.type === 'student');

        if (user) {
            this.currentUser = user;
            if (remember) {
                localStorage.setItem('rememberedLogin', JSON.stringify({ type: 'student', email: email }));
            } else {
                localStorage.removeItem('rememberedLogin');
            }
            this.showStudentDashboard();
        } else {
            alert('Invalid email or password!');
        }
    }

    // Admin login
    adminLogin(e) {
        e.preventDefault();
        const adminId = document.getElementById('adminId').value;
        const password = document.getElementById('adminPassword').value;
        const remember = document.getElementById('rememberAdmin').checke