"""Offline structural checks; NOT a Flutter compile or end-to-end database test."""
import re
from pathlib import Path
root=Path(__file__).resolve().parent.parent
files=['pubspec.yaml','lib/main.dart','lib/admin.dart','lib/employee.dart','lib/theme.dart','lib/api.dart','lib/maps.dart','lib/services.dart','lib/finance.dart','server/api.php','server/core.php','server/install.php','server/schema.sql','server/push.php','server/finance.php','server/migrations/002_art_car_finance.sql','scripts/build_android.ps1','tests/finance_rules.php','assets/branding/art_car_logo.png']
for name in files:
    path=root/name
    assert path.is_file(),f'Missing {path}'
    assert path.stat().st_size>200,f'Empty {path}'
backend=(root/'server/api.php').read_text()
for dart in (root/'lib').glob('*.dart'):
    source=dart.read_text()
    for action in re.findall(r'FleetApi\.instance\.(?:get|post)\(\s*\'([a-z_]+)\'',source):
        assert f"case '{action}':" in backend,f'Missing API endpoint {action} in {dart.name}'
assert len(list((root/'design_reference').glob('*.png')))==10
assert 'ART CAR' in (root/'lib/main.dart').read_text()
assert 'https://art.codeone.site/api' in (root/'lib/api.dart').read_text()
for needed in ('finance_report','finance_adjust','finance_audit'):
    assert f"case '{needed}':" in backend
for col in ('charge_amount','payment_method','collection_status','collected_amount','collection_audit'):
    assert col in (root/'server/schema.sql').read_text()
for dens in ['mdpi','hdpi','xhdpi','xxhdpi','xxxhdpi']:
    assert (root/f'scripts/icons/mipmap-{dens}/ic_launcher.png').exists()
print('OK: source, 10 reference images, branding, finance SQL, all UI API endpoints')
