<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>Langkah 2: Tentukan Jumlah - {{ config('app.name', 'Laravel') }}</title>
    
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    
    <style>
        :root {
            --bg: #f8fafc; --panel: #ffffff; --muted: #6b7280; --accent: #0b5ed7;
            --font-main: 'Inter', system-ui, -apple-system, sans-serif;
        }
        * { box-sizing: border-box; }
        
        body { 
            margin: 0; 
            font-family: var(--font-main); 
            background: var(--bg); 
            color: #111827;
            -webkit-font-smoothing: antialiased;
        }
        
        .app { display: flex; min-height: 100vh; }
        
        /* Content area adjustments for responsiveness */
        .content { 
            flex: 1; 
            padding: 32px; 
            width: 100%;
            transition: all 0.3s ease;
        }

        /* Responsive Styles */
        @media (max-width: 1024px) {
            .app { display: block; }
            .content { padding: 20px; padding-top: 80px; }
        }
        
        @media (max-width: 640px) {
            .content { padding: 16px; padding-top: 80px; }
        }
    </style>
</head>
<body>
    <div class="app">
        {{-- Sidebar partial --}}
        @include('partials.sidebar')

        {{-- Main content --}}
        <main class="content">
            <div class="max-w-4xl mx-auto">
                
                {{-- Breadcrumb / Header Kecil --}}
                <div class="mb-6">
                    <a href="{{ route('borrow.select') }}" class="inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-2">
                        <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg>
                        Kembali ke Pilih Barang
                    </a>
                    <h1 class="text-2xl font-bold text-gray-900">Permintaan Baru</h1>
                </div>

                <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden flex flex-col">
                    <form action="{{ route('borrow.store.quantity') }}" method="POST" class="flex flex-col h-full">
                        @csrf

                        <div class="p-5 md:p-6 border-b border-gray-200 bg-gray-50/50">
                            <div class="flex items-center gap-3 mb-1">
                                <span class="flex items-center justify-center w-6 h-6 rounded-full bg-blue-100 text-blue-600 text-xs font-bold">2</span>
                                <h2 class="text-lg font-semibold text-gray-800">Tentukan Jumlah</h2>
                            </div>
                            <p class="text-sm text-gray-500 ml-9">Masukkan jumlah barang yang ingin Anda pinjam.</p>
                        </div>

                        <div class="p-5 md:p-6">
                            
                            <!-- Detail Barang yang Dipilih -->
                            <div class="mb-8 p-4 md:p-5 border border-blue-100 bg-blue-50/50 rounded-xl flex flex-col sm:flex-row gap-5 items-start sm:items-center">
                                <div class="flex-shrink-0">
                                    @if($item->image)
                                        <img src="{{ asset('storage/' . $item->image) }}" 
                                             alt="{{ $item->nama }}" 
                                             class="w-20 h-20 rounded-lg object-cover bg-white border border-blue-100 shadow-sm">
                                    @else
                                        <div class="w-20 h-20 rounded-lg bg-white border border-blue-100 flex items-center justify-center text-blue-300 shadow-sm">
                                            <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
                                            </svg>
                                        </div>
                                    @endif
                                </div>
                                
                                <div class="flex-1 min-w-0">
                                    <span class="text-xs font-semibold text-blue-600 uppercase tracking-wide mb-1 block">Barang Dipilih</span>
                                    <h3 class="text-lg md:text-xl font-bold text-gray-900 leading-tight mb-1">{{ $item->nama }}</h3>
                                    <p class="text-sm text-gray-500 font-mono mb-2">{{ $item->sku }}</p>
                                    
                                    <div class="flex items-center gap-2">
                                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-white text-gray-600 border border-gray-200 shadow-sm">
                                            Divisi: {{ $item->divisi->nama ?? 'Umum' }}
                                        </span>
                                        <span class="text-xs font-medium text-green-600 flex items-center gap-1 bg-green-50 px-2 py-0.5 rounded-full border border-green-100">
                                            <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
                                            Stok: {{ $item->jumlah }}
                                        </span>
                                    </div>
                                </div>
                            </div>

                            <!-- Input Jumlah -->
                            <div class="max-w-md">
                                <label for="jumlah" class="block text-sm font-medium text-gray-700 mb-2">Jumlah Pinjam</label>
                                <div class="relative rounded-md shadow-sm">
                                    <input type="number" name="jumlah" id="jumlah" 
                                           value="1" min="1" max="{{ $item->jumlah }}" 
                                           class="block w-full rounded-lg border-gray-300 pl-4 pr-12 py-3 focus:border-blue-500 focus:ring-blue-500 sm:text-sm shadow-sm transition-shadow" 
                                           placeholder="0" required autofocus>
                                    <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                        <span class="text-gray-500 sm:text-sm">unit</span>
                                    </div>
                                </div>
                                <p class="mt-2 text-sm text-gray-500">Maksimal peminjaman: {{ $item->jumlah }} unit</p>
                                
                                @error('jumlah')
                                    <p class="mt-2 text-sm text-red-600 flex items-center gap-1">
                                        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                                        {{ $message }}
                                    </p>
                                @enderror
                            </div>

                        </div>

                        <div class="p-5 md:p-6 flex justify-between items-center bg-gray-50/50 rounded-b-xl border-t mt-auto">
                            <a href="{{ route('borrow.select') }}" class="text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors flex items-center gap-1">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg>
                                Kembali
                            </a>
                            <button type="submit" class="w-full sm:w-auto px-6 py-3 bg-blue-600 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all transform active:scale-95">
                                Lanjut ke Tanggal &rarr;
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </main>
    </div>
</body>
</html>