use Livewire\Component;
class PricingCalculator extends Component
{
    // ...
    public function updated($property)
    {
        // Use direct validation for simplicity on update
         $numericProps = [
            'webInstances', 'workerInstances', 'databaseStorageGB',
            'postgresComputeUnits', 'objectStorageGB', 'objectStorageClassAOpsThousands',
            'objectStorageClassBOpsThousands', 'dataTransfer', 'requests',
            'customDomains', 'additionalUsers'
        ];
        if (in_array($property, $numericProps)) {
            $validated = Validator::make(
                [$property => $this->$property],
                [$property => 'numeric|min:0']
            )->validate();
            // Coerce specific integers
             $intProps = ['webInstances', 'workerInstances', 'databaseStorageGB', 'objectStorageGB', 'dataTransfer', 'requests', 'customDomains', 'additionalUsers'];
             if (in_array($property, $intProps)) {
                 $this->$property = max(0, (int)$validated[$property]);
             }
             // Coerce specific floats/decimals
             $floatProps = ['postgresComputeUnits', 'objectStorageClassAOpsThousands', 'objectStorageClassBOpsThousands'];
             if (in_array($property, $floatProps)) {
                $this->$property = max(0, (float)$validated[$property]);
             }
        }
        // Reset dependent values when the plan changes
        if ($property === 'plan') {
            $this->resetUsageToPlanDefaults();
            $this->validateInputsForPlan(); // Keep potential plan specific validation logic
        }
        // Reset database size if type changes
        if ($property === 'databaseType') {
            if ($this->databaseType === 'mysql') {
                $this->mysqlDatabaseSize = $this->pricingService->getMySqlDefaultSizeKey() ?? 'mysql-flex-1c-1g'; // Provide a fallback
            } elseif ($this->databaseType === 'postgres') {
                 $this->postgresComputeUnits = $this->pricingService->getPostgresMinCpu();
            }
        }
         // Reset KV tier if toggled off or default missing
         if (($property === 'includeKv' && !$this->includeKv) || ($property === 'kvTier' && !$this->kvTier)) {
              $this->kvTier = $this->pricingService->getKvDefaultTierKey() ?? '1gb'; // Fallback
         }
         // Reset object storage if toggled off
         if ($property === 'includeObjectStorage' && !$this->includeObjectStorage) {
             $this->objectStorageGB = 10;
             $this->objectStorageClassAOpsThousands = 100;
             $this->objectStorageClassBOpsThousands = 1000;
         }
         // Reset workers if toggled off or default missing
         if (($property === 'includeWorkers' && !$this->includeWorkers) || ($property === 'workerComputeSize' && !$this->workerComputeSize)) {
             $this->workerComputeSize = $this->pricingService->getComputeDefaultSizeKey() ?? 'flex-1c-512m'; // Fallback
             $this->workerInstances = 1;
         }
         // Reset web compute if default missing
         if ($property === 'webComputeSize' && !$this->webComputeSize) {
            $this->webComputeSize = $this->pricingService->getComputeDefaultSizeKey() ?? 'flex-1c-1g'; // Fallback
         }
    }
    // ...
}