@extends('layouts.dashboard')

@section('title', __('Perfil de Organizador'))

@push('head')
    <style>
        .rt-ios-input {
            border-radius: 12px !important;
            border: 1px solid rgba(0,0,0,0.08) !important;
            padding: 0.75rem 1rem !important;
            font-size: 0.95rem !important;
            background-color: #f9f9fb !important;
            transition: all 0.2s;
        }
        .rt-ios-input:focus {
            background-color: #ffffff !important;
            border-color: var(--rt-cherry) !important;
            box-shadow: 0 0 0 4px rgba(185, 24, 48, 0.1) !important;
        }
        .rt-label {
            font-weight: 700;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: #8e8e93;
            margin-bottom: 0.5rem;
        }
        .rt-status-card {
            background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
            color: #ffffff;
            border-radius: 24px;
        }
    </style>
@endpush

@section('content')
    <div class="container-fluid px-0">
        {{-- Header --}}
        <div class="mb-5 mt-2">
            <h1 class="h2 fw-bold text-dark mb-1">{{ __('Perfil de Organizador') }}</h1>
            <p class="text-muted small">{{ __('Configura tu identidad corporativa y preferencias de pago.') }}</p>
        </div>

        <div class="row g-4">
            {{-- Datos de la Organización --}}
            <div class="col-lg-8">
                <div class="card border-0 shadow-sm mb-4" style="border-radius: 24px;">
                    <div class="card-header bg-transparent border-0 px-4 pt-4">
                        <div class="d-flex align-items-center">
                            <div class="rounded-3 d-flex align-items-center justify-content-center me-2" style="width: 32px; height: 32px; background: rgba(37, 99, 235, 0.1); color: #2563eb;">
                                <i class="fas fa-building fa-xs"></i>
                            </div>
                            <h6 class="fw-bold text-dark mb-0">{{ __('Información Corporativa') }}</h6>
                        </div>
                    </div>
                    <div class="card-body p-4">
                        <form method="POST" action="{{ route('dashboard.profile.update') }}">
                            @csrf
                            @method('PUT')

                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label class="rt-label" for="name">{{ __('Nombre del Contacto') }}</label>
                                    <input type="text" name="name" id="name" value="{{ old('name', $user->name) }}" 
                                           class="form-control rt-ios-input @error('name') is-invalid @enderror" required>
                                    @error('name')<span class="invalid-feedback">{{ $message }}</span>@enderror
                                </div>

                                <div class="col-md-6">
                                    <label class="rt-label" for="phone">{{ __('Teléfono de Contacto') }}</label>
                                    <input type="text" name="phone" id="phone" value="{{ old('phone', $user->phone) }}" 
                                           class="form-control rt-ios-input @error('phone') is-invalid @enderror" required maxlength="32">
                                    @error('phone')<span class="invalid-feedback">{{ $message }}</span>@enderror
                                </div>

                                <div class="col-md-12">
                                    <label class="rt-label" for="organization_name">{{ __('Nombre de la Organización / Empresa') }}</label>
                                    <input type="text" name="organization_name" id="organization_name" value="{{ old('organization_name', $user->organization_name) }}" 
                                           class="form-control rt-ios-input @error('organization_name') is-invalid @enderror" required maxlength="255">
                                    @error('organization_name')<span class="invalid-feedback">{{ $message }}</span>@enderror
                                </div>

                                <div class="col-md-12">
                                    <label class="rt-label" for="primary_event_type">{{ __('Tipo de Eventos Principal') }}</label>
                                    <select name="primary_event_type" id="primary_event_type" class="form-select rt-ios-input @error('primary_event_type') is-invalid @enderror" required>
                                        @foreach (\App\Enums\OrganizerPrimaryEventType::cases() as $type)
                                            <option value="{{ $type->value }}" @selected(old('primary_event_type', $user->organizer?->primary_event_type?->value) === $type->value)>{{ $type->label() }}</option>
                                        @endforeach
                                    </select>
                                    @error('primary_event_type')<span class="invalid-feedback">{{ $message }}</span>@enderror
                                </div>

                                <div class="col-md-12">
                                    <div class="p-3 rounded-3 mt-2" style="background: #f8fafc; border: 1px dashed #e2e8f0;">
                                        <label class="rt-label" for="paypal_email">
                                            <i class="fab fa-paypal me-1"></i> {{ __('Cuenta de PayPal para Cobros') }}
                                        </label>
                                        <input type="email" name="paypal_email" id="paypal_email" value="{{ old('paypal_email', $user->organizer?->paypal_email) }}" 
                                               class="form-control rt-ios-input @error('paypal_email') is-invalid @enderror" placeholder="pagos@tuorganizacion.com">
                                        @error('paypal_email')<span class="invalid-feedback">{{ $message }}</span>@enderror
                                        <p class="text-muted mt-2 mb-0" style="font-size: 0.7rem;">
                                            {{ __('Usaremos esta cuenta para enviarte los fondos de tus ventas de forma segura.') }}
                                        </p>
                                    </div>
                                </div>
                            </div>

                            <div class="mt-4 pt-3 border-top d-flex justify-content-end">
                                <button type="submit" class="btn btn-primary px-4 py-2" style="border-radius: 12px;">
                                    {{ __('Actualizar Perfil') }}
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            {{-- Estado y Seguridad --}}
            <div class="col-lg-4">
                {{-- Account Status Card --}}
                <div class="card rt-status-card border-0 shadow-lg mb-4">
                    <div class="card-body p-4 text-center">
                        <div class="rt-label text-white-50 mb-3">{{ __('Estado de Verificación') }}</div>
                        
                        @php($st = $user->account_status)
                        <div class="mb-3">
                            @if($st === \App\Enums\AccountStatus::Approved)
                                <div class="rounded-circle d-flex align-items-center justify-content-center mx-auto mb-2 shadow-lg" style="width: 64px; height: 64px; background: #22c55e;">
                                    <i class="fas fa-check-double text-white fs-3"></i>
                                </div>
                                <h5 class="fw-bold mb-0 text-white">{{ __('Organizador Verificado') }}</h5>
                            @elseif($st === \App\Enums\AccountStatus::AwaitingReview)
                                <div class="rounded-circle d-flex align-items-center justify-content-center mx-auto mb-2 shadow-lg" style="width: 64px; height: 64px; background: #f59e0b;">
                                    <i class="fas fa-hourglass-half text-white fs-3"></i>
                                </div>
                                <h5 class="fw-bold mb-0 text-white">{{ __('En Revisión') }}</h5>
                            @elseif($st === \App\Enums\AccountStatus::Rejected)
                                <div class="rounded-circle d-flex align-items-center justify-content-center mx-auto mb-2 shadow-lg" style="width: 64px; height: 64px; background: #ef4444;">
                                    <i class="fas fa-times text-white fs-3"></i>
                                </div>
                                <h5 class="fw-bold mb-0 text-white">{{ __('Acceso Rechazado') }}</h5>
                            @else
                                <div class="rounded-circle d-flex align-items-center justify-content-center mx-auto mb-2 shadow-lg" style="width: 64px; height: 64px; background: #6b7280;">
                                    <i class="fas fa-user-slash text-white fs-3"></i>
                                </div>
                                <h5 class="fw-bold mb-0 text-white">{{ __('Cuenta Inactiva') }}</h5>
                            @endif
                        </div>

                        @if($st === \App\Enums\AccountStatus::Rejected && $user->rejection_reason)
                            <div class="p-3 rounded-3 bg-white bg-opacity-10 small">
                                <strong>{{ __('Motivo:') }}</strong> {{ $user->rejection_reason }}
                            </div>
                        @endif
                    </div>
                </div>

                {{-- Security Quick Link --}}
                <div class="card border-0 shadow-sm" style="border-radius: 24px;">
                    <div class="card-body p-4">
                        <div class="rt-label mb-2">{{ __('Acceso') }}</div>
                        <div class="fw-bold text-dark mb-3">{{ $user->email }}</div>
                        <div class="text-muted small mb-0">
                            {{ __('Como organizador, tu cuenta está sujeta a auditorías de seguridad periódicas.') }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
