@props([
    'section' => null,
    'title' => null,
    'icon' => null,
    'breadcrumbs' => collect(),
    'description' => null,
    'showSection' => true,
    'showIcon' => true,
    'showTitle' => true,
    'showBreadcrumbs' => true,
    'showDescription' => true,
    'headerClass' => '',
    'innerClass' => '',
    'contentClass' => '',
    'actionsClass' => '',
    'sectionClass' => '',
    'titleClass' => '',
    'iconClass' => '',
    'descriptionClass' => '',
])

@php
    $headerBreadcrumbs = $breadcrumbs instanceof \Illuminate\Support\Collection
        ? $breadcrumbs
        : collect($breadcrumbs ?? []);

    $hasActions = isset($actions) && trim((string) $actions) !== '';
    $resolvedHeaderClass = trim('px-6 pt-10 pb-7 md:px-10 border-b border-white/[0.06] bg-gradient-to-b from-sky-500/[0.04] to-transparent ' . $headerClass);
    $resolvedInnerClass = trim('flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between ' . $innerClass);
    $resolvedContentClass = trim('max-w-3xl min-w-0 ' . $contentClass);
    $resolvedActionsClass = trim('flex flex-col items-start gap-3 lg:items-end ' . $actionsClass);
    $resolvedSectionClass = trim('text-xs font-semibold uppercase tracking-widest text-white/30 mb-1 ' . $sectionClass);
    $resolvedTitleClass = trim('text-3xl font-bold text-white leading-tight flex items-center gap-3 ' . $titleClass);
    $resolvedIconClass = trim('text-sky-400 text-2xl ' . $iconClass);
    $resolvedDescriptionClass = trim('mt-1 text-sm text-white/50 ' . $descriptionClass);
@endphp

<header {{ $attributes->class([$resolvedHeaderClass]) }}>
    <div class="{{ $resolvedInnerClass }}">
        <div class="{{ $resolvedContentClass }}">
            @if($showSection && filled($section))
                <p class="{{ $resolvedSectionClass }}">{{ $section }}</p>
            @endif

            @if($showTitle && filled($title))
                <h1 class="{{ $resolvedTitleClass }}">
                    @if($showIcon && filled($icon))
                        <i class="fa-solid {{ $icon }} {{ $resolvedIconClass }}"></i>
                    @endif
                    <span class="min-w-0">{{ $title }}</span>
                </h1>
            @endif

            @if($showBreadcrumbs && $headerBreadcrumbs->isNotEmpty())
                <div class="mt-3">
                    @include('components.breadcrumbs', ['breadcrumbs' => $headerBreadcrumbs])
                </div>
            @endif

            @if($showDescription && filled($description))
                <p class="{{ $resolvedDescriptionClass }}">{!! $description !!}</p>
            @endif
        </div>

        @if($hasActions)
            <div class="{{ $resolvedActionsClass }}">
                {{ $actions }}
            </div>
        @endif
    </div>
</header>
