@extends('layouts.app')

@push('head')
<style>
    .notification-card {
        background: var(--card);
        border: 1px solid rgba(148, 163, 184, 0.14);
        border-radius: 20px;
        padding: 30px 34px;
        box-shadow: 0 22px 42px rgba(15, 23, 42, 0.4);
        max-width: 780px;
        margin: 0 auto;
    }
    .notification-card h2 {
        margin: 0 0 18px;
        font-weight: 700;
        letter-spacing: -0.02em;
    }
    .notification-form {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    .notification-field label {
        display: block;
        font-weight: 600;
        margin-bottom: 6px;
        color: #dbeafe;
        letter-spacing: 0.01em;
    }
    .notification-card .form-control,
    .notification-card select {
        background: rgba(15, 23, 42, 0.82);
        border: 1px solid rgba(148, 163, 184, 0.24);
        color: #f1f5f9;
        border-radius: 12px;
        padding: 10px 12px;
        font-size: 14px;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
        transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    }
    .notification-card .form-control::placeholder,
    .notification-card select option {
        color: #94a3b8;
    }
    .notification-card .form-control:focus,
    .notification-card select:focus {
        outline: none;
        border-color: #38bdf8;
        box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
        background: rgba(15, 23, 42, 0.94);
    }
    .notification-hint {
        font-size: 12px;
        color: #94a3b8;
        margin-top: 6px;
    }
    .notification-actions {
        margin-top: 6px;
    }
    .notification-actions .btn-primary {
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        color: #e2e8f0;
        border: none;
        padding: 11px 24px;
        border-radius: 12px;
        font-weight: 600;
        box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .notification-actions .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow: 0 14px 28px rgba(37, 99, 235, 0.36);
    }
    .notification-actions .btn-primary:active {
        transform: translateY(0);
        box-shadow: 0 10px 20px rgba(37, 99, 235, 0.28);
    }
</style>
@endpush

@section('content')
<div class="notification-card">
    <h2>Buat Pemberitahuan</h2>

    @if (session('success'))
        <div style="background:#ecfdf5; color:#065f46; padding:10px 12px; border:1px solid #10b981; border-radius:8px; margin-bottom:12px;">
            {{ session('success') }}
        </div>
    @endif

    @if ($errors->any())
        <div style="background:#fef2f2; color:#991b1b; padding:10px 12px; border:1px solid #ef4444; border-radius:8px; margin-bottom:12px;">
            <div style="font-weight:600; margin-bottom:6px;">Terjadi kesalahan:</div>
            <ul style="margin:0 0 0 18px; padding:0;">
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <form method="POST" action="{{ route('admin.notifications.store') }}" class="notification-form" enctype="multipart/form-data">
        @csrf
        <div class="notification-field">
            <label for="user_id">Pilih User</label>
            <select name="user_id" id="user_id" class="form-control" required>
                <option value="all">Semua User</option>
                @foreach($users as $user)
                    <option value="{{ $user->id }}">{{ $user->name }} ({{ $user->username }})</option>
                @endforeach
            </select>
        </div>
        <div class="notification-field">
            <label for="title">Judul</label>
            <input type="text" name="title" id="title" class="form-control" placeholder="Masukkan judul pemberitahuan" required>
        </div>
        <div class="notification-field">
            <label for="message">Catatan</label>
            <textarea name="message" id="message" class="form-control" rows="3" placeholder="Tulis pesan pemberitahuan" required></textarea>
        </div>
        <div class="notification-field">
            <label for="image">Gambar (opsional)</label>
            <input type="file" name="image" id="image" class="form-control" accept="image/*">
            <div class="notification-hint">Maks 2MB. Format: JPG/PNG.</div>
        </div>
        <div class="notification-actions">
            <button type="submit" class="btn btn-primary">Kirim Pemberitahuan</button>
        </div>
    </form>
</div>
@endsection
