// vapora-frontend: Leptos CSR UI for VAPORA v1.0
// Phase 1: Complete frontend implementation with glassmorphism design

use leptos::prelude::*;
use leptos_router::{
    components::{Route, Router, Routes},
    StaticSegment,
};

mod api;
mod components;
mod config;
mod pages;

use pages::*;

/// Main application component with routing
#[component]
pub fn App() -> impl IntoView {
    view! {
        <Router>
            <Routes fallback=|| view! { <NotFoundPage /> }>
                <Route path=StaticSegment("") view=HomePage />
                <Route path=StaticSegment("projects") view=ProjectsPage />
                <Route path=(StaticSegment("projects"), StaticSegment(":id")) view=ProjectDetailPage />
                <Route path=StaticSegment("agents") view=AgentsPage />
                <Route path=StaticSegment("workflows") view=WorkflowsPage />
            </Routes>
        </Router>
    }
}

/// Entry point for CSR mode
#[cfg(feature = "csr")]
pub fn main() {
    // Initialize console logger and panic hook
    _ = console_log::init_with_level(log::Level::Debug);
    console_error_panic_hook::set_once();

    // Mount the app to the DOM
    mount_to_body(|| view! { <App /> })
}
