from __future__ import annotations
from typing import Callable, Optional

# Element

class Element:
    def __init__(self, element_type: Optional[str] = ...) -> None: ...
    def to_json(self) -> str: ...
    def __repr__(self) -> str: ...

# ElementBuilder

class ElementBuilder:
    # Factory methods
    @staticmethod
    def div() -> ElementBuilder: ...
    @staticmethod
    def text(content: str) -> ElementBuilder: ...
    @staticmethod
    def button(label: str) -> ElementBuilder: ...
    @staticmethod
    def image(src: str) -> ElementBuilder: ...
    @staticmethod
    def input() -> ElementBuilder: ...

    # Layout
    def width(self, w: float) -> ElementBuilder: ...
    def height(self, h: float) -> ElementBuilder: ...
    def size(self, w: float, h: float) -> ElementBuilder: ...
    def size_full(self) -> ElementBuilder: ...

    def v_flex(self) -> ElementBuilder: ...
    def h_flex(self) -> ElementBuilder: ...
    def items_center(self) -> ElementBuilder: ...
    def justify_center(self) -> ElementBuilder: ...
    def justify_between(self) -> ElementBuilder: ...

    def gap(self, g: float) -> ElementBuilder: ...

    # Padding/Margin
    def padding(self, y: float, x: Optional[float] = ...) -> ElementBuilder: ...
    def p(self, y: float, x: Optional[float] = ...) -> ElementBuilder: ...
    def pt(self, p: float) -> ElementBuilder: ...
    def pr(self, p: float) -> ElementBuilder: ...
    def pb(self, p: float) -> ElementBuilder: ...
    def pl(self, p: float) -> ElementBuilder: ...
    def px(self, p: float) -> ElementBuilder: ...
    def py(self, p: float) -> ElementBuilder: ...

    def margin(self, m: float) -> ElementBuilder: ...
    def m(self, m: float) -> ElementBuilder: ...

    # Styling
    def bg(self, color: str) -> ElementBuilder: ...
    def text_color(self, color: str) -> ElementBuilder: ...
    def rounded(self, radius: float) -> ElementBuilder: ...
    def border(self, width: float, color: str) -> ElementBuilder: ...
    def b(self, color: str) -> ElementBuilder: ...

    def style(self, css: str) -> ElementBuilder: ...

    def overflow_hidden(self) -> ElementBuilder: ...
    def overflow(self, value: str) -> ElementBuilder: ...

    def text_align(self, align: str) -> ElementBuilder: ...
    def text_center(self) -> ElementBuilder: ...
    def word_wrap(self, value: str) -> ElementBuilder: ...

    # Transitions and effects
    def transition(self, value: str) -> ElementBuilder: ...
    def transition_all(self, seconds: float) -> ElementBuilder: ...
    def transition_colors(self, seconds: float) -> ElementBuilder: ...
    def transition_transform(self, seconds: float) -> ElementBuilder: ...
    def opacity(self, value: float) -> ElementBuilder: ...
    def cursor(self, value: str) -> ElementBuilder: ...

    # Hover styles
    def hover_bg(self, color: str) -> ElementBuilder: ...
    def hover_text_color(self, color: str) -> ElementBuilder: ...
    def hover_border_color(self, color: str) -> ElementBuilder: ...
    def hover_opacity(self, value: float) -> ElementBuilder: ...
    def hover_scale(self, value: float) -> ElementBuilder: ...

    # Focus styles
    def focus_bg(self, color: str) -> ElementBuilder: ...
    def focus_text_color(self, color: str) -> ElementBuilder: ...
    def focus_border_color(self, color: str) -> ElementBuilder: ...

    # Image properties
    def alt(self, text: str) -> ElementBuilder: ...
    def object_fit(self, value: str) -> ElementBuilder: ...

    # Positioning
    def position(self, value: str) -> ElementBuilder: ...
    def absolute(self) -> ElementBuilder: ...
    def relative(self) -> ElementBuilder: ...
    def top(self, value: float) -> ElementBuilder: ...
    def right(self, value: float) -> ElementBuilder: ...
    def bottom(self, value: float) -> ElementBuilder: ...
    def left(self, value: float) -> ElementBuilder: ...

    # Text
    def text_size(self, size: float) -> ElementBuilder: ...
    def text_weight(self, weight: str) -> ElementBuilder: ...

    # Children
    def child(self, child: Element) -> ElementBuilder: ...
    def child_builder(self, child: ElementBuilder) -> ElementBuilder: ...
    def child_text(self, text: str) -> ElementBuilder: ...

    # Interactivity
    def on_click(self, callback: Callable[[], None]) -> ElementBuilder: ...
    def on_input(self, callback: Callable[[str], None]) -> ElementBuilder: ...
    def on_mouse_enter(self, callback: Callable[[], None]) -> ElementBuilder: ...
    def on_mouse_leave(self, callback: Callable[[], None]) -> ElementBuilder: ...
    def on_mouse_down(self, callback: Callable[[], None]) -> ElementBuilder: ...
    def on_mouse_up(self, callback: Callable[[], None]) -> ElementBuilder: ...

    def value(self, val: str) -> ElementBuilder: ...
    def placeholder(self, text: str) -> ElementBuilder: ...

    # Final
    def build(self) -> Element: ...
    def __repr__(self) -> str: ...

# UiWindow
class AppBase:
    def __init__(self) -> None: ...
    def set_window(self, window: "UiWindow") -> None: ...
    def render(self) -> None: ...
    def run(self) -> None: ...
    def set_root(self, element) -> None: ...
    def on_start(self) -> None: ...
    def on_close(self) -> None: ...

class UiWindow:
    def __init__(
        self,
        title: Optional[str] = ...,
        width: Optional[int] = ...,
        height: Optional[int] = ...,
        background_color: Optional[str] = ...,
    ) -> None: ...

    def set_root(self, element: Element) -> None: ...
    def set_title(self, title: str) -> None: ...
    def run(self) -> None: ...
    def close(self) -> None: ...
    def is_running(self) -> bool: ...
    def __repr__(self) -> str: ...

# Convenience functions

def div() -> ElementBuilder: ...
def text(content: str) -> ElementBuilder: ...
def button(label: str) -> ElementBuilder: ...
def image(src: str) -> ElementBuilder: ...
def input() -> ElementBuilder: ...