<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="{{ auth()->check() && userSetting('dark_mode', 'false') === 'true' ? 'dark' : '' }}">
    <head>
        
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.bunny.net">
        <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

        <!-- Custom CSS for dark mode -->
        <link href="{{ asset('css/dark-mode.css') }}" rel="stylesheet">

        <!-- Scripts -->
        @vite(['resources/css/app.css', 'resources/js/app.js'])
        @livewireStyles
        
        @php
            // Impostazioni utente per colori personalizzati
            $userBgColor = auth()->check() ? userSetting('bg_color', '#ffffff') : '#ffffff';
            $userTextColor = auth()->check() ? userSetting('text_color', '#1e293b') : '#1e293b';
            $userAccentColor = auth()->check() ? userSetting('accent_color', '#6366f1') : '#6366f1';
            $userSidebarBg = auth()->check() ? userSetting('sidebar_bg_color', '#fde047') : '#fde047';
            $userSidebarText = auth()->check() ? userSetting('sidebar_text_color', '#1e293b') : '#1e293b';
            $userSidebarAccent = auth()->check() ? userSetting('sidebar_accent_color', '#6366f1') : '#6366f1';
        @endphp
        
        <style>
            :root {
                --user-bg-color: {{ $userBgColor }};
                --user-text-color: {{ $userTextColor }};
                --user-accent-color: {{ $userAccentColor }};
                --user-sidebar-bg: {{ $userSidebarBg }};
                --user-sidebar-text: {{ $userSidebarText }};
                --user-sidebar-accent: {{ $userSidebarAccent }};
            }
            
            /* Applica automaticamente i colori personalizzati */
            .bg-white { background-color: var(--user-bg-color) !important; }
            .text-gray-900 { color: var(--user-text-color) !important; }
            .bg-indigo-600 { background-color: var(--user-accent-color) !important; }
        </style>
    </head>
    <body class="font-sans antialiased">
        <div class="min-h-screen bg-gray-100 dark:bg-gray-900 flex">
            @include('components.menu.sidebar')
            <div class="flex-1 flex flex-col">
                @include('layouts.navigation')

                <!-- Page Heading -->
                @isset($header)
                    <header class="bg-white dark:bg-gray-800 shadow">
                        <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                            {{ $header }}
                        </div>
                    </header>
                @endisset

                <!-- Page Content -->
                <main>
                    {{ $slot }}
                </main>
            </div>
        </div>
        @livewireScripts
    </body>
</html>
