use dioxus::prelude::*;
use dioxus_free_icons::icons::bs_icons::BsShieldCheck;
use dioxus_free_icons::Icon;

use crate::i18n::{t, Locale};
use crate::Route;

/// Privacy Policy page.
///
/// Displays the platform's privacy policy. Publicly accessible
/// without authentication.
#[component]
pub fn PrivacyPage() -> Element {
    let locale = use_context::<Signal<Locale>>();
    let l = *locale.read();

    rsx! {
        div { class: "legal-page",
            nav { class: "legal-nav",
                Link { to: Route::LandingPage {}, class: "landing-logo",
                    span { class: "landing-logo-icon",
                        Icon { icon: BsShieldCheck, width: 20, height: 20 }
                    }
                    span { "CERTifAI" }
                }
            }
            main { class: "legal-content",
                h1 { "{t(l, \"privacy.title\")}" }
                p { class: "legal-updated", "{t(l, \"privacy.last_updated\")}" }

                h2 { "{t(l, \"privacy.intro_title\")}" }
                p { "{t(l, \"privacy.intro_text\")}" }

                h2 { "{t(l, \"privacy.controller_title\")}" }
                p {
                    "{t(l, \"impressum.company\")}"
                    br {}
                    "{t(l, \"privacy.controller_address\")}"
                    br {}
                    "{t(l, \"privacy.controller_email\")}"
                }

                h2 { "{t(l, \"privacy.data_title\")}" }
                p { "{t(l, \"privacy.data_intro\")}" }
                ul {
                    li {
                        strong { "{t(l, \"privacy.data_account_label\")}" }
                        "{t(l, \"privacy.data_account_text\")}"
                    }
                    li {
                        strong { "{t(l, \"privacy.data_usage_label\")}" }
                        "{t(l, \"privacy.data_usage_text\")}"
                    }
                    li {
                        strong { "{t(l, \"privacy.data_technical_label\")}" }
                        "{t(l, \"privacy.data_technical_text\")}"
                    }
                }

                h2 { "{t(l, \"privacy.use_title\")}" }
                ul {
                    li { "{t(l, \"privacy.use_1\")}" }
                    li { "{t(l, \"privacy.use_2\")}" }
                    li { "{t(l, \"privacy.use_3\")}" }
                    li { "{t(l, \"privacy.use_4\")}" }
                }

                h2 { "{t(l, \"privacy.storage_title\")}" }
                p { "{t(l, \"privacy.storage_text\")}" }

                h2 { "{t(l, \"privacy.rights_title\")}" }
                p { "{t(l, \"privacy.rights_intro\")}" }
                ul {
                    li { "{t(l, \"privacy.rights_access\")}" }
                    li { "{t(l, \"privacy.rights_rectify\")}" }
                    li { "{t(l, \"privacy.rights_erasure\")}" }
                    li { "{t(l, \"privacy.rights_restrict\")}" }
                    li { "{t(l, \"privacy.rights_portability\")}" }
                    li { "{t(l, \"privacy.rights_complaint\")}" }
                }

                h2 { "{t(l, \"privacy.contact_title\")}" }
                p { "{t(l, \"privacy.contact_text\")}" }
            }
            footer { class: "legal-footer",
                Link { to: Route::LandingPage {}, "{t(l, \"common.back_to_home\")}" }
                Link { to: Route::ImpressumPage {}, "{t(l, \"common.impressum\")}" }
            }
        }
    }
}
