<!DOCTYPE html>
<html>
<head>
    <title>Berikan Review</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { 
            font-family: Arial, sans-serif; 
            background: #f5f5f5;
            padding: 20px;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 { color: #333; margin-bottom: 10px; }
        .product-info {
            background: #f9f9f9;
            padding: 15px;
            border-radius: 5px;
            margin: 20px 0;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #555;
        }
        .required { color: red; }
        input, textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
        }
        textarea { min-height: 100px; resize: vertical; }
        .star-rating {
            font-size: 40px;
            direction: rtl;
            unicode-bidi: bidi-override;
            display: inline-block;
        }
        .star-rating input {
            display: none;
        }
        .star-rating label {
            color: #ddd;
            cursor: pointer;
            display: inline-block;
            padding: 0 5px;
        }
        .star-rating input:checked ~ label,
        .star-rating label:hover,
        .star-rating label:hover ~ label {
            color: #ffc107;
        }
        button {
            background: #4CAF50;
            color: white;
            padding: 15px 30px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            width: 100%;
        }
        button:hover { background: #45a049; }
        .badge {
            display: inline-block;
            padding: 3px 8px;
            background: #e3f2fd;
            color: #1976d2;
            border-radius: 3px;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>⭐ Berikan Review</h1>
        <p style="color: #666; margin-bottom: 20px;">Bagaimana pengalaman Anda?</p>

        <div class="product-info">
            <strong>{{ $order->product->name ?? 'Product' }}</strong><br>
            <small>Order #{{ $order->id }} | 
                <span class="badge">✅ Selesai</span>
            </small>
        </div>

        @if(session('error'))
            <div style="background: #ffebee; color: #c62828; padding: 10px; border-radius: 5px; margin-bottom: 20px;">
                {{ session('error') }}
            </div>
        @endif

        <form method="POST" action="{{ route('reviews.store.token', $order->review_token) }}" enctype="multipart/form-data">
            @csrf

            <div class="form-group">
                <label>Rating <span class="required">*</span></label>
                <div class="star-rating">
                    @for ($i = 5; $i >= 1; $i--)
                        <input type="radio" id="star{{ $i }}" name="rating" value="{{ $i }}" {{ old('rating') == $i ? 'checked' : '' }} required>
                        <label for="star{{ $i }}">★</label>
                    @endfor
                </div>
                @error('rating')
                    <small style="color: red;">{{ $message }}</small>
                @enderror
            </div>

            <div class="form-group">
                <label for="reviewer_name">Nama Anda <span class="required">*</span></label>
                <input type="text" id="reviewer_name" name="reviewer_name" 
                       value="{{ old('reviewer_name', $order->guest_name) }}" 
                       placeholder="Nama yang akan ditampilkan" required>
                @error('reviewer_name')
                    <small style="color: red;">{{ $message }}</small>
                @enderror
            </div>

            <div class="form-group">
                <label for="comment">Ulasan (Opsional)</label>
                <textarea id="comment" name="comment" placeholder="Ceritakan pengalaman Anda...">{{ old('comment') }}</textarea>
                @error('comment')
                    <small style="color: red;">{{ $message }}</small>
                @enderror
            </div>

            <div class="form-group">
                <label for="images">Upload Foto (Opsional, Max 3)</label>
                <input type="file" id="images" name="images[]" accept="image/*" multiple>
                <small style="color: #666;">Maksimal 3 foto, masing-masing max 2MB</small>
            </div>

            <button type="submit">📤 Kirim Review</button>
        </form>

        <p style="text-align: center; margin-top: 20px; color: #999; font-size: 12px;">
            Link ini hanya dapat digunakan satu kali
        </p>
    </div>
</body>
</html>