@extends('admin.clients.tabs._layout')

@section('tab-content')
<div class="card border-0 shadow-sm">
    <div class="card-header border-bottom">
        <h6 class="mb-0">
            <i class="fas fa-history text-primary me-2"></i>{{ __('admin/clients.tabs_logs') }}
        </h6>
    </div>
    <div class="card-body">
        <!-- Search -->
        <div class="row mb-3">
            <div class="col-md-4">
                <input type="text"
                       id="searchInput"
                       class="form-control"
                       placeholder="{{ __('admin/clients.logs_search') }}">
            </div>
        </div>

        <!-- DataTable -->
        <div class="table-responsive">
            <table id="logs" class="table table-bordered table-striped"
                   data-records-url="{{ route('api.admin.clients.logs.records', $client) }}">
                <thead>
                    <tr>
                        <th>{{ __('admin/clients.logs_id') }}</th>
                        <th>{{ __('admin/clients.logs_action') }}</th>
                        <th>{{ __('admin/clients.logs_entity_type') }}</th>
                        <th>{{ __('admin/clients.logs_description') }}</th>
                        <th>{{ __('admin/clients.logs_actor_name') }}</th>
                        <th>{{ __('admin/clients.logs_ip_address') }}</th>
                        <th>{{ __('admin/clients.logs_created_at') }}</th>
                        <th>{{ __('admin/clients.logs_actions') }}</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>

<!-- Log Detail Modal -->
<div class="modal fade" id="logDetailModal" tabindex="-1" aria-labelledby="logDetailModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="logDetailModalLabel">{{ __('admin/clients.logs_detail_title') }}</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="row mb-3">
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_action') }}:</strong>
                        <p id="logAction" class="mb-0"></p>
                    </div>
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_entity_type') }}:</strong>
                        <p id="logEntityType" class="mb-0"></p>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_entity_id') }}:</strong>
                        <p id="logEntityId" class="mb-0"></p>
                    </div>
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_actor_name') }}:</strong>
                        <p id="logActorName" class="mb-0"></p>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-12">
                        <strong>{{ __('admin/clients.logs_description') }}:</strong>
                        <p id="logDescription" class="mb-0"></p>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_ip_address') }}:</strong>
                        <p id="logIpAddress" class="mb-0"></p>
                    </div>
                    <div class="col-md-6">
                        <strong>{{ __('admin/clients.logs_created_at') }}:</strong>
                        <p id="logCreatedAt" class="mb-0"></p>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-12">
                        <strong>{{ __('admin/clients.logs_user_agent') }}:</strong>
                        <p id="logUserAgent" class="mb-0 text-muted small"></p>
                    </div>
                </div>
                <div class="row">
                    <div class="col-12">
                        <strong>{{ __('admin/clients.logs_properties') }}:</strong>
                        <pre id="logProperties" class="border rounded p-3 mt-2" style="max-height: 300px; overflow-y: auto;"></pre>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ __('admin/clients.logs_close') }}</button>
            </div>
        </div>
    </div>
</div>

@push('scripts')
<script>
    // Dil çevirilerini JavaScript'e aktar
    window.translations = {
        common: {
            buttons_view: '{{ __("admin/common.buttons_view") }}'
        }
    };
</script>
@vite('resources/js/admin/clients/logs.js')
@endpush
@endsection
