#!/usr/bin/env python3
"""
Unparty Styles - Python Access to Centralized Styling

This module provides Python access to the centralized styling system defined
in unparty_styles.sh. It's the Python companion to the shell styling library.

Usage:
    from unparty.styles import Colors, print_success, print_error
    
    print_success("Operation completed")
    print(f"{Colors.BRAND}Branded text{Colors.END}")

Version: 31.1.0
Last Updated: 2026-08-09
Source of Truth: unparty_styles.sh (versions must stay in sync)
"""

__version__ = "31.1.0"


class Colors:
    """
    ANSI color codes matching unparty_styles.sh
    
    This class mirrors the color definitions from unparty_styles.sh to ensure
    consistency across shell and Python scripts.
    
    Source of Truth: unparty_styles.sh
    """
    
    # Basic colors (matching unparty_styles.sh lines 18-25)
    RED = '\033[0;31m'
    GREEN = '\033[0;32m'
    YELLOW = '\033[1;33m'  # Note: Already bright by default
    BLUE = '\033[0;34m'
    PURPLE = '\033[0;35m'
    CYAN = '\033[0;36m'
    WHITE = '\033[1;37m'
    NC = '\033[0m'  # No Color / End
    END = '\033[0m'  # Alias for NC
    
    # Bright variants (matching unparty_styles.sh lines 28-34)
    # Note: YELLOW is already bright, so BRIGHT_YELLOW is identical
    BRIGHT_RED = '\033[1;31m'
    BRIGHT_GREEN = '\033[1;32m'
    BRIGHT_YELLOW = '\033[1;33m'  # Same as YELLOW
    BRIGHT_BLUE = '\033[1;34m'
    BRIGHT_PURPLE = '\033[1;35m'
    BRIGHT_CYAN = '\033[1;36m'
    BRIGHT_WHITE = '\033[1;37m'
    
    # Unparty brand colors (matching unparty_styles.sh lines 37-39)
    BRAND = '\033[38;2;249;194;46m'    # #f9c22e (official unparty yellow) - Primary
    BRAND_COLOR = '\033[38;2;249;194;46m'  # Alias for BRAND (backward compatibility)
    BRAND_LIGHT = '\033[38;2;252;207;77m'
    BRAND_DARK = '\033[38;2;204;159;38m'
    
    # Style modifiers (matching unparty_styles.sh lines 42-45)
    BOLD = '\033[1m'
    DIM = '\033[2m'
    UNDERLINE = '\033[4m'
    REVERSE = '\033[7m'
    
    # Background colors (matching unparty_styles.sh lines 48-54)
    BG_RED = '\033[41m'
    BG_GREEN = '\033[42m'
    BG_YELLOW = '\033[43m'
    BG_BLUE = '\033[44m'
    BG_PURPLE = '\033[45m'
    BG_CYAN = '\033[46m'
    BG_WHITE = '\033[47m'
    
    # Custom RGB colors (matching unparty_styles.sh lines 57-60)
    DARK_THEME_BG = '\033[48;2;10;10;10m'      # #0a0a0a
    DARK_THEME_FG = '\033[38;2;237;237;237m'   # #ededed
    ACCENT_ORANGE = '\033[38;2;255;165;0m'     # #ffa500
    ACCENT_PINK = '\033[38;2;255;20;147m'      # #ff1493
    
    # Legacy aliases for backward compatibility
    HEADER = PURPLE  # Used in some older scripts
    

class Icons:
    """Unicode emoji icons for consistent visual branding"""
    
    # Status icons
    SUCCESS = '🪩'
    ERROR = '❌'
    WARNING = '👾'
    INFO = '📌'
    ACTION = '🚀'
    DATE = '📅'
    
    # Content type icons
    FILE = '📁'
    SCRIPT = '📚'
    FUNCTION = '🎯'
    CATEGORY = '📊'
    PATTERN = '💡'
    SEMANTIC = '🧠'
    EXACT = '🎯'
    CACHED = '💾'
    SUNSET = '🌅'
    DATA = '📋'
    DOCUMENT = '📄'


def colorize(color: str, text: str) -> str:
    """
    Wrap text with color codes.
    
    Args:
        color: ANSI color code from Colors class
        text: Text to colorize
        
    Returns:
        Colored text string
    """
    return f"{color}{text}{Colors.END}"


def print_success(message: str) -> None:
    """Print success message with branding (matches unparty_success)"""
    print(f"{Colors.GREEN}{Icons.SUCCESS}{Colors.END} {Colors.WHITE}{message}{Colors.END}")


def print_error(message: str) -> None:
    """Print error message with branding (matches unparty_error)"""
    print(f"{Colors.RED}{Icons.ERROR}{Colors.END} {Colors.WHITE}{message}{Colors.END}")


def print_warning(message: str) -> None:
    """Print warning message with branding (matches unparty_warning)"""
    print(f"{Colors.YELLOW}{Icons.WARNING}{Colors.END} {Colors.ACCENT_ORANGE}{message}{Colors.END}")


def print_info(message: str) -> None:
    """Print info message with branding (matches unparty_info)"""
    print(f"{Colors.BLUE}{Icons.INFO}{Colors.END} {Colors.WHITE}{message}{Colors.END}")


def print_action(message: str) -> None:
    """Print action message with branding (matches unparty_action)"""
    print(f"{Colors.BRAND}{Icons.ACTION}{Colors.END} {Colors.WHITE}{message}{Colors.END}")


def print_date(message: str) -> None:
    """Print date message with branding (matches unparty_date)"""
    print(f"{Colors.BLUE}{Icons.DATE}{Colors.END} {Colors.BRIGHT_PURPLE}{message}{Colors.END}")


def print_section(title: str) -> None:
    """Print section header (matches unparty_section)"""
    print()
    print(f"{Colors.BRAND}═══{Colors.END} {Colors.BOLD}{Colors.WHITE}{title}{Colors.END} {Colors.BRAND}═══{Colors.END}")
    print()


def print_subsection(title: str) -> None:
    """Print subsection header (matches unparty_subsection)"""
    print(f"{Colors.WHITE}## {title}{Colors.END}")


def print_key_value(key: str, value: str, indent: int = 0) -> None:
    """Print key-value pair (matches unparty_key_value)"""
    spaces = "  " * indent
    print(f"{spaces}{Colors.CYAN}{key}:{Colors.END} {Colors.WHITE}{value}{Colors.END}")


def print_list_item(text: str, indent: int = 0, bullet: str = "•") -> None:
    """Print list item (matches unparty_list_item)"""
    spaces = "  " * indent
    print(f"{spaces}{Colors.PURPLE}{bullet}{Colors.END} {Colors.WHITE}{text}{Colors.END}")


def print_brand_item(text: str, indent: int = 0) -> None:
    """Print branded list item (matches unparty_brand_item)"""
    spaces = "  " * indent
    print(f"{spaces}{Colors.BRAND}▶{Colors.END} {Colors.WHITE}{text}{Colors.END}")


def print_divider() -> None:
    """Print full divider (matches unparty_divider)"""
    print(f"{Colors.BRAND}{'=' * 60}{Colors.END}")


def print_light_divider() -> None:
    """Print light divider (matches unparty_light_divider)"""
    print(f"{Colors.CYAN}{'─' * 60}{Colors.END}")


# Timing constants (matching unparty_styles.sh lines 430-434)
INSTANT = 0.05
QUICK = 0.1
NORMAL = 0.3
DRAMATIC = 0.5
SLOW = 1.0


# Export all for convenience
__all__ = [
    'Colors',
    'Icons',
    'colorize',
    'print_success',
    'print_error',
    'print_warning',
    'print_info',
    'print_action',
    'print_date',
    'print_section',
    'print_subsection',
    'print_key_value',
    'print_list_item',
    'print_brand_item',
    'print_divider',
    'print_light_divider',
    'INSTANT',
    'QUICK',
    'NORMAL',
    'DRAMATIC',
    'SLOW',
]
