<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Services\SettingsService;
use Illuminate\Http\Request;

class ThemeSettingsController extends Controller
{
    protected $settings;
    
    public function __construct(SettingsService $settings)
    {
        $this->settings = $settings;
    }
    
    public function index()
    {
        return view('admin.theme-settings', [
            'settings' => $this->settings->getAll()
        ]);
    }
    
    public function update(Request $request)
    {
        $validated = $request->validate([
            'primary_color' => 'required|string',
            'secondary_color' => 'required|string',
            'accent_color' => 'required|string',
            'dark_color' => 'required|string',
            'font_family' => 'required|string',
            'border_radius' => 'required|string',
            'box_shadow' => 'required|string',
            'header_font_size' => 'required|string',
        ]);
        
        foreach ($validated as $key => $value) {
            $this->settings->set($key, $value);
        }
        
        return redirect()->back()->with('success', 'Theme settings updated successfully!');
    }
}