"""Default brand configurations for common use cases."""

from __future__ import annotations

from pptx_mcp.models.brand import (
    BrandConfig,
    ColorPalette,
    FontConfig,
    LayoutRules,
    SpacingConfig,
    ToneStyle,
)


def executive_default() -> BrandConfig:
    """Clean executive style suitable for C-suite presentations."""
    return BrandConfig(
        name="Executive Default",
        colors=ColorPalette(
            primary="#1B2A4A",
            secondary="#2D5F8A",
            accent="#E8913A",
            background="#FFFFFF",
            text_primary="#1A1A2E",
            text_secondary="#5A5A6E",
            success="#2E7D32",
            danger="#C62828",
            chart_colors=["#1B2A4A", "#2D5F8A", "#E8913A", "#6B8E23", "#8B4513", "#4682B4"],
        ),
        fonts=FontConfig(
            heading_font="Calibri",
            body_font="Calibri",
            title_size=36,
            heading_size=28,
            subheading_size=20,
            body_size=16,
            caption_size=11,
            line_spacing=1.15,
        ),
        spacing=SpacingConfig(
            margin_left=0.75,
            margin_right=0.75,
            margin_top=0.75,
            margin_bottom=0.5,
            title_top=0.4,
            content_top=1.6,
            element_gap=0.3,
            column_gap=0.5,
            padding=0.2,
        ),
        layout_rules=LayoutRules(
            max_bullets_per_slide=5,
            max_words_per_bullet=12,
            max_words_per_slide=60,
            min_font_size=14,
            prefer_visual_balance=True,
            use_accent_sparingly=True,
            title_every_slide=True,
        ),
        tone=ToneStyle.EXECUTIVE,
    )


def technical_default() -> BrandConfig:
    """Technical style for engineering and product presentations."""
    return BrandConfig(
        name="Technical Default",
        colors=ColorPalette(
            primary="#263238",
            secondary="#37474F",
            accent="#00BCD4",
            background="#FAFAFA",
            text_primary="#212121",
            text_secondary="#616161",
            success="#4CAF50",
            danger="#F44336",
            chart_colors=["#00BCD4", "#FF9800", "#4CAF50", "#E91E63", "#9C27B0", "#3F51B5"],
        ),
        fonts=FontConfig(
            heading_font="Segoe UI",
            body_font="Segoe UI",
            mono_font="Cascadia Code",
            title_size=32,
            heading_size=24,
            subheading_size=18,
            body_size=14,
            caption_size=10,
            line_spacing=1.3,
        ),
        layout_rules=LayoutRules(
            max_bullets_per_slide=7,
            max_words_per_bullet=18,
            max_words_per_slide=100,
            min_font_size=12,
        ),
        tone=ToneStyle.TECHNICAL,
    )


def minimal_default() -> BrandConfig:
    """Minimal, high-contrast style with generous whitespace."""
    return BrandConfig(
        name="Minimal Default",
        colors=ColorPalette(
            primary="#111111",
            secondary="#333333",
            accent="#FF4444",
            background="#FFFFFF",
            text_primary="#111111",
            text_secondary="#666666",
            chart_colors=["#111111", "#FF4444", "#888888", "#CCCCCC"],
        ),
        fonts=FontConfig(
            heading_font="Arial",
            body_font="Arial",
            title_size=40,
            heading_size=32,
            subheading_size=22,
            body_size=18,
            caption_size=12,
            line_spacing=1.4,
        ),
        spacing=SpacingConfig(
            margin_left=1.0,
            margin_right=1.0,
            margin_top=1.0,
            margin_bottom=0.75,
            content_top=2.0,
            element_gap=0.4,
            column_gap=0.6,
        ),
        layout_rules=LayoutRules(
            max_bullets_per_slide=4,
            max_words_per_bullet=10,
            max_words_per_slide=40,
            min_font_size=16,
        ),
        tone=ToneStyle.MINIMAL,
    )


def creative_default() -> BrandConfig:
    """Bold, colorful style for creative and marketing presentations."""
    return BrandConfig(
        name="Creative Default",
        colors=ColorPalette(
            primary="#6B21A8",
            secondary="#2563EB",
            accent="#F59E0B",
            background="#FFFFFF",
            text_primary="#1E1B4B",
            text_secondary="#6B7280",
            success="#059669",
            danger="#DC2626",
            chart_colors=["#6B21A8", "#2563EB", "#F59E0B", "#059669", "#EC4899", "#14B8A6"],
        ),
        fonts=FontConfig(
            heading_font="Georgia",
            body_font="Calibri",
            title_size=38,
            heading_size=30,
            subheading_size=22,
            body_size=16,
            caption_size=11,
            line_spacing=1.25,
        ),
        spacing=SpacingConfig(
            margin_left=0.9,
            margin_right=0.9,
            margin_top=0.9,
            margin_bottom=0.6,
            title_top=0.45,
            content_top=1.7,
            element_gap=0.35,
            column_gap=0.5,
            padding=0.25,
        ),
        layout_rules=LayoutRules(
            max_bullets_per_slide=5,
            max_words_per_bullet=14,
            max_words_per_slide=65,
            min_font_size=14,
        ),
        tone=ToneStyle.CREATIVE,
    )


def corporate_default() -> BrandConfig:
    """Conservative corporate style for formal business presentations."""
    return BrandConfig(
        name="Corporate Default",
        colors=ColorPalette(
            primary="#1E3A5F",
            secondary="#4A6FA5",
            accent="#C9A84C",
            background="#FFFFFF",
            text_primary="#1A1A1A",
            text_secondary="#555555",
            success="#2E7D32",
            danger="#B71C1C",
            chart_colors=["#1E3A5F", "#4A6FA5", "#C9A84C", "#2E7D32", "#8D6E63", "#546E7A"],
        ),
        fonts=FontConfig(
            heading_font="Times New Roman",
            body_font="Calibri",
            title_size=34,
            heading_size=26,
            subheading_size=19,
            body_size=15,
            caption_size=10,
            line_spacing=1.2,
        ),
        spacing=SpacingConfig(
            margin_left=0.8,
            margin_right=0.8,
            margin_top=0.8,
            margin_bottom=0.5,
            title_top=0.4,
            content_top=1.6,
            element_gap=0.3,
            column_gap=0.45,
            padding=0.2,
        ),
        layout_rules=LayoutRules(
            max_bullets_per_slide=6,
            max_words_per_bullet=15,
            max_words_per_slide=80,
            min_font_size=12,
        ),
        tone=ToneStyle.CORPORATE,
    )


PRESETS: dict[str, BrandConfig] = {
    "executive": executive_default(),
    "technical": technical_default(),
    "minimal": minimal_default(),
    "creative": creative_default(),
    "corporate": corporate_default(),
}


def get_preset(name: str) -> BrandConfig:
    """Get a preset brand configuration by name.

    Args:
        name: Preset name ("executive", "technical", "minimal").

    Returns:
        BrandConfig for the requested preset.

    Raises:
        KeyError: If preset name is not found.
    """
    if name not in PRESETS:
        available = ", ".join(PRESETS.keys())
        raise KeyError(f"Unknown preset '{name}'. Available: {available}")
    return PRESETS[name].model_copy(deep=True)
