@extends('layouts.app')

@section('title', 'Add Administrator')

@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.show', $auditCompany) }}" 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;">Add Administrator</h1>
                    <p style="color: rgba(255, 255, 255, 0.6); font-size: 14px;">Add a new administrator to {{ $auditCompany->name }}</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-admin', $auditCompany) }}">
                @csrf

                <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="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="John Doe">
                        @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;">Admin 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="admin@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;">Password *</label>
                        <input type="password" name="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('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="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('password_confirmation')
                            <div style="color: #ef4444; font-size: 12px; margin-top: 4px;">{{ $message }}</div>
                        @enderror
                    </div>
                </div>

                <!-- Submit Buttons -->
                <div style="display: flex; gap: 12px; justify-content: flex-end; margin-top: 32px;">
                    <a href="{{ route('audit-companies.show', $auditCompany) }}" 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="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
                            <circle cx="8.5" cy="7" r="4"></circle>
                            <line x1="20" y1="8" x2="20" y2="14"></line>
                            <line x1="23" y1="11" x2="17" y2="11"></line>
                        </svg>
                        Add Administrator
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
