<?php

use App\Models\User;

test('admin client create form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.clients.individual.create'))
        ->assertOk();

    // Flux labels with required class will have data-flux-label and required class
    $response->assertSee('required', escape: false);
});

test('admin company create form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.clients.company.create'))
        ->assertOk();

    $response->assertSee('required', escape: false);
});

test('client booking form page loads successfully', function () {
    $client = User::factory()->individual()->create();

    // The booking page initially shows a calendar, required label appears after slot selection
    $this->actingAs($client)
        ->get(route('client.consultations.book'))
        ->assertOk();
});

test('admin posts create form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.posts.create'))
        ->assertOk();

    $response->assertSee('required', escape: false);
});

test('admin timeline create form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.timelines.create'))
        ->assertOk();

    $response->assertSee('required', escape: false);
});

test('admin individual client edit form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();
    $client = User::factory()->individual()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.clients.individual.edit', $client))
        ->assertOk();

    $response->assertSee('required', escape: false);
});

test('admin company client edit form renders with required class on labels', function () {
    $admin = User::factory()->admin()->create();
    $client = User::factory()->company()->create();

    $response = $this->actingAs($admin)
        ->get(route('admin.clients.company.edit', $client))
        ->assertOk();

    $response->assertSee('required', escape: false);
});

test('form pages include error handling structure', function () {
    $admin = User::factory()->admin()->create();

    // Forms have error fields that will display validation errors
    $this->actingAs($admin)
        ->get(route('admin.clients.individual.create'))
        ->assertOk()
        ->assertSee('full_name'); // Error field name present
});

test('app css contains form styling system comment', function () {
    $cssPath = resource_path('css/app.css');

    $this->assertFileExists($cssPath);

    $cssContent = file_get_contents($cssPath);

    // Verify the form styling section exists
    $this->assertStringContainsString('Form Styling System', $cssContent);
    $this->assertStringContainsString('.input-field', $cssContent);
    $this->assertStringContainsString('.form-label', $cssContent);
    $this->assertStringContainsString('.textarea-field', $cssContent);
    $this->assertStringContainsString('.checkbox-custom', $cssContent);
    $this->assertStringContainsString('.radio-custom', $cssContent);
    $this->assertStringContainsString('.error-message', $cssContent);
});

test('app css contains flux ui form component styling', function () {
    $cssPath = resource_path('css/app.css');

    $cssContent = file_get_contents($cssPath);

    // Verify Flux UI specific styling exists
    $this->assertStringContainsString('[data-flux-label]', $cssContent);
    $this->assertStringContainsString('[data-flux-field]', $cssContent);
    $this->assertStringContainsString('[data-flux-error]', $cssContent);
    $this->assertStringContainsString('border-gold', $cssContent);
    $this->assertStringContainsString('ring-gold', $cssContent);
});

test('app css contains rtl support for form elements', function () {
    $cssPath = resource_path('css/app.css');

    $cssContent = file_get_contents($cssPath);

    // Verify RTL support exists
    $this->assertStringContainsString('[dir="rtl"]', $cssContent);
    $this->assertStringContainsString('text-right', $cssContent);
});

test('app css contains required indicator styling', function () {
    $cssPath = resource_path('css/app.css');

    $cssContent = file_get_contents($cssPath);

    // Verify required indicator styling
    $this->assertStringContainsString('.required::after', $cssContent);
    $this->assertStringContainsString('text-danger', $cssContent);
});
