use eframe::egui;
use rust_i18n::t;
use crate::installer::{GlobalState, InstallerStep};
use crate::ui::theme;

pub struct FinishStep;

impl InstallerStep for FinishStep {
    fn name(&self) -> String { t!("finish").to_string() }

    fn show(&mut self, ui: &mut egui::Ui, _state: &mut GlobalState) {
        ui.add_space(32.0);
        ui.vertical_centered(|ui| {
            // Büyük onay simgesi
            ui.label(
                egui::RichText::new("✔")
                    .size(72.0)
                    .color(theme::c_success()),
            );
            ui.add_space(16.0);

            ui.label(
                egui::RichText::new(t!("finish_title"))
                    .size(24.0)
                    .strong()
                    .color(theme::c_text()),
            );
            ui.add_space(8.0);
            ui.label(
                egui::RichText::new(t!("finish_description"))
                    .size(14.0)
                    .color(theme::c_text_dim()),
            );

            ui.add_space(32.0);

            // Yeniden Başlat — ana eylem butonu
            if ui.add(
                theme::primary_button(&t!("finish_restart"))
                    .min_size(egui::vec2(200.0, 44.0)),
            ).clicked() {
                let _ = std::process::Command::new("systemctl")
                    .arg("reboot")
                    .spawn();
            }

            ui.add_space(12.0);

            // Canlı masaüstüne dön — ikincil eylem
            if ui.add(
                theme::secondary_button(&t!("finish_live"))
                    .min_size(egui::vec2(200.0, 36.0)),
            ).clicked() {
                ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
            }
        });
    }

    fn is_complete(&self, _state: &GlobalState) -> bool { true }
}
