from typing import Tuple
from dataclasses import dataclass, field

from pyWebLayout.style.alignment import Alignment


@dataclass
class PageStyle:
    """
    Defines the styling properties for a page including borders, spacing, and layout.
    """

    # Alignment applied to body text that does not specify its own. Headings are
    # never justified regardless of this setting.
    default_alignment: Alignment = Alignment.JUSTIFY

    # Border properties
    border_width: int = 0
    border_color: Tuple[int, int, int] = (0, 0, 0)

    # Spacing properties
    line_spacing: int = 5  # Additional pixels between lines (added to font size)
    inter_block_spacing: int = 15  # Pixels between blocks (paragraphs, headings, etc.)
    word_spacing: int = 0  # Additional pixels between words (0 = use font defaults)

    # Padding (top, right, bottom, left)
    padding: Tuple[int, int, int, int] = (20, 20, 20, 20)

    # Background color
    background_color: Tuple[int, int, int] = (255, 255, 255)

    # Typography properties
    max_font_size: int = 72  # Maximum font size allowed on a page

    @property
    def padding_top(self) -> int:
        return self.padding[0]

    @property
    def padding_right(self) -> int:
        return self.padding[1]

    @property
    def padding_bottom(self) -> int:
        return self.padding[2]

    @property
    def padding_left(self) -> int:
        return self.padding[3]

    @property
    def total_horizontal_padding(self) -> int:
        """Get total horizontal padding (left + right)"""
        return self.padding_left + self.padding_right

    @property
    def total_vertical_padding(self) -> int:
        """Get total vertical padding (top + bottom)"""
        return self.padding_top + self.padding_bottom

    @property
    def total_border_width(self) -> int:
        """Get total border width (both sides)"""
        return self.border_width * 2
