{{-- Cookie 同意提示 — 依据《个人信息保护法》第十七条 --}}
@if(config('kylin-adminlte.cookie_consent.enabled', true))
<div id="cookie-consent-banner" class="cookie-consent-banner alert alert-dark alert-dismissible fade show fixed-bottom mb-0 rounded-0 border-0" role="alert" style="z-index: 9999; display: none;">
    <div class="container d-flex justify-content-between align-items-center flex-wrap">
        <div class="cookie-consent-text me-3">
            <i class="bi bi-info-circle-fill me-1"></i>
            {{ config('kylin-adminlte.cookie_consent.message', '本网站使用 Cookie 来提升您的浏览体验。继续使用本网站即表示您同意我们的隐私政策。') }}
            @if(config('kylin-adminlte.cookie_consent.more_info_url'))
                <a href="{{ config('kylin-adminlte.cookie_consent.more_info_url') }}" target="_blank" rel="noopener noreferrer" class="alert-link text-nowrap">
                    了解更多
                </a>
            @endif
        </div>
        <button type="button" class="btn btn-primary btn-sm cookie-consent-accept" data-bs-dismiss="alert" aria-label="{{ __('同意') }}">
            {{ config('kylin-adminlte.cookie_consent.button_text', '同意') }}
        </button>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function () {
    // 检查用户是否已同意 Cookie
    if (!localStorage.getItem('cookie_consent_accepted')) {
        document.getElementById('cookie-consent-banner').style.display = 'block';
    }

    document.querySelector('.cookie-consent-accept').addEventListener('click', function () {
        localStorage.setItem('cookie_consent_accepted', 'true');
        document.getElementById('cookie-consent-banner').style.display = 'none';
    });
});
</script>
@endif