package com.example.notesai.util

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color

object AppColors {
    // Theme state
    private var isDarkTheme by mutableStateOf(true)

    // Primary Colors
    val Primary: Color
        get() = if (isDarkTheme) Color(0xFF6C63FF) else Color(0xFF5A52D5)

    val Secondary: Color
        get() = if (isDarkTheme) Color(0xFF03DAC6) else Color(0xFF018786)

    val Accent: Color
        get() = if (isDarkTheme) Color(0xFFFF6B9D) else Color(0xFFE91E63)

    // Background Colors
    val Background: Color
        get() = if (isDarkTheme) Color(0xFF121212) else Color(0xFFFAFAFA)

    val Surface: Color
        get() = if (isDarkTheme) Color(0xFF1E1E1E) else Color(0xFFFFFFFF)

    val SurfaceVariant: Color
        get() = if (isDarkTheme) Color(0xFF2A2A2A) else Color(0xFFF5F5F5)

    val SurfaceElevated: Color
        get() = if (isDarkTheme) Color(0xFF252525) else Color(0xFFFFFFFF)

    // Text Colors
    val OnBackground: Color
        get() = if (isDarkTheme) Color(0xFFE1E1E1) else Color(0xFF1C1B1F)

    val OnSurface: Color
        get() = if (isDarkTheme) Color(0xFFCCCCCC) else Color(0xFF1C1B1F)

    val OnSurfaceVariant: Color
        get() = if (isDarkTheme) Color(0xFF9E9E9E) else Color(0xFF49454F)

    val OnSurfaceTertiary: Color
        get() = if (isDarkTheme) Color(0xFF757575) else Color(0xFF79747E)

    // Utility Colors
    val Error: Color
        get() = if (isDarkTheme) Color(0xFFCF6679) else Color(0xFFB3261E)

    val Warning: Color
        get() = if (isDarkTheme) Color(0xFFFFB74D) else Color(0xFFF57C00)

    val Success: Color
        get() = if (isDarkTheme) Color(0xFF81C784) else Color(0xFF388E3C)

    val Info: Color
        get() = if (isDarkTheme) Color(0xFF64B5F6) else Color(0xFF1976D2)

    // Border & Divider
    val Border: Color
        get() = if (isDarkTheme) Color(0xFF3A3A3A) else Color(0xFFE0E0E0)

    val Divider: Color
        get() = if (isDarkTheme) Color(0xFF2E2E2E) else Color(0xFFE0E0E0)

    // Function to update theme
    fun setTheme(darkTheme: Boolean) {
        isDarkTheme = darkTheme
    }

    // Get current theme state
    fun isDark(): Boolean = isDarkTheme
}

object Constants {

    // Animation Durations
    const val ANIMATION_DURATION_SHORT = 150
    const val ANIMATION_DURATION_MEDIUM = 300
    const val ANIMATION_DURATION_LONG = 500

    // Spacing values
    object Spacing {
        const val ExtraSmall = 4
        const val Small = 8
        const val Medium = 12
        const val Large = 16
        const val ExtraLarge = 24
        const val ExtraExtraLarge = 32
    }

    // Border Radius values
    object Radius {
        const val Small = 8
        const val Medium = 12
        const val Large = 16
        const val ExtraLarge = 24
        const val ExtraExtraLarge = 32
    }

    // Elevation values
    object Elevation {
        const val None = 0
        const val Small = 2
        const val Medium = 4
        const val Large = 8
        const val ExtraLarge = 12
    }

    // Reference to AppColors for compatibility
    val AppColors = com.example.notesai.util.AppColors

    // Category gradient colors - 8 pilihan warna
    val CategoryColors = listOf(
        // Purple gradient
        0xFF6750A4L to 0xFF7E57C2L,

        // Pink gradient
        0xFF9C27B0L to 0xFFE91E63L,

        // Blue gradient
        0xFF2196F3L to 0xFF03A9F4L,

        // Green gradient
        0xFF4CAF50L to 0xFF8BC34AL,

        // Orange gradient
        0xFFFF9800L to 0xFFFFB74DL,

        // Red gradient
        0xFFF44336L to 0xFFE91E63L,

        // Teal gradient
        0xFF009688L to 0xFF26A69AL,

        // Indigo gradient
        0xFF3F51B5L to 0xFF5C6BC0L
    )
}