@extends('layouts.app')

@section('title', 'Create Audit Company')

@section('content')
<div class="main-content">
    <div class="content-container">
        <!-- Page Header -->
        <div class="glass-card" style="padding: 24px; margin-bottom: 24px;">
            <div style="display: flex; align-items: center; gap: 16px;">
                <a href="{{ route('audit-companies.index') }}" style="display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.8); padding: 10px 16px; border-radius: 8px; text-decoration: none; font-size: 14px; transition: all 0.3s ease;">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
                        <line x1="19" y1="12" x2="5" y2="12"></line>
                        <polyline points="12 19 5 12 12 5"></polyline>
                    </svg>
                    Back
                </a>
                <div>
                    <h1 style="font-size: 28px; font-weight: 600; margin-bottom: 4px;">Create Audit Company</h1>
                    <p style="color: rgba(255, 255, 255, 0.6); font-size: 14px;">Add a new audit company and assign an administrator</p>
                </div>
            </div>
        </div>

        <!-- Form -->
        <div class="glass-card" style="padding: 32px;">
            @if($errors->any())
                <div class="glass-alert error" style="margin-bottom: 24px;">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <circle cx="12" cy="12" r="10"></circle>
                        <line x1="12" y1="8" x2="12" y2="12"></line>
                        <line x1="12" y1="16" x2="12.01" y2="16"></line>
                    </svg>
                    <div>
                        <div style="font-weight: 600; margin-bottom: 4px;">Please fix the following errors:</div>
                        <ul style="margin: 0; padding-left: 20px;">
                            @foreach($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
            @endif

            <form method="POST" action="{{ route('audit-companies.store') }}">
                @csrf

                <!-- Audit Company Information -->
                <div style="margin-bottom: 32px;">
                    <h2 style="font-size: 20px; font-weight: 600; margin-bottom: 20px; color: #14b8a6;">Audit Company Information</h2>
                    
                    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;">
                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Company Name *</label>
                            <input type="text" name="name" value="{{ old('name') }}" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="Enter company name">
                            @error('name')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Email *</label>
                            <input type="email" name="email" value="{{ old('email') }}" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="company@example.com">
                            @error('email')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Phone</label>
                            <input type="tel" name="phone" value="{{ old('phone') }}" style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="+852 1234 5678">
                            @error('phone')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Registration Number</label>
                            <input type="text" name="registration_number" value="{{ old('registration_number') }}" style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="CRN-123456">
                            @error('registration_number')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div style="grid-column: 1 / -1;">
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Address</label>
                            <textarea name="address" rows="3" style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease; resize: vertical;" placeholder="Enter company address">{{ old('address') }}</textarea>
                            @error('address')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>
                    </div>
                </div>

                <!-- Administrator Information -->
                <div style="margin-bottom: 32px;">
                    <h2 style="font-size: 20px; font-weight: 600; margin-bottom: 20px; color: #f97316;">Administrator Information</h2>
                    
                    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;">
                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Admin Name *</label>
                            <input type="text" name="admin_name" value="{{ old('admin_name') }}" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="John Doe">
                            @error('admin_name')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Admin Email *</label>
                            <input type="email" name="admin_email" value="{{ old('admin_email') }}" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="admin@example.com">
                            @error('admin_email')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Password *</label>
                            <input type="password" name="admin_password" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="Minimum 8 characters">
                            @error('admin_password')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>

                        <div>
                            <label style="display: block; color: rgba(255, 255, 255, 0.8); font-size: 14px; font-weight: 500; margin-bottom: 8px;">Confirm Password *</label>
                            <input type="password" name="admin_password_confirmation" required style="width: 100%; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 12px 16px; color: #ffffff; font-size: 14px; transition: all 0.3s ease;" placeholder="Confirm password">
                            @error('admin_password_confirmation')
                                <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                            @enderror
                        </div>
                    </div>
                </div>

                <!-- Submit Buttons -->
                <div style="display: flex; gap: 12px; justify-content: flex-end;">
                    <a href="{{ route('audit-companies.index') }}" style="display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.8); padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 500; transition: all 0.3s ease;">
                        Cancel
                    </a>
                    <button type="submit" style="display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(135deg, #14b8a6, #06b6d4); color: white; padding: 12px 24px; border-radius: 8px; border: none; font-weight: 500; cursor: pointer; transition: all 0.3s ease;">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 18px; height: 18px;">
                            <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
                            <polyline points="22 4 12 14.01 9 11.01"></polyline>
                        </svg>
                        Create Audit Company
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
