@extends('eliteadmin::layouts.installer')

@section('title', 'Installation - Database')

@section('content')
    <h2 class="h4 mb-3">Database Configuration</h2>
    <p class="text-muted mb-4">Enter your database connection details.</p>

    <form action="{{ route('installer.database.store') }}" method="POST">
        @csrf

        <div class="row g-3 mb-4">
            <div class="col-md-6">
                <label for="db_connection" class="form-label">Database Type</label>
                <input type="hidden" name="db_connection" value="mysql">
                <input type="text" id="db_connection" class="form-control bg-light" value="MySQL" readonly>
                <div class="form-text">MySQL is required for this platform.</div>
            </div>
            <div class="col-md-6">
                <label for="db_host" class="form-label">Database Host</label>
                <input type="text" name="db_host" id="db_host" class="form-control @error('db_host') is-invalid @enderror"
                       value="{{ old('db_host', 'localhost') }}" required>
                @error('db_host')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="db_port" class="form-label">Database Port</label>
                <input type="number" name="db_port" id="db_port" class="form-control @error('db_port') is-invalid @enderror"
                       value="{{ old('db_port', '3306') }}" required>
                @error('db_port')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="db_database" class="form-label">Database Name</label>
                <input type="text" name="db_database" id="db_database" class="form-control @error('db_database') is-invalid @enderror"
                       value="{{ old('db_database') }}" required>
                @error('db_database')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="db_username" class="form-label">Database Username</label>
                <input type="text" name="db_username" id="db_username" class="form-control @error('db_username') is-invalid @enderror"
                       value="{{ old('db_username') }}" required>
                @error('db_username')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="db_password" class="form-label">Database Password</label>
                <input type="password" name="db_password" id="db_password" class="form-control @error('db_password') is-invalid @enderror"
                       value="{{ old('db_password') }}">
                @error('db_password')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
        </div>

        <div class="d-flex flex-column flex-sm-row gap-2 justify-content-between">
            <a href="{{ route('installer.requirements') }}" class="btn btn-outline-secondary">Back</a>
            <div class="d-flex gap-2">
                <button type="submit" name="action" value="test" class="btn btn-outline-primary">Test Connection</button>
                <button type="submit" name="action" value="continue" class="btn btn-primary">Continue</button>
            </div>
        </div>
    </form>
@endsection
