<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>로그인 - {{ config('app.name') }}</title>
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="bg-gray-100">
    <div class="min-h-screen flex items-center justify-center">
        <div class="flex flex-col items-center">
            <div class="text-center mb-6">
                <h1 class="text-4xl font-bold text-gray-900">{{ config('app.name') }}</h1>
                <p class="text-gray-600 mt-2">관리자 패널</p>
            </div>

            <div class="w-96 bg-white rounded-lg shadow-xl p-8">
                <h2 class="text-2xl font-semibold text-center mb-6">로그인</h2>

                @if (session('success'))
                <div class="flex items-center gap-3 p-4 mb-4 bg-green-100 border border-green-200 text-green-800 rounded-lg">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    <span>{{ session('success') }}</span>
                </div>
                @endif

                @if ($errors->any())
                <div class="flex items-center gap-3 p-4 mb-4 bg-red-100 border border-red-200 text-red-800 rounded-lg">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    <span>{{ $errors->first() }}</span>
                </div>
                @endif

                <form method="POST" action="{{ route('login') }}">
                    @csrf

                    <div class="mb-4">
                        <label class="block text-sm font-medium text-gray-700 mb-2">
                            이메일 또는 아이디
                        </label>
                        <input
                            type="text"
                            name="login"
                            value="{{ old('login') }}"
                            placeholder="email@example.com 또는 아이디"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent @error('login') border-red-500 @enderror"
                            required
                            autofocus
                        />
                        @error('login')
                        <p class="text-sm text-red-600 mt-1">{{ $message }}</p>
                        @enderror
                        <p class="text-xs text-gray-500 mt-1">* 아이디 로그인은 본사 소속만 가능합니다.</p>
                    </div>

                    <div class="mb-4">
                        <label class="block text-sm font-medium text-gray-700 mb-2">
                            비밀번호
                        </label>
                        <input
                            type="password"
                            name="password"
                            class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent @error('password') border-red-500 @enderror"
                            required
                        />
                        @error('password')
                        <p class="text-sm text-red-600 mt-1">{{ $message }}</p>
                        @enderror
                    </div>

                    <input type="hidden" name="remember" value="1" />

                    <button type="submit" class="w-full bg-primary text-white font-semibold py-2.5 px-4 rounded-lg hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 transition-opacity">
                        로그인
                    </button>
                </form>
            </div>

            {{-- 전자계약 서명 바로가기 --}}
            <div class="w-96 bg-white rounded-lg shadow-xl p-6 mt-4">
                <h3 class="text-sm font-semibold text-gray-700 mb-3">전자계약 서명하기</h3>
                <p class="text-xs text-gray-500 mb-3">카카오톡으로 서명 요청을 받으셨나요? 전화번호를 입력하세요.</p>

                @if ($errors->has('phone'))
                <div class="flex items-center gap-2 p-3 mb-3 bg-red-50 border border-red-200 text-red-700 rounded-lg text-sm">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <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" />
                    </svg>
                    <span>{{ $errors->first('phone') }}</span>
                </div>
                @endif

                <form method="POST" action="{{ route('esign.verify-phone') }}" class="flex gap-2">
                    @csrf
                    <input
                        type="tel"
                        name="phone"
                        placeholder="01012345678"
                        class="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent"
                    />
                    <button type="submit" class="px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap">
                        확인
                    </button>
                </form>
            </div>
        </div>
    </div>
</body>
</html>