@php
    $pageTitle = '공지사항';
    $pageDesc  = '서비스 운영 및 결제/발송 관련 안내를 확인하세요.';

    $breadcrumbs = [
      ['label' => '홈', 'url' => url('/')],
      ['label' => '고객센터', 'url' => url('/cs')],
      ['label' => '공지사항', 'url' => url()->current()],
    ];

    $csActive = 'notice';
@endphp

@extends('web.layouts.subpage')

@section('title', '공지사항 | PIN FOR YOU')
@section('meta_description', 'PIN FOR YOU 공지사항입니다. 운영/결제/발송 관련 최신 안내를 확인하세요.')
@section('canonical', url('/cs/notice'))

@push('styles')
    <link rel="stylesheet" href="{{ asset('assets/css/cs-notice.css') }}">
@endpush

@push('scripts')
    <script defer src="{{ asset('assets/js/cs-notice.js') }}"></script>
@endpush

@section('subcontent')
    <div class="notice-page">

        <div class="notice-head-row">
            <div class="notice-count">
                총 <strong>{{ number_format($notices->total()) }}</strong>건
            </div>

            <div class="notice-toolbar" role="search">
                <form class="nt-right" action="{{ route('web.cs.notice.index') }}" method="GET">
                    <div class="nt-search">
                        <input type="text" name="q" value="{{ $q ?? request('q') }}"
                               placeholder="검색"
                               aria-label="공지 검색">
                        @if(($q ?? '') !== '')
                            <a class="nt-clear" href="{{ route('web.cs.notice.index') }}" aria-label="검색 초기화">×</a>
                        @endif
                        <button type="submit" aria-label="검색">검색</button>
                    </div>
                </form>
            </div>
        </div>

        <ul class="notice-list2" data-highlight="{{ $q ?? '' }}">
            @forelse($notices as $row)
                @php
                    $tag = $row->uiTag();
                    $dt  = $row->regdateCarbon();
                @endphp
                <li class="notice-item">
                    <a href="{{ route('web.cs.notice.show', ['seq' => $row->seq]) }}" class="notice-link">
                        <span class="{{ $tag['class'] }}">{{ $tag['label'] }}</span>
                        <span class="n2-text js-hl">{{ $row->subject }}</span>
                        <time class="n2-date">{{ $dt ? $dt->format('Y.m.d') : '-' }}</time>
                    </a>
                </li>
            @empty
                <li class="notice-empty">
                    <div class="notice-empty-box">
                        <strong>공지사항이 없습니다.</strong>
                        @if(($q ?? '') !== '')
                            <div class="notice-empty-sub">다른 검색어로 다시 시도해 주세요.</div>
                        @endif
                    </div>
                </li>
            @endforelse
        </ul>

        @if($notices->hasPages())
            <div class="notice-pager">
                {{ $notices->links('web.partials.pagination') }}
            </div>
        @endif

    </div>

    @include('web.partials.cs-quick-actions')
@endsection
