<?php

use Illuminate\Support\Facades\App;

test('primary button class renders with correct styles', function () {
    $view = $this->blade('<button class="btn-primary">Submit</button>');

    $view->assertSee('btn-primary', false);
    $view->assertSee('Submit');
});

test('secondary button class renders with correct styles', function () {
    $view = $this->blade('<button class="btn-secondary">Cancel</button>');

    $view->assertSee('btn-secondary', false);
    $view->assertSee('Cancel');
});

test('danger button class renders with correct styles', function () {
    $view = $this->blade('<button class="btn-danger">Delete</button>');

    $view->assertSee('btn-danger', false);
    $view->assertSee('Delete');
});

test('disabled button renders with disabled attribute', function () {
    $view = $this->blade('<button class="btn-primary" disabled>Disabled</button>');

    $view->assertSee('disabled', false);
    $view->assertSee('Disabled');
});

test('btn-disabled class can be applied explicitly', function () {
    $view = $this->blade('<button class="btn-primary btn-disabled">Disabled</button>');

    $view->assertSee('btn-disabled', false);
});

test('small button size variant renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-sm">Small</button>');

    $view->assertSee('btn-sm', false);
    $view->assertSee('Small');
});

test('large button size variant renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-lg">Large</button>');

    $view->assertSee('btn-lg', false);
    $view->assertSee('Large');
});

test('full width button variant renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-full">Full Width</button>');

    $view->assertSee('btn-full', false);
    $view->assertSee('Full Width');
});

test('loading state class renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-loading">Loading</button>');

    $view->assertSee('btn-loading', false);
});

test('button with left icon class renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-icon-left"><span>Icon</span> Add</button>');

    $view->assertSee('btn-icon-left', false);
    $view->assertSee('Add');
});

test('button with right icon class renders correctly', function () {
    $view = $this->blade('<button class="btn-primary btn-icon-right">Next <span>Icon</span></button>');

    $view->assertSee('btn-icon-right', false);
    $view->assertSee('Next');
});

test('button group renders correctly', function () {
    $view = $this->blade('
        <div class="btn-group">
            <button class="btn-primary">First</button>
            <button class="btn-primary">Second</button>
            <button class="btn-primary">Third</button>
        </div>
    ');

    $view->assertSee('btn-group', false);
    $view->assertSee('First');
    $view->assertSee('Second');
    $view->assertSee('Third');
});

test('multiple button classes can be combined', function () {
    $view = $this->blade('<button class="btn-primary btn-sm btn-icon-left">Combined</button>');

    $view->assertSee('btn-primary', false);
    $view->assertSee('btn-sm', false);
    $view->assertSee('btn-icon-left', false);
});

test('buttons render correctly in RTL mode', function () {
    App::setLocale('ar');

    $view = $this->blade('
        <html lang="ar" dir="rtl">
            <body>
                <button class="btn-primary btn-icon-left">
                    <span>Icon</span>
                    أضف جديد
                </button>
            </body>
        </html>
    ');

    $view->assertSee('dir="rtl"', false);
    $view->assertSee('btn-icon-left', false);
    $view->assertSee('أضف جديد');
});

test('flux button with primary class renders correctly', function () {
    $view = $this->blade('<flux:button class="btn-primary">Flux Primary</flux:button>');

    $view->assertSee('btn-primary', false);
    $view->assertSee('Flux Primary');
});

test('flux button with secondary class renders correctly', function () {
    $view = $this->blade('<flux:button class="btn-secondary">Flux Secondary</flux:button>');

    $view->assertSee('btn-secondary', false);
    $view->assertSee('Flux Secondary');
});

test('flux button with danger class renders correctly', function () {
    $view = $this->blade('<flux:button class="btn-danger">Flux Danger</flux:button>');

    $view->assertSee('btn-danger', false);
    $view->assertSee('Flux Danger');
});

test('flux button with size variant renders correctly', function () {
    $view = $this->blade('<flux:button class="btn-primary btn-lg">Large Flux</flux:button>');

    $view->assertSee('btn-lg', false);
    $view->assertSee('Large Flux');
});

test('flux button with icon renders correctly', function () {
    $view = $this->blade('<flux:button icon="plus" class="btn-primary btn-icon-left">Add Item</flux:button>');

    $view->assertSee('btn-primary', false);
    $view->assertSee('Add Item');
});
