import flet as ft
from pages.documents.standard import StandardDocuments
from pages.documents.custom import Documents as CustomDocuments

class DocumentsHome:
    def __init__(self, page: ft.Page, home):
        self.page = page
        self.home = home

    def open_standard_docs(self, e):
        """Navighează către lista de documente standard."""
        self.home.placeholder.content = StandardDocuments(self.page, self.home).build()
        self.page.update()

    def open_custom_docs(self, e):
        """Navighează către sistemul de solicitări personalizate."""
        self.home.placeholder.content = CustomDocuments(self.page, self.home).build()
        self.page.update()

    def build(self):
        return ft.Container(
            content=ft.Column(
                [
                    ft.Text(
                        "Documente Juridice", 
                        size=32, 
                        weight=ft.FontWeight.BOLD,
                        color=ft.Colors.BLUE_GREY_900
                    ),
                    ft.Text(
                        "Selectați tipul de serviciu dorit", 
                        size=16, 
                        color=ft.Colors.GREY_700
                    ),
                    ft.Divider(height=40, color=ft.Colors.TRANSPARENT),
                    ft.Row(
                        [
                            ft.Card(
                                content=ft.Container(
                                    content=ft.Column(
                                        [
                                            ft.Icon(ft.Icons.INSERT_DRIVE_FILE, size=60, color=ft.Colors.BLUE_700),
                                            ft.Text("Documente Standard", size=22, weight=ft.FontWeight.BOLD),
                                            ft.Text(
                                                "Modele de contracte, cereri și acte predefinite gata de descărcare.", 
                                                text_align=ft.TextAlign.CENTER,
                                                color=ft.Colors.GREY_600
                                            ),
                                        ],
                                        alignment=ft.MainAxisAlignment.CENTER,
                                        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                                    ),
                                    padding=40,
                                    on_click=self.open_standard_docs,
                                    ink=True,
                                    border_radius=10,
                                ),
                                width=350,
                                height=350,
                                elevation=5,
                            ),
                            ft.Card(
                                content=ft.Container(
                                    content=ft.Column(
                                        [
                                            ft.Icon(ft.Icons.EDIT_NOTE, size=60, color=ft.Colors.ORANGE_700),
                                            ft.Text("Documente Personalizate", size=22, weight=ft.FontWeight.BOLD),
                                            ft.Text(
                                                "Solicită asistență pentru un document adaptat nevoilor tale specifice.", 
                                                text_align=ft.TextAlign.CENTER,
                                                color=ft.Colors.GREY_600
                                            ),
                                        ],
                                        alignment=ft.MainAxisAlignment.CENTER,
                                        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                                    ),
                                    padding=40,
                                    on_click=self.open_custom_docs,
                                    ink=True,
                                    border_radius=10,
                                ),
                                width=350,
                                height=350,
                                elevation=5,
                            ),
                        ],
                        alignment=ft.MainAxisAlignment.CENTER,
                        spacing=40,
                    ),
                ],
                alignment=ft.MainAxisAlignment.CENTER,
                horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                expand=True
            ),
            expand=True,
            padding=20,
        )