@extends('layouts.app')

@section('content')
<div class="min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 py-8 px-4 md:px-8">
    <div class="max-w-7xl mx-auto">
        <div class="mb-8">
            <div class="flex items-center justify-between mb-6">
                <div>
                    <h1 class="text-3xl font-bold text-gray-900 mb-2">📊 {{ \App\Helpers\TranslationHelper::transFromDatabase('Detailed Costs (Hierarchical)', __('Detailed Costs (Hierarchical)')) }}</h1>
                    <p class="text-gray-600">{{ \App\Helpers\TranslationHelper::transFromDatabase('Hierarchical detailed view of cost centers and costs', __('Hierarchical detailed view of cost centers and costs')) }}</p>
                </div>
                <a href="{{ route('reports.cost-center') }}" class="inline-flex items-center px-6 py-3 bg-gradient-to-r from-blue-600 to-blue-700 text-white font-semibold rounded-lg hover:from-blue-700 hover:to-blue-800 transition-all duration-200 shadow-lg">
                    <i class="fas fa-arrow-right ml-2"></i>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Return', __('Return')) }}</span>
                </a>
            </div>

            <form action="{{ route('reports.hierarchical-costs') }}" method="GET" class="bg-white rounded-lg shadow-md p-6 mb-6 border border-gray-200">
                <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                    <div>
                        <label for="date_from" class="block text-sm font-medium text-gray-700 mb-2">{{ \App\Helpers\TranslationHelper::transFromDatabase('Date From', __('Date From')) }}</label>
                        <input type="date" name="date_from" id="date_from" value="{{ $dateFrom }}" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
                    </div>
                    <div>
                        <label for="date_to" class="block text-sm font-medium text-gray-700 mb-2">{{ \App\Helpers\TranslationHelper::transFromDatabase('Date To', __('Date To')) }}</label>
                        <input type="date" name="date_to" id="date_to" value="{{ $dateTo }}" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
                    </div>
                    <div class="flex items-end gap-2">
                        <button type="submit" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-lg transition-colors duration-200">
                            <i class="fas fa-search ml-2"></i>
                            {{ \App\Helpers\TranslationHelper::transFromDatabase('Search', __('Search')) }}
                        </button>
                        <a href="{{ request()->fullUrlWithQuery(['export' => 'true']) }}" class="flex-1 bg-green-600 hover:bg-green-700 text-white font-semibold py-2 px-4 rounded-lg transition-colors duration-200 text-center">
                            <i class="fas fa-download ml-2"></i>
                            {{ \App\Helpers\TranslationHelper::transFromDatabase('Export', __('Export')) }}
                        </a>
                    </div>
                </div>
            </form>
        </div>

        @if(empty($data))
        <div class="bg-white rounded-xl shadow-lg p-12 text-center border border-gray-200">
            <i class="fas fa-inbox text-gray-400 text-5xl mb-4"></i>
            <p class="text-gray-600 font-medium text-lg">{{ \App\Helpers\TranslationHelper::transFromDatabase('No data to display', __('No data to display')) }}</p>
        </div>
        @else
        <div class="bg-white rounded-xl shadow-lg border border-gray-200">
            <div class="p-6 border-b border-gray-200">
                <h3 class="text-lg font-semibold text-gray-900">{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost center hierarchical structure', __('Cost center hierarchical structure')) }}</h3>
            </div>
            <div class="p-6">
                @foreach($data as $root)
                    @include('reports.cost-center.partials.hierarchy-item', ['item' => $root])
                @endforeach
            </div>
        </div>
        @endif
    </div>
</div>

<style>
.hierarchy-item {
    margin-left: 20px;
    border-left: 2px solid #e5e7eb;
    padding-left: 15px;
}

.hierarchy-level-0 {
    margin-left: 0;
    border-left: none;
    padding-left: 0;
}

.hierarchy-level-1 {
    margin-left: 20px;
}

.hierarchy-level-2 {
    margin-left: 40px;
}

.hierarchy-level-3 {
    margin-left: 60px;
}

.hierarchy-level-4 {
    margin-left: 80px;
}
</style>
@endsection
