@extends('layouts.customer')

@section('title', 'Create New Event - Admin')

@section('content')
<div class="admin-container">
    <!-- Page Header -->
    <div class="page-header">
        <h1>Create New Event</h1>
        <p class="subtitle">Add a new event to the system</p>
    </div>

    <!-- Event Form -->
    <div class="form-container">
        <form method="POST" action="{{ route('admin.events.store') }}">
            @csrf

            <!-- Event Name -->
            <div class="form-group">
                <label for="name">Event Name *</label>
                <input 
                    type="text" 
                    id="name" 
                    name="name" 
                    class="form-input @error('name') error @enderror" 
                    value="{{ old('name') }}" 
                    required
                    placeholder="e.g., Premium Wine Tasting"
                >
                @error('name')
                    <span class="error-message">{{ $message }}</span>
                @enderror
            </div>

            <!-- Description -->
            <div class="form-group">
                <label for="description">Description *</label>
                <textarea 
                    id="description" 
                    name="description" 
                    rows="4" 
                    class="form-input @error('description') error @enderror" 
                    required
                    placeholder="Describe the event experience..."
                >{{ old('description') }}</textarea>
                @error('description')
                    <span class="error-message">{{ $message }}</span>
                @enderror
            </div>

            <!-- Event Type -->
            <div class="form-group">
                <label for="type">Event Type *</label>
                <select id="type" name="type" class="form-select @error('type') error @enderror" required>
                    <option value="">Select event type...</option>
                    <option value="tasting" {{ old('type') === 'tasting' ? 'selected' : '' }}>🍷 Wine Tasting</option>
                    <option value="harvest_festival" {{ old('type') === 'harvest_festival' ? 'selected' : '' }}>🍇 Harvest Festival</option>
                    <option value="vineyard_tour" {{ old('type') === 'vineyard_tour' ? 'selected' : '' }}>🚶 Vineyard Tour</option>
                </select>
                @error('type')
                    <span class="error-message">{{ $message }}</span>
                @enderror
            </div>

            <!-- Date and Time -->
            <div class="form-row">
                <div class="form-group">
                    <label for="event_date">Event Date *</label>
                    <input 
                        type="date" 
                        id="event_date" 
                        name="event_date" 
                        class="form-input @error('event_date') error @enderror" 
                        value="{{ old('event_date') }}" 
                        min="{{ date('Y-m-d') }}"
                        required
                    >
                    @error('event_date')
                        <span class="error-message">{{ $message }}</span>
                    @enderror
                </div>

                <div class="form-group">
                    <label for="event_time">Event Time *</label>
                    <input 
                        type="time" 
                        id="event_time" 
                        name="event_time" 
                        class="form-input @error('event_time') error @enderror" 
                        value="{{ old('event_time', '14:00') }}" 
                        required
                    >
                    @error('event_time')
                        <span class="error-message">{{ $message }}</span>
                    @enderror
                </div>
            </div>

            <!-- Capacity and Price -->
            <div class="form-row">
                <div class="form-group">
                    <label for="capacity">Capacity (Max Guests) *</label>
                    <input 
                        type="number" 
                        id="capacity" 
                        name="capacity" 
                        class="form-input @error('capacity') error @enderror" 
                        value="{{ old('capacity', 20) }}" 
                        min="1" 
                        max="500"
                        required
                        placeholder="e.g., 20"
                    >
                    @error('capacity')
                        <span class="error-message">{{ $message }}</span>
                    @enderror
                </div>

                <div class="form-group">
                    <label for="price_per_person">Price per Person (€) *</label>
                    <input 
                        type="number" 
                        id="price_per_person" 
                        name="price_per_person" 
                        class="form-input @error('price_per_person') error @enderror" 
                        value="{{ old('price_per_person', 25.00) }}" 
                        min="0" 
                        step="0.01" 
                        required
                        placeholder="e.g., 25.00"
                    >
                    @error('price_per_person')
                        <span class="error-message">{{ $message }}</span>
                    @enderror
                </div>
            </div>

            <!-- Location -->
            <div class="form-group">
                <label for="location">Location</label>
                <input 
                    type="text" 
                    id="location" 
                    name="location" 
                    class="form-input @error('location') error @enderror" 
                    value="{{ old('location') }}"
                    placeholder="e.g., Main Cellar, Vineyard Hill, Tasting Room"
                >
                @error('location')
                    <span class="error-message">{{ $message }}</span>
                @enderror
                <span class="form-hint">Optional: Specify where the event will take place</span>
            </div>

            <!-- Status -->
            <div class="form-group">
                <label for="status">Status *</label>
                <select id="status" name="status" class="form-select @error('status') error @enderror" required>
                    <option value="upcoming" {{ old('status', 'upcoming') === 'upcoming' ? 'selected' : '' }}>Upcoming</option>
                    <option value="cancelled" {{ old('status') === 'cancelled' ? 'selected' : '' }}>Cancelled</option>
                    <option value="completed" {{ old('status') === 'completed' ? 'selected' : '' }}>Completed</option>
                </select>
                @error('status')
                    <span class="error-message">{{ $message }}</span>
                @enderror
                <span class="form-hint">New events are usually set to "Upcoming"</span>
            </div>

            <!-- Form Actions -->
            <div class="form-actions">
                <a href="{{ route('admin.events.index') }}" class="btn-cancel">Cancel</a>
                <button type="submit" class="btn-submit">
                    <svg style="width: 20px; height: 20px;" fill="currentColor" viewBox="0 0 20 20">
                        <path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd"/>
                    </svg>
                    Create Event
                </button>
            </div>
        </form>
    </div>
</div>

<style>
    .admin-container {
        max-width: 100%;
    }

    .page-header {
        text-align: center;
        margin-bottom: 3rem;
    }

    .page-header h1 {
        font-size: 2.5rem;
        color: #2d3748;
        margin-bottom: 0.5rem;
        font-weight: 700;
    }

    .subtitle {
        font-size: 1.1rem;
        color: #718096;
    }

    .form-container {
        max-width: 800px;
        margin: 0 auto;
        background: white;
        padding: 2.5rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .form-group {
        margin-bottom: 1.5rem;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    label {
        display: block;
        font-weight: 600;
        color: #2d3748;
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    .form-input,
    .form-select {
        width: 100%;
        padding: 0.875rem 1rem;
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        font-size: 1rem;
        transition: all 0.2s;
        background: #f7fafc;
        font-family: inherit;
    }

    textarea.form-input {
        resize: vertical;
        min-height: 100px;
    }

    .form-input:focus,
    .form-select:focus {
        outline: none;
        border-color: #89b4d9;
        background: white;
    }

    .form-input.error,
    .form-select.error {
        border-color: #fc8181;
        background: #fff5f5;
    }

    .form-hint {
        display: block;
        color: #718096;
        font-size: 0.875rem;
        margin-top: 0.5rem;
        font-style: italic;
    }

    .error-message {
        display: block;
        color: #e53e3e;
        font-size: 0.875rem;
        margin-top: 0.5rem;
    }

    .form-actions {
        display: flex;
        gap: 1rem;
        margin-top: 2rem;
        padding-top: 2rem;
        border-top: 2px solid #e2e8f0;
    }

    .btn-submit,
    .btn-cancel {
        flex: 1;
        padding: 0.875rem 1.75rem;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        border: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        text-decoration: none;
    }

    .btn-submit {
        background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
        color: white;
        box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
    }

    .btn-submit:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    }

    .btn-cancel {
        background: #f7fafc;
        color: #4a5568;
        border: 2px solid #e2e8f0;
    }

    .btn-cancel:hover {
        background: #edf2f7;
    }

    @media (max-width: 768px) {
        .form-container {
            padding: 1.5rem;
        }

        .form-row {
            grid-template-columns: 1fr;
        }

        .form-actions {
            flex-direction: column;
        }
    }
</style>
@endsection
