<?php

if (PHP_SAPI !== 'cli') {
    http_response_code(404);
    exit;
}

$root = dirname(__DIR__);
$versionFile = $root . '/VERSION';
$quotesFile = $root . '/modules/crm/quotes.php';
$errors = array();

$version = is_file($versionFile) ? trim((string)file_get_contents($versionFile)) : '';
$quotes = is_file($quotesFile) ? (string)file_get_contents($quotesFile) : '';

if ($version !== '7.2.8') {
    $errors[] = 'VERSION no corresponde a 7.2.8.';
}

$checks = array(
    'capa visual de oportunidad' => 'quote-opportunity-skin',
    'fondo principal homologado' => 'background: var(--surface-1) !important;',
    'campos del sistema visual' => 'class="form-field"',
    'selectores del sistema visual' => 'class="select"',
    'controles de 46 px' => 'height: 46px !important;',
    'estado focus homologado' => 'box-shadow: 0 0 0 4px rgba(0, 255, 48, .08) !important;',
    'ajuste responsive' => '#quoteLayerForm.quote-opportunity-skin .quote-form-bottom',
);

foreach ($checks as $label => $needle) {
    if ($quotes === '' || strpos($quotes, $needle) === false) {
        $errors[] = 'Falta ' . $label . '.';
    }
}

if (!empty($errors)) {
    foreach ($errors as $error) {
        fwrite(STDERR, 'BLOCKED: ' . $error . PHP_EOL);
    }
    exit(1);
}

echo 'READY: CRM QUOTES V7.2.8' . PHP_EOL;

