// Success Modal Function - Add this to teacher_exams.php
function showSuccessModal(message) {
    // Remove existing modals
    const existingModals = document.querySelectorAll('.success-modal-overlay');
    existingModals.forEach(modal => modal.remove());

    // Create modal overlay
    const overlay = document.createElement('div');
    overlay.className = 'success-modal-overlay';
    overlay.innerHTML = `
        <div class="success-modal">
            <div class="success-icon">
                <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <circle cx="12" cy="12" r="10" fill="#d4edda" stroke="#28a745" stroke-width="2"/>
                    <path d="M8 12l2.5 2.5L16 9" stroke="#28a745" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
                </svg>
            </div>
            <div class="success-message">${message}</div>
            <button class="success-ok-btn" onclick="this.closest('.success-modal-overlay').remove()">OK</button>
        </div>
    `;

    // Add styles
    const styles = document.createElement('style');
    styles.textContent = `
        .success-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
            animation: fadeIn 0.3s ease;
        }
        .success-modal {
            background: white;
            border-radius: 12px;
            padding: 40px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            max-width: 400px;
            width: 90%;
        }
        .success-icon {
            margin-bottom: 20px;
            display: flex;
            justify-content: center;
        }
        .success-message {
            font-size: 18px;
            color: #333;
            margin-bottom: 30px;
            line-height: 1.4;
        }
        .success-ok-btn {
            background: #007bff;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 12px 32px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .success-ok-btn:hover {
            background: #0056b3;
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
    `;
    document.head.appendChild(styles);

    // Add to page
    document.body.appendChild(overlay);

    // Auto-focus the OK button
    const okButton = overlay.querySelector('.success-ok-btn');
    okButton.focus();

    // Close on backdrop click
    overlay.addEventListener('click', function(e) {
        if (e.target === overlay) {
            overlay.remove();
        }
    });

    // Close on Escape key
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape') {
            overlay.remove();
        }
    });
}