<x-guest-layout>
    @push('styles')
    <style>
        .legal-container {
            max-width: 1000px;
            margin: 60px auto;
            padding: 0 25px;
        }
        .legal-header {
            margin-bottom: 50px;
            text-align: center;
        }
        .legal-card {
            background: rgba(255, 255, 255, 0.85);
            backdrop-filter: blur(20px);
            border-radius: 40px;
            border: 1px solid rgba(255, 255, 255, 0.5);
            box-shadow: 0 30px 60px rgba(0,0,0,0.1);
            padding: 60px;
        }
        .last-revised-badge {
            background: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 50px;
            padding: 8px 20px;
            font-size: 0.85rem;
            display: inline-block;
            margin-bottom: 15px;
            color: #6c757d;
        }
        .legal-content {
            font-family: var(--adminuiux-content-font), "Open Sans", sans-serif;
            line-height: 1.8;
            color: #2c3e50;
        }
        .legal-content h1 {
            font-size: clamp(2rem, 5vw, 3.5rem);
            line-height: 1.1;
            margin-bottom: 30px;
        }
        .legal-content h2 {
            font-size: clamp(1.5rem, 4vw, 2rem);
        }
        .legal-content h1, .legal-content h2, .legal-content h3 {
            font-family: var(--adminuiux-title-font), "Outfit", sans-serif;
            font-weight: 700;
            margin-top: 45px;
            margin-bottom: 25px;
            color: #1a1a1a;
            letter-spacing: -0.02em;
        }
        .legal-content p { margin-bottom: 20px; }
        .legal-content ul, .legal-content ol { margin-bottom: 25px; padding-left: 20px; }
        .legal-content li { margin-bottom: 10px; }
        .legal-back-btn {
            font-family: var(--adminuiux-title-font), "Outfit", sans-serif;
            font-weight: 600;
            color: #ffffff; /* High contrast on dark bg */
            background: rgba(0,0,0,0.15);
            padding: 10px 25px;
            border-radius: 50px;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            margin-bottom: 30px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255,255,255,0.1);
        }
        .legal-back-btn:hover {
            transform: translateX(-5px);
            background: rgba(0,0,0,0.3);
            color: #fff;
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .legal-footer {
            margin-top: 40px;
            text-align: center;
            padding: 20px;
            border-top: 1px solid #f1f3f5;
        }
        .toc-floating {
            position: sticky;
            top: 100px;
            height: fit-content;
        }
        @media (max-width: 991px) {
            .legal-card { padding: 40px; }
            .legal-container { margin: 30px auto; padding: 0 15px; }
        }
        @media (max-width: 575px) {
            .legal-card { padding: 30px 20px; border-radius: 30px; }
            .legal-header { margin-bottom: 35px; }
        }
    </style>
    @endpush

    <div class="legal-container">
        <a href="{{ route('login') }}" class="legal-back-btn">
            <i class="bi bi-arrow-left me-2"></i> {{ __('Back to Login') }}
        </a>

        <div class="row">
            <div class="col-12">
                <div class="legal-card overflow-hidden">
                    <header class="legal-header">
                        <div class="last-revised-badge">
                            <i class="bi bi-clock-history me-2"></i> 
                            {{ __('Version') }} {{ $version }} &bull; 
                            {{ __('Last Updated') }}: {{ $lastUpdated ?? now()->format('Y-m-d') }}
                        </div>
                        <h1 class="display-5 fw-bold text-dark">{{ $title }}</h1>
                    </header>

                    <article class="legal-content">
                        @if(!empty($content))
                            {!! strip_tags($content, '<h1><h2><h3><h4><h5><h6><p><br><strong><em><u><s><ul><ol><li><a><blockquote><table><thead><tbody><tr><th><td><hr><span><div><img>') !!}
                        @else
                            <div class="text-center py-5 opacity-50">
                                <i class="bi bi-file-earmark-text fs-1 mb-3 d-block"></i>
                                <p>{{ __('Content for this page has not been published yet.') }}</p>
                            </div>
                        @endif

                        @if($type === 'privacy' && !empty($dpo_email))
                            <div class="alert alert-light border rounded-4 mt-5 p-4">
                                <h6 class="fw-bold"><i class="bi bi-shield-check text-success me-2"></i> {{ __('Data Protection Officer') }}</h6>
                                <p class="small mb-2">{{ __('If you have questions regarding your data privacy, please contact our DPO:') }}</p>
                                <a href="mailto:{{ $dpo_email }}" class="text-primary fw-bold">{{ $dpo_email }}</a>
                                @if(!empty($company_address))
                                    <div class="mt-3 x-small text-muted">
                                        <i class="bi bi-geo-alt me-1"></i> {{ $company_address }}
                                    </div>
                                @endif
                            </div>
                        @endif
                    </article>

                    <footer class="legal-footer">
                        <p class="small text-muted mb-0">&copy; {{ date('Y') }} {{ config('app.name') }}. {{ __('All rights reserved.') }}</p>
                    </footer>
                </div>
            </div>
        </div>
    </div>
</x-guest-layout>
