Background: Perioperative atrial fibrillation (POAF) commonly occurs after major cardiac and non-cardiac surgeries. It has a reported incidence rate of 20%–50% following cardiac surgery and 8–12% after major noncardiac surgeries. Many complications arise from this condition including increased morbidity, raised risk of stroke, prolonged hospital stays, and large healthcare bills. The traditional intraoperative monitoring method is manual ECG surveillance in time sequence, which is sometimes unable to detect a brief episode or check-up. In this way, our intention is helpful to interruption of such events at an early stage. Objective: This paper proposes a novel deep learning method for real-time detection of POAF using single-lead ECG signals, in order to make intraoperative patient safety as well as clinical decisions. Methods: A Temporal-Convolutional Transformer (TCT) network was established to combine convolutional neural networks for local morphological feature extraction, and transformer encoders capturing the long-range temporal dependencies of sequences. With training based on the MIT-BIH Atrial Fibrillation Database and augmentation of over 300 hours of intraoperative ECG recordings, models were evaluated using metrics such as accuracy, sensitivity, F1-score, specificity, AUC ans time to detection. Model explainability was evaluated by multiple visualization methods such as Heatmap techniques like Grad-CAM and visual attention maps. Results: The TCT network reached data accuracy of 97.5%, sensitivity 96.2%, specificity 98.1% and average detection time from capture to detection was 2.3 seconds. When atrial fibrillation and normal rhythms were studied with dimensionality reduction methods (PCA, t-SNE), results confirmed a clear separation. Grad-CAM images not only demonstrated closer relationships between atrial fibrillation cases but also made clear that the presence or absence of P-waves in a person's heart rhythm pointed to critical diagnosis points for these patients. Conclusion: The intended TCT structure delivers accurate, robust and interpretable real-time detection of POAF. Its performance and transparency in turn allow potential integration into perioperative monitoring workflows and telemedicine platforms. Future work should focus on multicenter validation, multi-lead analysis and prospective clinical trials to show across the range of different surgical environments where this technology is well-suited.