import sys
import time
from PySide6.QtWidgets import QApplication
from app.ui.main_window import MainWindow

def main():
    # 시작 시간 측정
    start_time = time.time()
    print(f"[STARTUP] Application starting at {time.strftime('%H:%M:%S')}")
    
    print("[STARTUP] Creating QApplication...")
    t0 = time.time()
    app = QApplication(sys.argv)
    print(f"[STARTUP] QApplication created in {time.time() - t0:.3f}s")
    
    # 스타일 설정
    print("[STARTUP] Setting style...")
    t0 = time.time()
    app.setStyle("Fusion")
    print(f"[STARTUP] Style set in {time.time() - t0:.3f}s")

    # 메인 윈도우 생성 (지연 로딩 적용됨)
    print("[STARTUP] Creating MainWindow...")
    t0 = time.time()
    window = MainWindow()
    print(f"[STARTUP] MainWindow created in {time.time() - t0:.3f}s")
    
    # 윈도우 표시
    print("[STARTUP] Showing window...")
    t0 = time.time()
    window.show()
    print(f"[STARTUP] Window shown in {time.time() - t0:.3f}s")
    
    total_time = time.time() - start_time
    print(f"[STARTUP] ✓ Application ready in {total_time:.3f}s")

    sys.exit(app.exec())

if __name__ == "__main__":
    main()