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")

    # 역 정보는 파일 로드 시점에 자동으로 로드됨 (지연 로딩)
    # TrackInfo.load_info() 호출 제거 - 불필요한 초기 로딩 방지

    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()