"""
GUI helpers — reusable widgets for form layout.
"""

import tkinter as tk
from tkinter import ttk


def section_frame(parent, title: str) -> ttk.LabelFrame:
    """Create a styled LabelFrame section."""
    frm = ttk.LabelFrame(parent, text=f"  {title}  ", padding=(16, 10))
    frm.pack(fill=tk.X, padx=16, pady=(12, 4))
    frm.columnconfigure(1, weight=1)
    return frm


def labeled_entry(
    parent,
    label: str,
    default: str = "",
    row: int = 0,
    show: str = "",
    width: int = 36,
) -> ttk.Entry:
    """Create a label + entry pair on *row* and return the Entry widget."""
    lbl = ttk.Label(parent, text=label, font=("Helvetica", 10))
    lbl.grid(row=row, column=0, sticky="w", padx=(0, 8), pady=3)

    entry = ttk.Entry(parent, width=width, show=show, font=("Menlo", 10))
    entry.insert(0, default)
    entry.grid(row=row, column=1, sticky="ew", pady=3)
    return entry
