<?php

use Illuminate\Support\Facades\File;

test('default.css uses new charcoal color for links', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toContain('a {')
        ->and($css)->toContain('color: #4A4A42;');
});

test('default.css uses new charcoal color for h1 headings', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/h1\s*\{[^}]*color:\s*#4A4A42;/');
});

test('default.css uses new charcoal color for h2 headings', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/h2\s*\{[^}]*color:\s*#4A4A42;/');
});

test('default.css uses new charcoal color for h3 headings', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/h3\s*\{[^}]*color:\s*#4A4A42;/');
});

test('default.css uses new charcoal color for header background', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.header\s*\{[^}]*background-color:\s*#4A4A42;/');
});

test('default.css uses new warm gray color for footer links', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.footer a\s*\{[^}]*color:\s*#C9C4BA;/');
});

test('default.css uses new charcoal color for table headers', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.table th\s*\{[^}]*color:\s*#4A4A42;/');
});

test('default.css uses new charcoal background for primary buttons', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.button-primary\s*\{[^}]*background-color:\s*#4A4A42;/');
});

test('default.css uses new off-white text for primary buttons', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.button-primary\s*\{[^}]*color:\s*#E8E4DC;/');
});

test('default.css uses new warm gray color for panel border', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    expect($css)->toMatch('/\.panel\s*\{[^}]*border-left:\s*#C9C4BA/');
});

test('header.blade.php uses new charcoal background color', function () {
    $header = File::get(resource_path('views/vendor/mail/html/header.blade.php'));

    expect($header)->toContain('background-color: #4A4A42;');
});

test('header.blade.php does not use old navy color', function () {
    $header = File::get(resource_path('views/vendor/mail/html/header.blade.php'));

    expect($header)->not->toContain('#0A1F44');
});

test('footer.blade.php uses new warm gray color for links', function () {
    $footer = File::get(resource_path('views/vendor/mail/html/footer.blade.php'));

    expect($footer)->toContain('color: #C9C4BA;');
});

test('footer.blade.php does not use old gold color', function () {
    $footer = File::get(resource_path('views/vendor/mail/html/footer.blade.php'));

    expect($footer)->not->toContain('#D4AF37');
});

test('default.css does not use old navy color for headings and links', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    // Check that old navy color is not used in headings
    expect($css)->not->toMatch('/h1\s*\{[^}]*color:\s*#0A1F44;/')
        ->and($css)->not->toMatch('/h2\s*\{[^}]*color:\s*#0A1F44;/')
        ->and($css)->not->toMatch('/h3\s*\{[^}]*color:\s*#0A1F44;/');
});

test('default.css does not use old gold color for buttons and panels', function () {
    $css = File::get(resource_path('views/vendor/mail/html/themes/default.css'));

    // Check that old gold color is not used in buttons
    expect($css)->not->toMatch('/\.button-primary\s*\{[^}]*background-color:\s*#D4AF37;/')
        ->and($css)->not->toMatch('/\.panel\s*\{[^}]*border-left:\s*#D4AF37/');
});
