{# resources/views/partials/admin_sidebar.twig #}
<aside class="bg-slate-800 text-slate-100 w-full lg:w-64 lg:min-h-screen p-4 flex-shrink-0 shadow-lg">
    <div class="flex items-center justify-center p-4 border-b border-slate-700 mb-6">
        <a href="{{ BASE_URL }}{{ routeParser is defined ? routeParser.urlFor('admin.dashboard') : '/admin/dashboard' }}" class="flex flex-col items-center text-center">
            
            {# Logomarca #}
            {% if config_app.get('site_logo_path') and config_app.get('site_logo_path') != 'assets/img/logo_padrao.png' %}
                <img src="{{ BASE_URL }}/uploads/{{ config_app.get('site_logo_path') }}" alt="{{ config_app.get('site_name') }} Logo" class="h-12 mb-2 mx-auto">
            {% else %}
                 <img src="{{ asset('img/logo.png') }}" alt="{{ config_app.get('site_name') }} Logo" class="h-12 mb-2 mx-auto" onerror="this.style.display='none'; document.getElementById('logo-text-fallback-sidebar').style.display='block';">
                 <div id="logo-text-fallback-sidebar" style="display:none;" class="text-2xl font-bold text-white">{{ config_app.get('site_name') }}</div>
            {% endif %}
            
            {# Nome do Sistema #}
            <h1 class="text-xl font-semibold text-white mt-1">{{ config_app.get('site_name') }}</h1>
            <p class="text-xs text-slate-400">{{ __('app.subtitle_law_system') | default('Web System Solution Veritas') }}</p>
        </a>
    </div>
    
    {% if session.user_id %}
    <div class="flex flex-col items-center mb-6 text-center">
        <div class="w-16 h-16 rounded-full bg-slate-200 flex items-center justify-center text-slate-700 text-2xl font-bold mb-2">
            {{ session.user_name | first | upper }} 
        </div>
        <h3 class="font-medium text-slate-200">{{ session.user_name }}</h3>
        <p class="text-xs text-slate-400">{{ session.user_role_name | default(__('role.user')) }}</p>
    </div>
    {% endif %}
    
    <nav class="space-y-1">
        {% set nav_items = {
            'admin.dashboard': {'label_key': 'sidebar.dashboard', 'icon': 'fa-th-large', 'id': 'dashboard'},
            'admin.appointments.index': {'label_key': 'sidebar.agenda', 'icon': 'fa-calendar-alt', 'id': 'appointments'},
            'admin.processes.index': {'label_key': 'sidebar.processes', 'icon': 'fa-balance-scale', 'id': 'processes'},
            'admin.clients.index': {'label_key': 'sidebar.clients', 'icon': 'fa-users', 'id': 'clients'},
            'admin.documents.index': {'label_key': 'sidebar.documents', 'icon': 'fa-file-alt', 'id': 'documents'},
            'admin.templates.index': {'label_key': 'sidebar.document_templates', 'icon': 'fa-paste', 'id': 'templates'},
            'admin.users.index': {'label_key': 'sidebar.users', 'icon': 'fa-user-shield', 'id': 'users'},
            'admin.jurisprudence.index': {'label_key': 'sidebar.jurisprudence', 'icon': 'fa-gavel', 'id': 'jurisprudence'},
            'admin.reports.index': {'label_key': 'sidebar.reports', 'icon': 'fa-chart-bar', 'id': 'reports'}
        } %}
        {% set settings_items = {
            'admin.settings.general.form': {'label_key': 'sidebar.settings_general', 'icon': 'fa-cogs', 'id': 'settings_general'},
            'admin.settings.languages.index': {'label_key': 'sidebar.languages_translations', 'icon': 'fa-language', 'id': 'settings_languages'},
            'admin.links.index': {'label_key': 'sidebar.useful_links', 'icon': 'fa-link', 'id': 'links'},
            'admin.ai_activity.index': {'label_key': 'sidebar.ai_log', 'icon': 'fa-robot', 'id': 'ai_log'}
        } %}

        {% for route_name, item in nav_items %}
            <a href="{{ BASE_URL }}{{ routeParser is defined ? routeParser.urlFor(route_name) : '#' }}" 
               class="flex items-center px-3 py-2.5 text-sm font-medium rounded-md transition-colors duration-150
                      {% if current_page == item.id %}bg-blue-600 text-white shadow-md{% else %}text-slate-300 hover:bg-slate-700 hover:text-white{% endif %}">
                <i class="fas {{ item.icon }} w-6 h-6 mr-3 flex-shrink-0 text-center"></i>
                <span>{{ __(item.label_key) }}</span>
            </a>
        {% endfor %}
        
        {# Separador para Configurações #}
        <div class="pt-4 mt-4 border-t border-slate-700">
             <p class="px-3 py-2 text-xs font-semibold text-slate-500 uppercase tracking-wider">{{ __('sidebar.administration') | default('Administração') }}</p>
             {% for route_name, item in settings_items %}
                <a href="{{ BASE_URL }}{{ routeParser is defined ? routeParser.urlFor(route_name) : '#' }}" 
                   class="flex items-center px-3 py-2.5 text-sm font-medium rounded-md transition-colors duration-150
                          {% if current_page starts with item.id or (current_page == 'settings_translations' and item.id == 'settings_languages') %}bg-blue-600 text-white shadow-md{% else %}text-slate-300 hover:bg-slate-700 hover:text-white{% endif %}">
                    <i class="fas {{ item.icon }} w-6 h-6 mr-3 flex-shrink-0 text-center"></i>
                    <span>{{ __(item.label_key) }}</span>
                </a>
            {% endfor %}
        </div>

        <a href="{{ BASE_URL }}{{ routeParser is defined ? routeParser.urlFor('auth.logout') : '#' }}" 
           class="flex items-center px-3 py-2.5 text-sm font-medium rounded-md transition-colors duration-150 mt-6 text-slate-300 hover:bg-red-600 hover:text-white">
            <i class="fas fa-sign-out-alt w-6 h-6 mr-3 flex-shrink-0 text-center"></i>
            <span>{{ __('sidebar.logout') }}</span>
        </a>
    </nav>
</aside>