File size: 25,768 Bytes
6a911c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#!/usr/bin/env python3
"""
Professional CLI Interface Module
ไธ“ไธšCLI็•Œ้ขๆจกๅ— - ๅŒ…ๅซlogoใ€้ขœ่‰ฒๅฎšไน‰ๅ’Œ็•Œ้ข็ป„ไปถ
"""

import os
import time
import platform
from pathlib import Path
from typing import Optional
import tkinter as tk
from tkinter import filedialog


class Colors:
    """ANSI color codes for terminal styling"""

    HEADER = "\033[95m"
    OKBLUE = "\033[94m"
    OKCYAN = "\033[96m"
    OKGREEN = "\033[92m"
    WARNING = "\033[93m"
    FAIL = "\033[91m"
    ENDC = "\033[0m"
    BOLD = "\033[1m"
    UNDERLINE = "\033[4m"

    # Gradient colors
    PURPLE = "\033[35m"
    MAGENTA = "\033[95m"
    BLUE = "\033[34m"
    CYAN = "\033[36m"
    GREEN = "\033[32m"
    YELLOW = "\033[33m"


class CLIInterface:
    """Professional CLI interface with modern styling"""

    def __init__(self):
        self.uploaded_file = None
        self.is_running = True

        # Check tkinter availability
        self.tkinter_available = True
        try:
            import tkinter as tk

            # Test if tkinter can create a window (some systems have tkinter but no display)
            test_root = tk.Tk()
            test_root.withdraw()
            test_root.destroy()
        except Exception:
            self.tkinter_available = False

    def clear_screen(self):
        """Clear terminal screen"""
        os.system("cls" if os.name == "nt" else "clear")

    def print_logo(self):
        """Print a beautiful ASCII logo with gradient colors and tech elements"""
        # ็กฎไฟๆฏ่กŒๆ€ปๅ…ฑ79ไธชๅญ—็ฌฆ๏ผˆไธๅŒ…ๆ‹ฌ้ขœ่‰ฒไปฃ็ ๏ผ‰๏ผŒ่พนๆก†ๅฎŒ็พŽๅฏน้ฝ
        logo = f"""
{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.MAGENTA}โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—{Colors.CYAN}                โ•‘
โ•‘  {Colors.BOLD}{Colors.PURPLE}โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘{Colors.CYAN}                โ•‘
โ•‘  {Colors.BOLD}{Colors.BLUE}โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘{Colors.CYAN}                โ•‘
โ•‘  {Colors.BOLD}{Colors.OKBLUE}โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘{Colors.CYAN}                โ•‘
โ•‘  {Colors.BOLD}{Colors.OKCYAN}โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•   โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘{Colors.CYAN}                โ•‘
โ•‘  {Colors.BOLD}{Colors.GREEN}โ•šโ•โ•  โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•     โ•šโ•โ•  โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ•    โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•{Colors.CYAN}                โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.YELLOW}โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”{Colors.CYAN}   โ•‘
โ•‘  {Colors.BOLD}{Colors.YELLOW}โ”‚  ๐Ÿค– AI-POWERED RESEARCH PAPER REPRODUCTION ENGINE ๐Ÿš€                  โ”‚{Colors.CYAN}   โ•‘
โ•‘  {Colors.BOLD}{Colors.YELLOW}โ”‚  โšก INTELLIGENT โ€ข AUTOMATED โ€ข CUTTING-EDGE โšก                        โ”‚{Colors.CYAN}   โ•‘
โ•‘  {Colors.BOLD}{Colors.YELLOW}โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜{Colors.CYAN}   โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.GREEN}๐Ÿ’Ž CORE CAPABILITIES:{Colors.ENDC}                                                        {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Neural PDF Analysis & Code Extraction                                 {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Advanced Document Processing Engine                                   {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Multi-Format Support (PDFโ€ขDOCXโ€ขPPTXโ€ขHTML)                           {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Smart File Upload Interface                                          {Colors.CYAN}โ•‘
โ•‘    {Colors.BOLD}{Colors.OKCYAN}โ–ถ Automated Repository Management                                      {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}{Colors.PURPLE}๐Ÿ”ฌ TECH STACK: Pythonโ€ขAIโ€ขMCPโ€ขDoclingโ€ขLLM                                   {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(logo)

    def print_welcome_banner(self):
        """Print welcome banner with version info"""
        banner = f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                              WELCOME TO ReproAI                              โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.YELLOW}Version: 2.0.0 | Build: Professional Edition                                 {Colors.CYAN}โ•‘
โ•‘  {Colors.GREEN}Status: Ready | Engine: Initialized                                          {Colors.CYAN}โ•‘
โ•‘  {Colors.PURPLE}Author: AI Research Team | License: MIT                                      {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(banner)

    def print_separator(self, char="โ•", length=79, color=Colors.CYAN):
        """Print a styled separator line"""
        print(f"{color}{char * length}{Colors.ENDC}")

    def print_status(self, message: str, status_type: str = "info"):
        """Print status message with appropriate styling"""
        status_styles = {
            "success": f"{Colors.OKGREEN}โœ…",
            "error": f"{Colors.FAIL}โŒ",
            "warning": f"{Colors.WARNING}โš ๏ธ ",
            "info": f"{Colors.OKBLUE}โ„น๏ธ ",
            "processing": f"{Colors.YELLOW}โณ",
            "upload": f"{Colors.PURPLE}๐Ÿ“",
            "download": f"{Colors.CYAN}๐Ÿ“ฅ",
            "analysis": f"{Colors.MAGENTA}๐Ÿ”",
        }

        icon = status_styles.get(status_type, status_styles["info"])
        print(f"{icon} {Colors.BOLD}{message}{Colors.ENDC}")

    def create_menu(self):
        """Create an interactive menu"""
        menu = f"""
{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                MAIN MENU                                      โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKGREEN}๐ŸŒ [U] Process URL       {Colors.CYAN}โ”‚  {Colors.PURPLE}๐Ÿ“ [F] Upload File    {Colors.CYAN}โ”‚  {Colors.FAIL}โŒ [Q] Quit{Colors.CYAN}         โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.YELLOW}๐Ÿ“ Enter a research paper URL (arXiv, IEEE, ACM, etc.)                      {Colors.CYAN}โ•‘
โ•‘  {Colors.YELLOW}   or upload a PDF/DOC file for intelligent analysis                        {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKCYAN}๐Ÿ’ก Tip: Press 'F' to open file browser or 'U' to enter URL manually        {Colors.CYAN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(menu)

    def get_user_input(self):
        """Get user input with styled prompt"""
        print(f"\n{Colors.BOLD}{Colors.OKCYAN}โžค Your choice: {Colors.ENDC}", end="")
        return input().strip().lower()

    def upload_file_gui(self) -> Optional[str]:
        """Modern file upload interface using tkinter with cross-platform compatibility"""
        # Check if tkinter is available
        if not self.tkinter_available:
            self.print_status("GUI file dialog not available on this system", "warning")
            self.print_status("Using manual file path input instead", "info")
            return self._get_manual_file_path()

        def select_file():
            try:
                # Create a hidden root window
                root = tk.Tk()
                root.withdraw()  # Hide the main window

                # Platform-specific configurations
                system = platform.system()

                if system == "Darwin":  # macOS
                    # macOS specific settings
                    try:
                        root.call("wm", "attributes", ".", "-topmost", True)
                    except Exception:
                        pass

                    # macOS compatible file types
                    file_types = [
                        ("PDF Files", ".pdf"),
                        ("Word Documents", ".docx .doc"),
                        ("PowerPoint Files", ".pptx .ppt"),
                        ("HTML Files", ".html .htm"),
                        ("Text Files", ".txt .md"),
                        ("All Files", ".*"),
                    ]
                else:
                    # Windows and Linux
                    root.attributes("-topmost", True)

                    # Windows/Linux compatible file types
                    file_types = [
                        ("PDF Files", "*.pdf"),
                        ("Word Documents", "*.docx;*.doc"),
                        ("PowerPoint Files", "*.pptx;*.ppt"),
                        ("HTML Files", "*.html;*.htm"),
                        ("Text Files", "*.txt;*.md"),
                        ("All Files", "*.*"),
                    ]

                # Set window title
                root.title("Repro-AI - File Selector")

                try:
                    # Open file dialog with platform-appropriate settings
                    file_path = filedialog.askopenfilename(
                        title="Select Research Paper File",
                        filetypes=file_types,
                        initialdir=os.getcwd(),
                    )
                except Exception as e:
                    self.print_status(f"File dialog error: {str(e)}", "error")
                    return None
                finally:
                    # Clean up
                    try:
                        root.destroy()
                    except Exception:
                        pass

                return file_path

            except Exception as e:
                # Fallback: destroy root if it exists
                try:
                    if "root" in locals():
                        root.destroy()
                except Exception:
                    pass

                # Print error and suggest alternative
                self.print_status(f"GUI file dialog failed: {str(e)}", "error")
                self.print_status(
                    "Please use manual file path input instead", "warning"
                )
                return self._get_manual_file_path()

        self.print_status("Opening file browser dialog...", "upload")
        file_path = select_file()

        if file_path:
            # Validate file
            if not os.path.exists(file_path):
                self.print_status("File not found!", "error")
                return None

            file_size = os.path.getsize(file_path) / (1024 * 1024)  # Size in MB
            file_ext = Path(file_path).suffix.lower()

            # Display file info with beautiful formatting
            file_name = Path(file_path).name
            directory = str(Path(file_path).parent)

            # Truncate long paths for display
            if len(file_name) > 50:
                display_name = file_name[:47] + "..."
            else:
                display_name = file_name

            if len(directory) > 49:
                display_dir = "..." + directory[-46:]
            else:
                display_dir = directory

            print(f"""
{Colors.OKGREEN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                               FILE SELECTED                                   โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}๐Ÿ“„ File Name:{Colors.ENDC} {Colors.CYAN}{display_name:<50}{Colors.OKGREEN}โ•‘
โ•‘  {Colors.BOLD}๐Ÿ“ Directory:{Colors.ENDC} {Colors.YELLOW}{display_dir:<49}{Colors.OKGREEN}โ•‘
โ•‘  {Colors.BOLD}๐Ÿ“Š File Size:{Colors.ENDC} {Colors.PURPLE}{file_size:.2f} MB{Colors.OKGREEN}                                      โ•‘
โ•‘  {Colors.BOLD}๐Ÿ”– File Type:{Colors.ENDC} {Colors.MAGENTA}{file_ext.upper():<50}{Colors.OKGREEN}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
""")

            self.print_status(f"File successfully selected: {file_name}", "success")
            return file_path
        else:
            self.print_status("No file selected", "warning")
            return None

    def _get_manual_file_path(self) -> Optional[str]:
        """Fallback method for manual file path input when GUI fails"""
        print(
            f"\n{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—"
        )
        print(
            "โ•‘                           MANUAL FILE INPUT                                   โ•‘"
        )
        print(
            f"โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}"
        )

        print(f"\n{Colors.YELLOW}๐Ÿ“ Supported file types:{Colors.ENDC}")
        print(f"   {Colors.CYAN}โ€ข PDF files (.pdf)")
        print(f"   {Colors.CYAN}โ€ข Word documents (.docx, .doc)")
        print(f"   {Colors.CYAN}โ€ข PowerPoint files (.pptx, .ppt)")
        print(f"   {Colors.CYAN}โ€ข HTML files (.html, .htm)")
        print(f"   {Colors.CYAN}โ€ข Text files (.txt, .md){Colors.ENDC}")

        print(
            f"\n{Colors.BOLD}{Colors.OKCYAN}๐Ÿ“ Enter file path (or drag & drop): {Colors.ENDC}",
            end="",
        )
        file_path = input().strip()

        # Clean up the path (remove quotes if present)
        file_path = file_path.strip("\"'")

        if file_path:
            # Expand user directory if needed
            file_path = os.path.expanduser(file_path)

            # Check if file exists
            if os.path.exists(file_path):
                self.print_status(
                    f"File found: {os.path.basename(file_path)}", "success"
                )
                return file_path
            else:
                self.print_status("File not found at the specified path", "error")
                return None
        else:
            self.print_status("No file path provided", "warning")
            return None

    def get_url_input(self) -> str:
        """Get URL input with validation and examples"""
        print(
            f"\n{Colors.BOLD}{Colors.CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—"
        )
        print(
            "โ•‘                              URL INPUT                                        โ•‘"
        )
        print(
            f"โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}"
        )

        print(f"\n{Colors.YELLOW}๐Ÿ“ Supported URL Examples:{Colors.ENDC}")
        print(f"   {Colors.CYAN}โ€ข arXiv: https://arxiv.org/pdf/2403.00813")
        print(f"   {Colors.CYAN}โ€ข arXiv: @https://arxiv.org/pdf/2403.00813")
        print(f"   {Colors.CYAN}โ€ข IEEE:  https://ieeexplore.ieee.org/document/...")
        print(f"   {Colors.CYAN}โ€ข ACM:   https://dl.acm.org/doi/...")
        print(
            f"   {Colors.CYAN}โ€ข Direct PDF: https://example.com/paper.pdf{Colors.ENDC}"
        )

        print(
            f"\n{Colors.BOLD}{Colors.OKCYAN}๐ŸŒ Enter paper URL: {Colors.ENDC}", end=""
        )
        url = input().strip()

        if url:
            # Basic URL validation
            if any(
                domain in url.lower()
                for domain in ["arxiv.org", "ieee", "acm.org", ".pdf", "researchgate"]
            ):
                self.print_status(f"URL received: {url}", "success")
                return url
            else:
                self.print_status("URL appears valid, proceeding...", "info")
                return url
        else:
            self.print_status("No URL provided", "warning")
            return ""

    def show_progress_bar(self, message: str, duration: float = 2.0):
        """Show a progress animation with enhanced styling"""
        print(f"\n{Colors.YELLOW}{message}{Colors.ENDC}")

        # Progress bar animation with different styles
        bar_length = 50
        for i in range(bar_length + 1):
            percent = (i / bar_length) * 100
            filled = "โ–ˆ" * i
            empty = "โ–‘" * (bar_length - i)

            # Color gradient effect
            if percent < 33:
                color = Colors.FAIL
            elif percent < 66:
                color = Colors.WARNING
            else:
                color = Colors.OKGREEN

            print(
                f"\r{color}[{filled}{empty}] {percent:6.1f}%{Colors.ENDC}",
                end="",
                flush=True,
            )
            time.sleep(duration / bar_length)

        print(f"\n{Colors.OKGREEN}โœ… {message} completed!{Colors.ENDC}\n")

    def show_spinner(self, message: str, duration: float = 1.0):
        """Show a spinner animation"""
        spinner_chars = "โ ‹โ ™โ นโ ธโ ผโ ดโ ฆโ งโ ‡โ "
        end_time = time.time() + duration

        while time.time() < end_time:
            for char in spinner_chars:
                print(
                    f"\r{Colors.CYAN}{char} {Colors.BOLD}{message}{Colors.ENDC}",
                    end="",
                    flush=True,
                )
                time.sleep(0.1)
                if time.time() >= end_time:
                    break

        print(f"\r{Colors.OKGREEN}โœ… {Colors.BOLD}{message} - Done!{Colors.ENDC}")

    def print_results_header(self):
        """Print results section header"""
        header = f"""
{Colors.OKGREEN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                             PROCESSING RESULTS                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(header)

    def print_error_box(self, title: str, error_msg: str):
        """Print error message in a styled box"""
        print(f"""
{Colors.FAIL}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                  ERROR                                        โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.BOLD}Title: {title:<66}{Colors.FAIL}โ•‘
โ•‘  {Colors.BOLD}Error: {error_msg:<66}{Colors.FAIL}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
""")

    def print_goodbye(self):
        """Print goodbye message"""
        goodbye = f"""
{Colors.BOLD}{Colors.YELLOW}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                GOODBYE!                                       โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                               โ•‘
โ•‘  {Colors.CYAN}Thank you for using ReproAI!                                               {Colors.YELLOW}โ•‘
โ•‘  {Colors.GREEN}๐ŸŒŸ Star us on GitHub: https://github.com/your-repo                        {Colors.YELLOW}โ•‘
โ•‘  {Colors.PURPLE}๐Ÿ“ง Contact: support@reproai.com                                          {Colors.YELLOW}โ•‘
โ•‘  {Colors.MAGENTA}๐Ÿ› Report issues: https://github.com/your-repo/issues                    {Colors.YELLOW}โ•‘
โ•‘                                                                               โ•‘
โ•‘  {Colors.OKGREEN}โœจ Happy coding! See you next time! โœจ                                   {Colors.YELLOW}โ•‘
โ•‘                                                                               โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•{Colors.ENDC}
"""
        print(goodbye)

    def ask_continue(self) -> bool:
        """Ask user if they want to continue"""
        print(
            f"\n{Colors.BOLD}{Colors.CYAN}Press Enter to continue or 'q' to quit: {Colors.ENDC}",
            end="",
        )
        choice = input().strip().lower()
        return choice not in ["q", "quit", "exit"]