@extends('admin.layouts.app')

@section('title', '공지사항 등록')
@section('page_title', '공지사항 등록')
@section('page_desc', '공지(상단노출) / 첨부파일 / 링크를 설정합니다.')

@push('head')
    <style>
        /* notice create only - match admins */
        .lbtn{padding:8px 12px;font-size:13px;border-radius:12px;line-height:1.1;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;
            border:1px solid rgba(255,255,255,.10);background:rgba(255,255,255,.06);color:inherit;cursor:pointer;}
        .lbtn:hover{background:rgba(255,255,255,.10);text-decoration:none;}
        .lbtn--primary{background:rgba(59,130,246,.88);border-color:rgba(59,130,246,.95);color:#fff;}
        .lbtn--primary:hover{background:rgba(59,130,246,.98);}
        .lbtn--ghost{background:transparent;}
        .lbtn--sm{padding:7px 10px;font-size:12px;border-radius:11px;}
        .lbtn--wide{padding:10px 14px;font-weight:800;}
        .wrap{max-width:880px;}
        .checks{display:flex;flex-wrap:wrap;gap:10px;}
    </style>
@endpush

@section('content')
    <div class="a-card" style="padding:16px; margin-bottom:16px;">
        <div style="display:flex; justify-content:space-between; align-items:flex-start; gap:12px; flex-wrap:wrap;">
            <div>
                <div style="font-weight:900; font-size:16px;">공지사항 등록</div>
                <div class="a-muted" style="font-size:12px; margin-top:4px;">
                    공지(상단노출) / 첨부파일 / 링크를 설정합니다.
                </div>
            </div>

            <a class="lbtn lbtn--ghost lbtn--sm"
               href="{{ route('admin.notice.index', request()->only(['field','q','page'])) }}">
                ← 목록
            </a>
        </div>
    </div>

    <form method="POST"
          action="{{ route('admin.notice.store') }}"
          enctype="multipart/form-data"
          onsubmit="this.querySelector('button[type=submit]')?.setAttribute('disabled','disabled');">
        @csrf

        <div class="a-card wrap" style="padding:16px;">
            <div class="a-field">
                <label class="a-label">옵션</label>
                <div class="checks">
                    <label class="a-check" style="margin:0;">
                        <input type="checkbox" name="first_sign" value="1" {{ old('first_sign') ? 'checked' : '' }}>
                        <span>공지(게시물 상위노출)</span>
                    </label>
                </div>
            </div>

            <div class="a-field">
                <label class="a-label">제목</label>
                <input class="a-input" name="subject" value="{{ old('subject') }}" maxlength="80" placeholder="제목을 입력하세요">
                @error('subject') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div class="a-field">
                <label class="a-label">내용</label>
                <textarea class="a-input" name="content" rows="12" placeholder="내용을 입력하세요">{{ old('content') }}</textarea>
                @error('content') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div class="a-field">
                <label class="a-label"># 링크1</label>
                <input class="a-input" name="link_01" value="{{ old('link_01') }}" maxlength="200" placeholder="https://">
                @error('link_01') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div class="a-field">
                <label class="a-label"># 링크2</label>
                <input class="a-input" name="link_02" value="{{ old('link_02') }}" maxlength="200" placeholder="https://">
                @error('link_02') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div class="a-field">
                <label class="a-label"># 첨부파일1</label>
                <input class="a-input" type="file" name="file_01">
                @error('file_01') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div class="a-field">
                <label class="a-label"># 첨부파일2</label>
                <input class="a-input" type="file" name="file_02">
                @error('file_02') <div class="a-error">{{ $message }}</div> @enderror
            </div>

            <div style="display:flex; gap:8px; flex-wrap:wrap; margin-top:14px;">
                <button class="lbtn lbtn--primary lbtn--wide" type="submit">등록</button>
                <a class="lbtn lbtn--ghost" href="{{ route('admin.notice.index', request()->only(['field','q','page'])) }}">취소</a>
            </div>
        </div>
    </form>
@endsection
