package com.radiola.ui.theme

import androidx.compose.ui.graphics.Color
import com.radiola.R

/**
 * Цветовые темы приложения. radiOLA всегда тёмная — палитры различаются оттенком
 * фона, акцентом и брендовым градиентом. Выбор хранится по [id] в настройках
 * (`SettingsRepository.getThemePalette`), применяется в `RadiolaTheme`.
 *
 * Все цвета берутся компонентами через `RadiolaTheme.colors` / `MaterialTheme.colorScheme`,
 * поэтому смена палитры перекрашивает приложение мгновенно.
 */
enum class ThemePalette(
    val id: String,
    val title: String,
    val colors: RadiolaColors,
) {
    // Фирменная зелёная (по умолчанию) — берёт значения из Color.kt.
    FOREST(
        "forest", "Лес",
        RadiolaColors(
            bgBase = BgBase, surface = BgSurface, surface2 = BgSurface2, elevated = BgElevated,
            accent = Accent, accentDim = AccentDim,
            textPrimary = TextPrimary, textSecondary = TextSecondary, textMuted = TextMuted,
            border = BorderColor, live = LiveRed,
            gradientStart = BrandGradientStart, gradientEnd = BrandGradientEnd,
        ),
    ),

    // Глубокий сине-бирюзовый, акцент циан.
    OCEAN(
        "ocean", "Океан",
        RadiolaColors(
            bgBase = Color(0xFF0A0F1A), surface = Color(0xFF121A2A), surface2 = Color(0xFF1A2438), elevated = Color(0xFF222F47),
            accent = Color(0xFF4FD6E0), accentDim = Color(0xFF2E8E9A),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFF8F9DB3), textMuted = Color(0xFF5C6A82),
            border = Color(0xFF26324A), live = Color(0xFFFF5C7A),
            gradientStart = Color(0xFF5BE1F2), gradientEnd = Color(0xFF3A7BD5),
        ),
    ),

    // Тёплый тёмный, коралл/оранжевый.
    SUNSET(
        "sunset", "Закат",
        RadiolaColors(
            bgBase = Color(0xFF1A0F0C), surface = Color(0xFF261712), surface2 = Color(0xFF33201A), elevated = Color(0xFF422A22),
            accent = Color(0xFFFF8A5B), accentDim = Color(0xFFC55E3A),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFFB39A8F), textMuted = Color(0xFF82675C),
            border = Color(0xFF4A322A), live = Color(0xFFFF4D6D),
            gradientStart = Color(0xFFFFB36B), gradientEnd = Color(0xFFFF6B5B),
        ),
    ),

    // Тёмно-фиолетовый, акцент сирень.
    AMETHYST(
        "amethyst", "Аметист",
        RadiolaColors(
            bgBase = Color(0xFF120E1A), surface = Color(0xFF1C1528), surface2 = Color(0xFF271D38), elevated = Color(0xFF332747),
            accent = Color(0xFFB388FF), accentDim = Color(0xFF7E5BC5),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFFA095B3), textMuted = Color(0xFF6E5C82),
            border = Color(0xFF372A4A), live = Color(0xFFFF5C9D),
            gradientStart = Color(0xFFC9A6FF), gradientEnd = Color(0xFF8B5BD5),
        ),
    ),

    // Почти чёрный, неоновый розово-малиновый (киберпанк).
    NEON(
        "neon", "Неон",
        RadiolaColors(
            bgBase = Color(0xFF0D0A12), surface = Color(0xFF16111E), surface2 = Color(0xFF1F1729), elevated = Color(0xFF2A1F38),
            accent = Color(0xFFFF4D9D), accentDim = Color(0xFFC53A75),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFFB095A6), textMuted = Color(0xFF7C5C6E),
            border = Color(0xFF3A2A33), live = Color(0xFFFF3D5C),
            gradientStart = Color(0xFFFF5BD0), gradientEnd = Color(0xFFFF4D7A),
        ),
    ),

    // Тёплый уголь, золотой акцент.
    AMBER(
        "amber", "Янтарь",
        RadiolaColors(
            bgBase = Color(0xFF14110A), surface = Color(0xFF201A10), surface2 = Color(0xFF2C2418), elevated = Color(0xFF392F20),
            accent = Color(0xFFFFC247), accentDim = Color(0xFFC5902E),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFFB3A88F), textMuted = Color(0xFF82765C),
            border = Color(0xFF4A3F2A), live = Color(0xFFFF5C52),
            gradientStart = Color(0xFFFFD66B), gradientEnd = Color(0xFFFF9F45),
        ),
    ),

    // Холодный графит, ледяной голубой.
    ICE(
        "ice", "Лёд",
        RadiolaColors(
            bgBase = Color(0xFF0C1014), surface = Color(0xFF161C22), surface2 = Color(0xFF202830), elevated = Color(0xFF2C3640),
            accent = Color(0xFF7FB3FF), accentDim = Color(0xFF4F7CC5),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFF95A3B3), textMuted = Color(0xFF5C6A7C),
            border = Color(0xFF2A3540), live = Color(0xFFFF6B6B),
            gradientStart = Color(0xFFA6D0FF), gradientEnd = Color(0xFF6B9FFF),
        ),
    ),

    // Тёмная мальва, розовый акцент.
    ROSE(
        "rose", "Роза",
        RadiolaColors(
            bgBase = Color(0xFF160E12), surface = Color(0xFF22151B), surface2 = Color(0xFF2E1E26), elevated = Color(0xFF3C2A33),
            accent = Color(0xFFFF7EA8), accentDim = Color(0xFFC5547A),
            textPrimary = Color(0xFFFFFFFF), textSecondary = Color(0xFFB395A0), textMuted = Color(0xFF825C6A),
            border = Color(0xFF4A2A38), live = Color(0xFFFF4D6D),
            gradientStart = Color(0xFFFFA6C2), gradientEnd = Color(0xFFFF6B9F),
        ),
    ),
    ;

    /** Перекрашенный под эту тему 3D-логотип (drawable). */
    val logoRes: Int
        get() = when (this) {
            FOREST -> R.drawable.logo_forest
            OCEAN -> R.drawable.logo_ocean
            SUNSET -> R.drawable.logo_sunset
            AMETHYST -> R.drawable.logo_amethyst
            NEON -> R.drawable.logo_neon
            AMBER -> R.drawable.logo_amber
            ICE -> R.drawable.logo_ice
            ROSE -> R.drawable.logo_rose
        }

    companion object {
        /** Палитра по сохранённому id (фолбэк — «Лес»). */
        fun fromId(id: String?): ThemePalette = entries.firstOrNull { it.id == id } ?: FOREST
    }
}
