package de.assecutor.hha.backend.views;

import com.vaadin.flow.component.applayout.AppLayout;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.sidenav.SideNav;
import com.vaadin.flow.component.sidenav.SideNavItem;

public class MainLayout extends AppLayout {

    public MainLayout() {
        addClassName("app-shell");
        setPrimarySection(Section.DRAWER);
        addToNavbar(createHeader());
        addToDrawer(createDrawerContent());
    }

    private Div createHeader() {
        DrawerToggle toggle = new DrawerToggle();

        H1 title = new H1("HHA Backoffice");
        title.addClassName("app-title");

        Paragraph subtitle = new Paragraph("Spring Boot 4 und Vaadin 25 im selben Repository wie die Flutter-App.");
        subtitle.addClassName("app-subtitle");

        Div brandBlock = new Div(title, subtitle);
        brandBlock.addClassName("brand-block");

        Div header = new Div(toggle, brandBlock);
        header.addClassName("app-header");
        return header;
    }

    private VerticalLayout createDrawerContent() {
        Span eyebrow = new Span("Shared Repository");
        eyebrow.addClassName("drawer-eyebrow");

        H1 heading = new H1("Web- und Mobile-Stack");
        heading.addClassName("drawer-title");

        Paragraph copy = new Paragraph(
                "Flutter lebt jetzt sauber im Modul /app. Das neue Backend liefert die Web-Oberflaeche und spaeter die API.");
        copy.addClassName("drawer-copy");

        Div intro = new Div(eyebrow, heading, copy);
        intro.addClassName("drawer-intro");

        SideNav navigation = new SideNav();
        navigation.addItem(new SideNavItem("Dashboard", DashboardView.class, VaadinIcon.DASHBOARD.create()));
        navigation.addItem(new SideNavItem("Integration", IntegrationView.class, VaadinIcon.CONNECT.create()));
        navigation.addClassName("drawer-nav");

        Paragraph footer = new Paragraph("Module: /app und /backend");
        footer.addClassName("drawer-footer");

        VerticalLayout drawer = new VerticalLayout(intro, navigation, footer);
        drawer.setPadding(false);
        drawer.setSpacing(false);
        drawer.setSizeFull();
        drawer.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN);
        drawer.addClassName("drawer-content");
        return drawer;
    }
}
