<?php
$colors = [
    'header'     => [
        'banner' => [
            'light' => 'bg-gray-100 text-gray-200',
            'dark'  => 'bg-gray-600 text-gray-200',
        ],
    ],
    'anchor'     => [
        'primary' => [
            'light' => 'text-blue-400',
            'dark'  => 'text-blue-200',
        ],
    ],
    'body'       => [
        'light' => 'bg-white text-gray-600',
        'dark'  => 'bg-gray-800 text-gray-300',
    ],
    'button'     => [
        'primary'  => [
            'light' => 'border-blue-400 bg-blue-400 hover:bg-blue-600 text-white',
            'dark'  => 'border-blue-600 hover:border-blue-800 bg-blue-600 hover:bg-blue-800 text-white',
        ],
        'default'  => [
            'light' => 'bg-gray-200 hover:bg-gray-300 text-gray-800',
            'dark'  => 'bg-gray-200 hover:bg-gray-300 text-gray-800',
        ],
        'danger'   => [
            'light' => 'border-red-400 bg-red-400 hover:bg-red-600 text-white',
            'dark'  => 'border-red-600 hover:border-red-800 bg-red-600 hover:bg-red-800 text-white',
        ],
        'dropdown' => [
            'light' => 'hover:bg-gray-50',
            'dark'  => 'hover:bg-gray-900',
        ],
    ],
    'breadcrumb' => [
        'parent'    => [
            'light' => 'text-gray-300 hover:text-gray-400',
            'dark'  => 'text-gray-400 hover:text-gray-500',
        ],
        'seperator' => [
            'light' => 'text-gray-200',
            'dark'  => 'text-gray-200',
        ],
        'child'     => [
            'light' => 'text-gray-200',
            'dark'  => 'text-gray-300',
        ],
    ],
    'dropdown'   => [
        'list' => [
            'light' => 'bg-white border-gray-600',
            'dark'  => 'bg-blue-900 border-gray-300',
        ],
        'item' => [
            'light' => 'hover:bg-gray-200',
            'dark'  => 'hover:bg-gray-900',
        ],
    ],
    'input'      => [
        'light' => 'text-gray-800 bg-white border-gray-300 focus:ring-blue-500',
        'dark'  => 'text-gray-300 bg-gray-800 border-gray-500 focus:ring-blue-500',
    ],
    'error'      => [
        'text'  => [
            'light' => 'text-red-600',
            'dark'  => 'text-red-600',
        ],
        'alert' => [
            'light' => 'bg-red-100 text-gray-800 border-red-600',
            'dark'  => 'bg-red-100 text-gray-800 border-red-600',
        ],
    ],
    'warning'    => [
        'text'  => [
            'light' => 'text-yellow-400',
            'dark'  => 'text-yellow-400',
        ],
        'alert' => [
            'light' => 'bg-yellow-100 text-gray-800 border-yellow-400',
            'dark'  => 'bg-yellow-100 text-gray-800 border-yellow-400',
        ],
    ],
    'success'    => [
        'text'  => [
            'light' => 'text-green-600',
            'dark'  => 'text-green-600',
        ],
        'alert' => [
            'light' => 'bg-green-100 text-gray-800 border-green-600',
            'dark'  => 'bg-green-100 text-gray-800 border-green-600',
        ],
    ],
    'info'       => [
        'text'  => [
            'light' => 'text-blue-400',
            'dark'  => 'text-blue-400',
        ],
        'alert' => [
            'light' => 'bg-blue-200 text-gray-800 border-blue-400',
            'dark'  => 'bg-blue-200 text-gray-800 border-blue-400',
        ],
    ],
    'modal'      => [
        'content' => [
            'light' => 'bg-white border-gray-600',
            'dark'  => 'bg-blue-900 border-gray-300',
        ],
        'shadow'  => [
            'light' => 'bg-black/70',
            'dark'  => 'bg-black/70',
        ],
    ],
    'nav'        => [
        'bar'          => [
            'light' => 'bg-blue-400 text-gray-200',
            'dark'  => 'bg-blue-600 text-gray-200',
        ],
        'item'         => [
            'light' => 'hover:bg-blue-600 hover:text-gray-200 text-white border-blue-400',
            'dark'  => 'hover:bg-blue-800 hover:text-gray-300 text-white border-blue-600',
        ],
        'hovercontent' => [
            'light' => 'bg-white text-gray-800',
            'dark'  => 'bg-slate-700 text-gray-300',
        ],
    ],
    'rule'       => [
        'light' => 'border-gray-400',
        'dark'  => 'border-gray-400',
    ],
    'text'       => [
        'muted' => [
            'light' => 'text-gray-400',
            'dark'  => 'text-gray-300',
        ],
    ],
    'toggle'     => [
        'light' => "bg-gray-300 peer-checked:bg-green-400 after:bg-white",
        'dark'  => "bg-gray-300 peer-checked:bg-green-400 after:bg-white",
    ],
    'footer'     => [
        'primary' => [
            'light' => "bg-gray-200 text-gray-500",
            'dark'  => "bg-slate-600 text-gray-300",
        ],
        'policy'  => [
            'light' => "bg-slate-400 text-gray-200",
            'dark'  => "bg-slate-800 text-gray-400",
        ],
    ],
];
function lightDarkify($colors, $level = 0)
{
    $result = ['light' => [], 'dark' => []];
    if ($level >= 3) {
        return $result;
    }
    foreach ($colors as $key => $value) {
        if (is_array($value)) {
            $subResult = lightDarkify($value, $level + 1);
            foreach ($subResult as $theme => $subValue) {
                if (isset($result[$theme])) {
                    $result[$theme][$key] = $subValue;
                }
            }
        } elseif ($key == 'light' || $key == 'dark') {
            $result[$key] = $value;
        }
    }
    return $result;
}
return lightDarkify($colors)[$theme];
