"""
Shared configuration for TapIN MMA.

Contains:
- Weight class display labels and parsing helpers
- Theme definitions used across the app
"""


import re
from typing import Dict, Optional, List, Tuple

# ---------------------------------------------------------
# Weight classes
# ---------------------------------------------------------
MEN_DIVS: List[Tuple[str, int]] = [
    ("Flyweight", 125),
    ("Bantamweight", 135),
    ("Featherweight", 145),
    ("Lightweight", 155),
    ("Welterweight", 170),
    ("Middleweight", 185),
    ("Light Heavyweight", 205),
    ("Heavyweight", 265),
]

WOMEN_DIVS: List[Tuple[str, int]] = [
    ("Strawweight", 115),
    ("Flyweight", 125),
    ("Bantamweight", 135),
]

MEN_LABELS = [f"Men's {n} - {w} lbs" for n, w in MEN_DIVS]
WOMEN_LABELS = [f"Women's {n} - {w} lbs" for n, w in WOMEN_DIVS]
DISPLAY_WEIGHT_CLASSES = ["All"] + MEN_LABELS + WOMEN_LABELS


def base_class_from_label(label: str) -> Optional[str]:
    if label == "All":
        return None
    m = re.search(r"(Men|Women)'s\s+(.+?)\s+-\s+\d+\s+lbs", label)
    if m:
        return m.group(2).strip()
    return label


# ---------------------------------------------------------
# Theme palette
# ---------------------------------------------------------
THEMES: Dict[str, Dict[str, str]] = {
    "Dark": {
        "--bg": "#0e1117",
        "--text": "#f5f7fa",
        "--card": "#161a22",
        "--accent": "#22c55e",
    },
    "Light": {
        "--bg": "#ffffff",
        "--text": "#0f172a",
        "--card": "#f8fafc",
        "--accent": "#0ea5e9",
    },
    "Octagon Red": {
        "--bg": "#1a0f0f",
        "--text": "#ffeeee",
        "--card": "#2b1515",
        "--accent": "#ef4444",
    },
    "Mat Blue": {
        "--bg": "#0b1220",
        "--text": "#dbeafe",
        "--card": "#101826",
        "--accent": "#3b82f6",
    },
}
