<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest extends TestCase
{
    use RefreshDatabase;

    protected function loginAsPlatformAdmin(): void
    {
        $this->seed();

        $this->post('/admin/login', [
            'email' => 'platform.admin@demo.local',
            'password' => 'Platform@123456',
        ])->assertRedirect('/admin');
    }

    public function test_admin_components_css_governance_blocks_should_use_theme_tokens(): void
    {
        $this->loginAsPlatformAdmin();

        $css = file_get_contents(public_path('css/admin-components.css'));
        $this->assertIsString($css);

        // 治理提示块必须用主题 token，避免硬编码色值导致整体风格难以统一。
        $this->assertStringContainsString('.governance-block{', $css);
        $this->assertStringContainsString('border:1px solid var(--adm-error-border-soft', $css);
        $this->assertStringContainsString('background:var(--adm-error-bg', $css);

        // 列表行内治理提示（row-warn）也必须用 token。
        // row-warn/row-warn-prefix 允许复用到仪表盘（按页面 scope），但平台订单列表的 scope 仍必须存在。
        $this->assertStringContainsString('.platform-orders-table .row-warn', $css);
        $this->assertStringContainsString('border-left:3px solid var(--adm-error', $css);
        $this->assertStringContainsString('.platform-orders-table .row-warn-prefix', $css);
        $this->assertStringContainsString('background:var(--adm-error-tint', $css);
    }
}
