"""
Theme Schema - Data structures for theme metadata.
"""

from dataclasses import dataclass
from pathlib import Path
from typing import Literal


# Required CSS variables that every theme must define
REQUIRED_VARIABLES: list[str] = [
    "--bg-primary",
    "--bg-secondary",
    "--bg-tertiary",
    "--accent-primary",
    "--accent-secondary",
    "--accent-tertiary",
    "--text-primary",
    "--text-secondary",
    "--text-muted",
    "--border-color",
    "--success-color",
    "--warning-color",
    "--error-color",
]

# RGB variants for rgba() usage
REQUIRED_RGB_VARIANTS: list[str] = [
    "--bg-primary-rgb",
    "--bg-secondary-rgb",
    "--bg-tertiary-rgb",
    "--accent-primary-rgb",
    "--accent-secondary-rgb",
    "--accent-tertiary-rgb",
    "--text-primary-rgb",
    "--text-secondary-rgb",
    "--text-muted-rgb",
    "--border-color-rgb",
    "--success-color-rgb",
    "--warning-color-rgb",
    "--error-color-rgb",
]

# Valid theme groups
ThemeGroup = Literal["core", "nature", "dev", "research", "system", "other"]

# Valid theme types (for luminance classification)
ThemeType = Literal["dark", "light"]


@dataclass
class ThemeMetadata:
    """Theme metadata extracted from CSS frontmatter."""

    id: str  # kebab-case identifier (e.g., "nord", "dracula")
    label: str  # Display label for UI (e.g., "Nord", "Dracula")
    icon: str  # FontAwesome icon class (e.g., "fa-snowflake")
    group: ThemeGroup  # Category for grouping in UI
    type: ThemeType = "dark"  # dark/light for luminance classification
    description: str = ""  # Optional description
    author: str = ""  # Optional author attribution
    css_path: Path | None = (
        None  # Path to CSS file (None for virtual themes like "system")
    )

    def to_dict(self) -> dict:
        """Convert to dictionary for JSON serialization."""
        return {
            "label": self.label,
            "icon": self.icon,
            "group": self.group,
            "type": self.type,
        }


# Group labels for UI display
GROUP_LABELS: dict[str, str] = {
    "core": "Core Themes",
    "nature": "Nature",
    "dev": "Developer Themes",
    "research": "Research & Reading",
    "system": "System",
    "other": "Other",
}
