import tkinter as tk

from ui import styles


class SummaryPanel(tk.Frame):
    """Panel de texto deshabilitado para mostrar el resumen de sync."""

    def __init__(self, parent, **kwargs):
        super().__init__(parent, **kwargs)

        tk.Label(self, text="Resumen:", font=styles.FONT_LABEL).pack(pady=(6, 2))

        self._text = tk.Text(
            self,
            height=10,
            state="disabled",
            bg=styles.SUMMARY_BG,
            fg=styles.SUMMARY_FG,
            font=styles.FONT_MONO,
        )
        self._text.pack(fill="both", expand=True, padx=styles.PAD_X, pady=styles.PAD_Y)

    def append(self, line: str) -> None:
        self._text.configure(state="normal")
        self._text.insert(tk.END, line + "\n")
        self._text.see(tk.END)
        self._text.configure(state="disabled")

    def clear(self) -> None:
        self._text.configure(state="normal")
        self._text.delete(1.0, tk.END)
        self._text.configure(state="disabled")
